[cxml-devel] Dom-impl improvements

Nathan Bird nathan at acceleration.net
Tue Jun 13 16:52:04 UTC 2006


We are building up a dom in memory as part of some XHTML and XUL generation.
Found time/memory being spent in append-child which we make heavy use of.

Here are some changes that improve this. The children of a node are stored
in a node-list (adjustable vector).  
Changes involved:
  -Don't allocate a node list until we actually HAVE children
  -When allocating a node-list, go ahead and make it 4 elements long
(instead of 0) so we don't immediately reallocate, and again.
  -When vector-push-extending. Let the lisp implementation take care of
increasing the size, instead of manually increasing by length 1 every
time. Again this reduces constant reallocation.
  -Use the has-child-nodes function instead of comparing length everywhere.


I attached some test results I got (kind of long), here are the summary
lines:
  seconds  |   consed   |  calls  |  sec/call  |  name  
----------------------------------------------------------
     2.092 | 32,227,920 | 708,718 |            | Total   ;;OLD
     0.859 | 25,507,240 | 691,366 |            | Total   ;;NEW
-------------- next part --------------
A non-text attachment was scrubbed...
Name: prof-dom-impl.results
Type: application/octet-stream
Size: 7918 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/cxml-devel/attachments/20060613/0999f164/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dom-impl-children.diff
Type: application/octet-stream
Size: 5050 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/cxml-devel/attachments/20060613/0999f164/attachment-0001.obj>


More information about the cxml-devel mailing list