Skip to content
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

adapter lookup can be slowish #8

Closed
tseaver opened this issue Jan 26, 2015 · 7 comments
Closed

adapter lookup can be slowish #8

tseaver opened this issue Jan 26, 2015 · 7 comments
Labels

Comments

@tseaver
Copy link
Member

tseaver commented Jan 26, 2015

In https://bugs.launchpad.net/zope.component/+bug/567746, @agroszer reported:

I had a feeling that adapter lookup can be alone slowish with lots of registrations.
Lots of registrations means

 >>> len(getGlobalSiteManager()._utility_registrations)
 980
 >>> len(getGlobalSiteManager()._adapter_registrations)
 1432
 >>> len(getGlobalSiteManager()._handler_registrations)
 63
 >>> len(getGlobalSiteManager()._subscription_registrations)
 50

That combined with some 100 z3c.form widgets on a single page seems to take quite a while.

See: https://mail.zope.org/pipermail/zope-dev/2009-November/038432.html

First TODO is profiling.

@tseaver tseaver added the bug label Jan 26, 2015
@icemac
Copy link
Member

icemac commented Sep 21, 2016

Maybe zopefoundation/zope.interface#48 fixes at least a bit of this problem.

@jamadden
Copy link
Member

zopefoundation/zope.interface#48 didn't touch adapters at all, or any kind of lookups. It just dealt with utility registration and unregistration.

@jamadden
Copy link
Member

Unfortunately, I haven't seen if there was any profiling for this particular case. But I wonder if it was having to load the AdapterRegistry from ZODB? For large adapter registries, that can be quite slow because every persistent object has to have a ghost created (or otherwise be found in the Connection cache); I have seen profiling for that. That's what leads to #51 (and our own BTree-based version of the adapter registry).

@agroszer
Copy link
Contributor

Ugh, this was ages ago.... if I'd just remember... I don't have the codebase handy anymore.

I think the global registry was not persistent. I think the problem was that z3c.form uses adaptation for "everything" to be flexible. Rendering a single widget/form uses a lot of adapters, and does a lot of adapter lookups.

@jamadden
Copy link
Member

Argh! Sorry, I completely missed the fact that it was the global registry.

There was a substantial performance increase in adapter lookups in zope.interface 5 thanks to various optimizations. This applies to all sorts of registries. Some particular Plone operations were seeing 50% improvements, other tests were 10% to 25%.

@agroszer
Copy link
Contributor

I'd be happy with that, also don't have the code around anymore, nor the time to chase this.

@jamadden
Copy link
Member

Thanks for the feedback!

I think we can close this given the recent changes in zope.interface, plus the fact that the vast majority of this lives in zope.interface nowadays anyway (if I'm wrong, feel free to reopen). I encourage those with performance issues to open issues over there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants