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

Cut call time of add_prefix() by 99.8% #69

Merged
merged 4 commits into from
Mar 13, 2024

Conversation

sneakers-the-rat
Copy link
Contributor

Fix: #68

Previously on perf hunting: we had stumbled across a method in the wild that seemed harmless enough, but upon getting closer it turned to attack and we saw that it was in fact O(2n^2) in disguise!!

On this episode: we propose a function-neutral change that looks the same to an external observer (eg. someone that calls and of the public methods combine(), prefixes(), or namespaces() methods directly) but internally within the add_prefix method we avoid set comprehensions that become very expensive as the namespaces or prefixes sets become large.

For Run on the linkmltests--with-slow` enabled, no tests fail and...
Current version: 156s (cumulative), 0.00580s per call
This PR: 0.2s (cumulative), 7.75e-06s per call
Change: -155.2s, 99.8% decrease

@cmungall cmungall merged commit da9a2e6 into linkml:main Mar 13, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Context.combine is O(2n^2)
2 participants