Welcome! Please see the About page for a little more info on how this works.

+2 votes
in Protocols by

In recent conversation I learned that some developers avoid and discourage the use of satisfies? because of performance concerns. I was told to "just look at the implementation, you will sweat bullets".

The implementation in this case is in find-protocol-impl which has to check metadata, traverse the inheritance chain as well as implemented interfaces.

The part of finding a protocol implementation for a specific class seems emminently cacheable, except for the fact that one can extend the protocol later on.

Would it make sense to cache this, and have extend-* invalidate the cache? Or alternatively to have a flag (e.g. -J-Dclojure.cache-protocols=true) for use in production where you know all protocol implementations will be loaded before lookups happen?

1 Answer

0 votes
by
selected by
 
Best answer

I think a proposal for a caching scheme would be welcomed. I'll log a ticket as a place to discuss further in a bit.


Looking a bit it seems that there are a couple of tickets that look to address satisfies?, the first being https://clojure.atlassian.net/browse/CLJ-1814 which seems to rely on a solution for https://clojure.atlassian.net/browse/CLJ-2426. Both seem to have quite a bit of discussion around them.

...