-
Notifications
You must be signed in to change notification settings - Fork 95
XPath nodeset always in document-order #320
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
Merged
+58
−31
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tompng
Thank you for this PR.
But, performance has decreased because the optimization for
nodesets.size == 1has been removed.Is there any way to improve this?
$ git checkout master $ rake build rexml 3.4.5 built to pkg/rexml-3.4.5.gem. $ gem install pkg/rexml-3.4.5.gem $ git checkout no_reverse_order $ benchmark-driver benchmark/xpath_no_reverse_order.yaml Calculating ------------------------------------- master(a98066c) after master(a98066c,YJIT) after(YJIT) child 280.227 19.016 544.496 31.084 i/s - 100.000 times in 0.356853s 5.258603s 0.183656s 3.217105s descendant 18.445 9.682 28.523 15.258 i/s - 100.000 times in 5.421532s 10.327928s 3.505883s 6.554030s Comparison: child master(a98066c,YJIT): 544.5 i/s master(a98066c): 280.2 i/s - 1.94x slower after(YJIT): 31.1 i/s - 17.52x slower after: 19.0 i/s - 28.63x slower descendant master(a98066c,YJIT): 28.5 i/s master(a98066c): 18.4 i/s - 1.55x slower after(YJIT): 15.3 i/s - 1.87x slower after: 9.7 i/s - 2.95x slowerThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, there are several ways.
A. Improve performance of sort
B. Mark nodesets ordering
ordered_nodeset = marked_as_ordered? ? nodesets.first : nodesets.first.reverse:ordered | :reversedbut in Optimize XPath step #315 we need to add:unorderedC. Delay nodeset ordering on demand
number(xpath)I implemented B with changing the meaning of
order:keyword parameter:forward | :reverse:ordered | :reversed | :unordered(future)Perhaps this approach will be a blocker implementing C(delayed nodeset ordering), and optimizing
XPathParser#step(#315) but we can consider it later.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tompng
Thank you.
I also think B is the best option, but can we keep
:forward | :reversein this PR?I don't want to include
:ordered | :reversed | :unordered(future)in this PR, because I can't review them at this time, as they are scheduled to be changed later.I would like to include changes to
:ordered | :reversed | :unordered(future)in the pull request when they are actually implemented.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated. Copilot suggested to rename the keyword parameter to
:axis_order, what do you think?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your update.
Also,
:axis_orderis easier to understand.Please change it to
:axis_order.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!