Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to initialize xmlXPathContext faster #3388

Closed
wants to merge 2 commits into from

Conversation

flavorjones
Copy link
Member

What problem is this PR intended to solve?

A variation on solving the "slow xpath context creation" problem described in #3266. See first attempt at #3378.

Copying the struct and the hash tables is slightly faster than calling xmlXpathNewContext:

Comparison:
    large: optimized:    17780.0 i/s
         large: main:    15143.4 i/s - same-ish: difference falls within error

Comparison:
    small: optimized:    62891.9 i/s
         small: main:    49413.5 i/s - 1.27x  slower

But still slower than re-using the context object ("edge", v1.18.0.rc1):

Comparison:
         large: edge:    22230.9 i/s
    large: optimized:    17780.0 i/s - 1.25x  slower
         large: main:    15143.4 i/s - 1.47x  slower

Comparison:
         small: edge:   129162.0 i/s
    small: optimized:    62891.9 i/s - 2.05x  slower
         small: main:    49413.5 i/s - 2.61x  slower

I probably won't merge this, but thought it was worth sharing for posterity.

Next I'm going to try an extension of #3378 that will push and pop "eval frames" that include the internal state but also the registered functions/namespaces/lookup handlers.

Revert the pieces of 969bea9 related to re-use of xpath context
objects.

Leave in these pieces of that commit:

- ability to de-register variables and namespaces
- XPathContext#node=

and backfill explicit test coverage for these features, as well as
recursive xpath evaluations.
Copying the struct and the hash tables is slightly faster than calling
xmlXpathNewContext:

  Comparison:
      large: optimized:    17780.0 i/s
           large: main:    15143.4 i/s - same-ish: difference falls within error

  Comparison:
      small: optimized:    62891.9 i/s
           small: main:    49413.5 i/s - 1.27x  slower

But still slower than re-using the context object ("edge", v1.18.0.rc1):

  Comparison:
           large: edge:    22230.9 i/s
      large: optimized:    17780.0 i/s - 1.25x  slower
           large: main:    15143.4 i/s - 1.47x  slower

  Comparison:
           small: edge:   129162.0 i/s
      small: optimized:    62891.9 i/s - 2.05x  slower
           small: main:    49413.5 i/s - 2.61x  slower
@flavorjones flavorjones deleted the flavorjones-faster-xpath-context branch December 21, 2024 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant