-
Notifications
You must be signed in to change notification settings - Fork 44
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
fipp.ednize/override?
uses satisfies?
#87
Comments
Can you quantify "very poor" performance? I'm hesitant to make breaking changes or in fact any changes at all unless the win is pretty substantial. As it is, Fipp is more than fast enough for every use case I've thrown at it so far. That's not to say it can't always be faster, just that I'm not yet convinced it's worth it. |
I see your point - I should perhaps qualify the code path by which I observed it, which was the request diff middleware from malli -> deep-diff2 -> fipp. For a rough estimate of the overhead of calling
I understand if you don't think a 2x improvement is worth making any change in this case. Another small change can be using eductions instead of |
OK, I think you've convinced me that it's worth perusing the wins, but I'm not super comfortable with the breaking change route. Ideally, we wouldn't have to change anything and Clojure would just be faster. See https://clojure.atlassian.net/browse/CLJ-1814 for a proposal to speed up
This seems like the least invasive solution, at least until CLJ-1814 is resolved. Maybe someone has already figured out how to implement a global cache that is discarded if underlying protocol mappings/extensions have changed? If not, could we figure that out? If not, I guess a local cache would get the job done.
PR welcome for that separately. Thanks! |
Ideally Clojure would be faster, although if we take a more philosophical approach, one never needs call |
Sketched out a version of cached satisfies, wdyt? (defn cache-satisfies
([prot]
(let [cache (volatile! {})]
(fn [x]
(cache-satisfies prot cache x))))
([prot cache x]
(let [clazz (class x)
ret (get @cache clazz ::not-found)]
(if (identical? ::not-found ret)
(let [ret (satisfies? prot x)]
(vswap! cache assoc clazz ret)
ret)
ret)))) It's about 100x faster than |
satisfies?
has very poor performance, and the wayvisit*
works, it callsoverride?
for each object it visits, incurring a pretty big overhead.An easy alternative to using
satisfies?
is:The problem with such change is it breaks current users, of which there are several
https://github.com/search?q=IOverride+fipp.ednize&type=code
This leaves four:
satisfies?
. This has the downsides of being influenced by load order. Possible mitigation is attaching the cache to the visitor instead of making it global.IEdn
(with another arity?) or another protocolAny solution that finds a way to remove the call to
satisfies?
will make fipp way faster.Happy to help with whatever solution you think will be correct, wdyt?
The text was updated successfully, but these errors were encountered: