Make `satisfies?` as fast as a protocol method call

Description

Currently `satisfies?` doesn't use the same impl cache used by protocol methods, making it too slow for real world usage.

With:

Before patch:

Cause: `satisfies?` calls `find-protocol-impl` to see whether an object implements a protocol, which checks for whether x is an instance of the protocol interface or whether x's class is one of the protocol implementations (or if its in an inheritance chain that would make this true). This check is fairly expensive and not cached.

Proposed: Extend the protocol's method impl cache to also handle (and cache) instance checks (including negative results).

After patch:

Patch: CLJ-1814-v7.patch (depends on )

Environment

None

Activity

Show:
Michael Blume
August 21, 2017, 6:52 PM

Patch with test

Michael Blume
August 21, 2017, 6:56 PM

Verified that test fails with v4 patch:

Michael Blume
September 18, 2017, 8:19 PM

Has this patch missed the 1.9 train? There was a fix we were hoping to make in HoneySQL that I'd hesitate to make with satisfies? as slow as it is.

Alex Miller
September 18, 2017, 8:48 PM

Not necessarily. We don't add features after 1.9 but perf stuff like this is still possible. It's been vetted by Rich. It's in my list of stuff to screen.

Nicola Mometto
November 20, 2018, 1:16 PM

Updated patch to work after the new instance-based protocol dispatch, this ticket should wait for first

Assignee

Unassigned

Reporter

Nicola Mometto

Approval

Vetted

Patch

Code and Test

Priority

Major