sunspot/sunspot — pull request #322 by urbanautomaton (2012-12-03 14:07:16+00:00)
Title: Register looked-up adapters/accessors for later access

Hi,

Investigating a performance issue in our app today, I noticed that Sunspot's DataAccessor and InstanceAdapter classes are looked up for derived types by inspecting the type's ancestors and lookup up registered adapters for classes up the chain. When loading a large number of facet row's associated instances, this causes the `InstanceAdapter.for` lookup to be invoked many times with the same derived type.

All this patch does is register the looked-up adapter/accessor for the derived type (if one is found), allowing it to be accessed directly the next time. In our app this lowered the time to fetch 100 facet rows' instances from ~200ms to ~60ms.

This isn't a behavioural change; is it therefore sufficient that the existing tests pass (which they do)? If not then I'm happy to add tests as requested.

Cheers,
Simon