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
By default JMESPath#search caches parsed expressions in order to improve performance. However, it also takes care to call #optimize on each expression. The optimized expressions are not cached, meaning that for every #search the optimization takes place.
According to my (limited) tests, caching the optimized expressions increases the performance by 10-30 times.
I see two ways to solve this;
Cache the optimized expressions within Runtime, instead of caching the non-optimized expressions in the CachingParser, or
Make #optimize memoize its result, so that sub-sequent calls can return the value directly without the overhead
I'll happily help with the coding, but wanted to get some feedback first.
The text was updated successfully, but these errors were encountered:
Sorry, I misunderstood things a bit. Since JMESPath.search creates a new Runtime for every call, it also creates a new CachingParser for each call. This should mean that expressions are not actually cached, and consequently my estimated performance increase would not be as significant as I stated just from caching the optimized expressions.
I suggest removing the CachingParser completely and instead introduce a CachingRuntime that provides the expression caching and a constant DEFAULT_RUNTIME that is used by JMESPath.search.
It seems like the caching optimization got lost in two steps: first I introduced the optimization step and missed that the result of the optimization wasn't cached, and then 5703438 changed things so that the caching parser is created for each new runtime.
By default
JMESPath#search
caches parsed expressions in order to improve performance. However, it also takes care to call#optimize
on each expression. The optimized expressions are not cached, meaning that for every#search
the optimization takes place.According to my (limited) tests, caching the optimized expressions increases the performance by 10-30 times.
I see two ways to solve this;
Runtime
, instead of caching the non-optimized expressions in theCachingParser
, or#optimize
memoize its result, so that sub-sequent calls can return the value directly without the overheadI'll happily help with the coding, but wanted to get some feedback first.
The text was updated successfully, but these errors were encountered: