-
Notifications
You must be signed in to change notification settings - Fork 62
-
Notifications
You must be signed in to change notification settings - Fork 62
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
each_recursive
is extremely slow
#134
Comments
Let's improve performance of it:
BTW, are you interesting in merging the CSS selector feature to REXML itself? |
@kou Thank you. I will try to improve its performance. I am also interested in merging the CSS selector feature to REXML.
I will create a separate issue on this matter. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
REXML::Node#each_recursive
is a fundamental operation to traverse XML nodes. In particular, CSS selector uses this method heavily.Unfortunately, this method is extremely slow. The following Gist contains a tiny (but mostly equivalent)
each_recursive
implementation and their benchmarks.https://gist.github.com/makenowjust/b4852a59e53f0c85c740818c75303d5e
And, the below is a result of this script on my laptop (Apple M1 Pro, 14 inch, 32 GB) and Ruby 3.3.2.
Yes, REXML's
each_recursive
is ~50x (or ~80x with YJIT) slower than my tiny implementation.I believe REXML does a lot of extra work, and we can make it faster.
The text was updated successfully, but these errors were encountered: