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
The benchmark submitted by a user in #760 indicates a 4x(!) speedup on simple expressions by avoiding re-initializing an XPathContext object. It seems likely that the real-world speedup will be less (since cleaning up registered namespaces and variables will have some overhead), but it still seems like it would be a pretty decent speedup.
For (2), we'll need a new Ruby class to wrap the compiled expression represented by xmlXPathCompExprPtr, and a way to pass that into #xpath, but that seems like relatively straightforward work. (Note this API won't be available in JRuby.)
I'd like to get a rough benchmark ahead of time to see how much time this will save us, for simple and for complex expressions -- after a brief search I couldn't find any prior results here.
The text was updated successfully, but these errors were encountered:
Two things I want to explore doing to try to improve the performance of XPath (and, transitively, CSS) searches:
For (1), we need to be a bit careful:
XPathContext#register_namespaces
)XPathContext#register_variable
)nokogiri:
prefix used for dynamic function bindingnokogiri-builtin:
prefix used for our performance-optimized builtin functionsbut the performance improvement could be significant, see this response from the current libxml2 maintainer indicating "best practice" is to keep one XPathContext per thread and re-use it.
The benchmark submitted by a user in #760 indicates a 4x(!) speedup on simple expressions by avoiding re-initializing an XPathContext object. It seems likely that the real-world speedup will be less (since cleaning up registered namespaces and variables will have some overhead), but it still seems like it would be a pretty decent speedup.
For (2), we'll need a new Ruby class to wrap the compiled expression represented by
xmlXPathCompExprPtr
, and a way to pass that into#xpath
, but that seems like relatively straightforward work. (Note this API won't be available in JRuby.)I'd like to get a rough benchmark ahead of time to see how much time this will save us, for simple and for complex expressions -- after a brief search I couldn't find any prior results here.
The text was updated successfully, but these errors were encountered: