php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #52634 Add depth as argument to expand minimizing mem-footprint.
Submitted: 2010-08-18 15:41 UTC Modified: 2020-12-07 16:34 UTC
From: email at robertdewilde dot nl Assigned:
Status: Suspended Package: XML Reader
PHP Version: 5.3.3 OS: CentOS 5
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: email at robertdewilde dot nl
New email:
PHP Version: OS:

 

 [2010-08-18 15:41 UTC] 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).

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-12-07 16:34 UTC] cmb@php.net
-Status: Open +Status: Suspended
 [2020-12-07 16:34 UTC] cmb@php.net
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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 01:01:28 2024 UTC