Using the built-in XML writer class will help simplify a lot of the generation code plus hopefully save a little bit of memory, if not maybe make it faster. I need to get a patch and then compare the before & after for sitemap generation.
| Comment | File | Size | Author |
|---|---|---|---|
| #22 | 764658-xmlsitemap-xmlwriter-D6.patch | 10.5 KB | dave reid |
| #20 | 764658-xmlsitemap-xmlwriter-D7.patch | 10.72 KB | dave reid |
| #19 | 764658-xmlsitemap-xmlwriter-D7.patch | 10.72 KB | dave reid |
| #9 | 764658-xmlsitemap-xmlwriter-D6.patch | 7.52 KB | dave reid |
| #2 | 764658-xmlsitemap-xmlwriter-D7.patch | 7.99 KB | dave reid |
Comments
Comment #1
dave reidThe D6 version needs to add a requirements check to ensure the class exists, as XMLWriter is included by default only as of PHP 5.1.2.
Comment #2
dave reidInitial performance testing:
So we get a marginal time difference. However, the memory usage shows something interesting:
Patch saved about 256 KB with about 7000 nodes. I'm not sure if this should proceed or not.
Comment #3
Anonymous (not verified) commentedSince it is slower my gut feel is a no go but reduced memory is also a performance factor. However, the speed of this module is more important due to its nature.
Comment #4
dave reidYeah I think I need to test with an even bigger data set. The percentage difference for memory usage was way more than the percentage difference in execution.
Comment #5
hass commentedIf you explain me how to collect the stats I'm able to run this tests on a site with 150.000 nodes, 2000 taxonomy term...
Comment #6
dave reidI created a 'test.php' file in my Drupal's root folder:
And then run the apache ab benchmarking command & record results from before & after patch:
ab -c 1 -n 25 http://mysql.drupal7dev.local/test.phpIf you have a smaller data set, you can change the 'n' paramter to a higher value, but for a large data set I wouldn't recommend going over 25 loops.
Comment #7
dave reidOk so I think I've finally come up with a compelling reason why we should make this switch. #786510: Contexts should be able to alter the XML header output (and possibly link output?) needs other modules to be able to modify the XML schema and individual XML link elements. That's super easy to do with XMLWriter were we can pass the writer object or the element object to the alter functions. Currently it's not easy to do otherwise.
Comment #8
hass commentedSorry, for testing I need a D6 patch... this big testing site is D6 only.
Comment #9
dave reidHere's the patch against the current DRUPAL-6--1 branch.
Comment #10
dave reidAnyone? :/
Comment #11
Anonymous (not verified) commentedIs there some reason to hang onto
or did you just forget to remove it in the final?
Comment #12
dave reidI'm not sure how I'm going to handle that. I may just remove the $status handling everywhere. At this point I'm more concerned about performance testing to see that this isn't going to be horrible change.
Comment #13
Anonymous (not verified) commentedI'm not setup to do performance testing. Maybe one of the users with 50K or more can give the change a try.
Comment #15
moshe weitzman commentedFWIW, I have always done my XML writing with core's format_xml_elements() but I never had a huge dataset.
Comment #16
dave reidYeah the problem is that we need to allow other modules to alter stuff in the XML head, namespaces, etc. I would think we'd get better performance using the native XMLWriter rather than generating large amounts of arrays (or a large number of separate small arrays). I'm going to move ahead with this issue this weekend as it's blocking other good patches from going in. If we encounter any major problems (none discovered in testing so far), it is possible to rollback.
Comment #17
dave reidI'm going to proceed with this since it has not gotten any reviews and is blocking a major feature.
Comment #18
dave reidComment #19
dave reidOMG yes this is exactly the approach I want to do because this allows us to extend the XMLWriter into our own XMLSitemapWriter class and also allows us to override XMLWriter::flush to keep track of the file writing status.
Comment #20
dave reidRevised patch
Comment #21
dave reidCommitted to CVS!
http://drupal.org/cvs?commit=413418
Comment #22
dave reidCommitted this to CVS on 6.x-2.x as well.
http://drupal.org/cvs?commit=413422