You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For background, see #2135 and #2137. The native Java implementation of nokogiri-builtin:css-class(@class,'foo') is slower than the corresponding XPath expression contains(concat(' ',normalize-space(@class),' '),' foo ') and I don't know why. (The identical C implementation is ~2x faster than libxml2's XPath evaluator.)
It's not even the implementation in NokogiriXpathFunction.java:builtinCssClass() because I can short-circuit that method to return false and it's still considerably slower than the XPath expression.
I guess it's possible that Xerces has super-duper optimized these functions, or that some kind of really amazing caching is happening under the hood, but that wouldn't explain why simply calling through the function resolver to a native Java function would be so much slower.
I'm not experienced enough with Java to do the profiling necessary to understand what's happening here. I'd love someone's help.
Help us reproduce what you're seeing
Here's a benchmark script that attempts to bust any caches:
I guess I expected this to be the same or faster than the XPath implementation.
Environment
In order to access the nokogiri-builtin xpath functions, you'll need to be on the branch from #2137 until it's merged onto master; and after that point you'll need to be on master.
The text was updated successfully, but these errors were encountered:
Please describe the bug
For background, see #2135 and #2137. The native Java implementation of
nokogiri-builtin:css-class(@class,'foo')
is slower than the corresponding XPath expressioncontains(concat(' ',normalize-space(@class),' '),' foo ')
and I don't know why. (The identical C implementation is ~2x faster than libxml2's XPath evaluator.)It's not even the implementation in
NokogiriXpathFunction.java:builtinCssClass()
because I can short-circuit that method toreturn false
and it's still considerably slower than the XPath expression.I guess it's possible that Xerces has super-duper optimized these functions, or that some kind of really amazing caching is happening under the hood, but that wouldn't explain why simply calling through the function resolver to a native Java function would be so much slower.
I'm not experienced enough with Java to do the profiling necessary to understand what's happening here. I'd love someone's help.
Help us reproduce what you're seeing
Here's a benchmark script that attempts to bust any caches:
and here is the result:
Expected behavior
I guess I expected this to be the same or faster than the XPath implementation.
Environment
In order to access the
nokogiri-builtin
xpath functions, you'll need to be on the branch from #2137 until it's merged onto master; and after that point you'll need to be on master.The text was updated successfully, but these errors were encountered: