Repository navigation
🐛 fix(xpath): keep many-argument calls linear - #2156
Merged
Merged
Conversation
A function call that runs a regex or extension function pins the nodes every live frame holds before each comparison, so that the callbacks cannot free them. The call bumped its frame version after each stored argument, so the next pin took the frame for a new one and walked every argument again. A call with many arguments and many nodes in the first one then cost the product of the two counts. Pin only the results added since the last visit, and drop the version counter that only the argument loop read. Each argument is visited once, so the cost grows with the argument count plus the node count. Fixes tox-dev#1778
Merging this PR will not alter performance
Comparing Footnotes
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An XPath expression that uses regex or Python extension functions took time that grew with the product of a call's argument count and the nodes in its arguments. 📈 Each stored argument made the next pin visit every node of the earlier arguments again. Expressions without such functions never pin and were not affected. After this change the cost grows with the argument count plus the node count, and results do not change.
Architecture
Before each Python call, the evaluator pins the nodes of live frames, so that a callback cannot free the nodes it holds. The frame's pin record now keeps how many results it has already pinned, and each pin visits only the results added since. The version counter that forced full revisits had no other reader, so it is gone.
Behavior changes
Fixes #1778.