Req #52634 [Opn->Sus]: Add depth as argument to expand minimizing mem-footprint.

From: Date: Mon, 07 Dec 2020 16:34:07 +0000
Subject: Req #52634 [Opn->Sus]: Add depth as argument to expand minimizing mem-footprint.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-230913@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=52634&edit=1

 ID:                 52634
 Updated by:         cmb@php.net
 Reported by:        email at robertdewilde dot nl
 Summary:            Add depth as argument to expand minimizing
                     mem-footprint.
-Status:             Open
+Status:             Suspended
 Type:               Feature/Change Request
 Package:            XML Reader
 Operating System:   CentOS 5
 PHP Version:        5.3.3
 Block user comment: N
 Private report:     N

 New Comment:

The point is that XMLReader is unidirectional.  If a node would
have been expanded to a certain level, none of the nodes below
this level could ever be accessed again; well, at least not until
we re-implement the expansion ourselves, what I consider very
unlikely.  If you, or anybody else, still feels stronly about
this, please forward the request to the internals mailing list for
discussion.  For the time being, I'm suspending this ticket.


Previous Comments:
------------------------------------------------------------------------
[2010-08-18 15:41:23] email at robertdewilde dot nl

Description:
------------
I would really like an additional argument to the expand() method (which I do like). I think the
biggest problem will be that the result should become some kind of semimanufactured DOM tree. Using
the expand() method I'll get the complete tree (which can be huge on higher depth levels).
Minimizing it to a number of levels would really limit the mem.footprint it'll create.

For example, I have a huge XML document with all sorts if nested resources. Using XMLReader
i'll find the first on (city). I'd like to expand it, but not all the streets it has
inside. I'd like to limit the depthOffset to 1 (only the direct childs). Because it can skip a
lot of parsing, it'll minimize processing costs and will consume less mem. 

Now I'd like to parse the streets. I decide to destruct my DOM-tree to save mem, and continue
searching for streets in my 'city' using XMLReader. At last, I found one. I'd
expand() it, but not all the way (I still don't want to know the details of all the houses,
actually, I never want it). I limit my expanding to the depthOffset 1 or maybe 2 (if house are
nested in another layer of elements). When I finished handling my street, I can destruct the
DOM-tree and go XMLRead the next one.


How bigger (and nested) the input is, the more memory I'll save limiting the expand. Other
options for the expand could be helpfull either (first 5 childs etc.) but it shouldn't become
too fullfeatured because it probably bring down performance.


Is it possible to add some sort of 'depthOffset' argument/config-setting to the
expand()-method? 

Test script:
---------------
500MB of heavily nested XML-data.

Expected result:
----------------
Only mem. footprint for what I'd actually use the expand() for.

Actual result:
--------------
Huge processing/mem. footprint for everything that's inside of the current node (parsed to
DOM).


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=52634&edit=1


Thread (2 messages)

« previous php.bugs (#230913) next »