Skip to content

XPath optimizations

Nick Wellnhofer requested to merge nwellnhof/libxml2:xpath-optimizations into master

This branch contains many cleanups, simplifications and optimizations of the XPath code. Also see #834.

Most notably:

  • Node tests are much faster.
  • Axis traversal was rewritten and is a bit faster.
  • Built-in functions are evaluated more efficiently.
  • Some built-in functions are compiled into their own ops.
  • The optimization for filtering first or last elements was reworked and should be much faster.
  • Optimizations for evaluation in Boolean context are improved.
  • The "parser" context and the value stack are reused, resulting in much fewer memory allocations if multiple expressions are evaluated.
  • Types are converted explicitly and only if needed.
  • Many micro-optimizations

My main benchmark was creating parts of the OpenGL documentation in DocBook format using xsltproc:

cd gl4/html
time path/to/xsltproc --nonet --xinclude --noout opengl-man.xsl ../gl*

This now completes in 5.85 seconds compared to 7.57 on master on my MacBook, a speedup of about 30%. (Note that xsltproc shipped with macOS 15 and based on libxml2 2.9.13 takes 8.75 seconds.)

Edited by Nick Wellnhofer

Merge request reports

Loading