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 thelinkmltests--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
Fix: https://github.com/linkml/prefixmaps/issues/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()
, ornamespaces()
methods directly) but internally within theadd_prefix
method we avoid set comprehensions that become very expensive as thenamespaces
orprefixes
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