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

Fix performance of extractKeys for very small sets. #2804

Merged
merged 3 commits into from
May 20, 2022

Conversation

lehins
Copy link
Collaborator

@lehins lehins commented May 20, 2022

It turned out that #2801 introduced a slight regression instead of an expected improvement in performance, which was discovered with profiling a db-analyser run.

After looking at profiling report it was immediately obvious to me why the regression actually happened: extractKeys is called a lot, but it is always called with a large Map (UTxO) and a very small Set (number of TxIns). Implementation added in #2801 was benchmarked for Sets of size 100 and 100000, which performed quite well. However, majority of times extractKeys is called with the Set that has number of elements in single digits. Comparing performance of old and new implementations, confirmed my suspicion: we already had very fast implementation before #2801

That being said, there is no reason to discard a function that performs well, therefore this PR adopts both implementations for the extractKeys functions, making it fast for both large and small inputs alike. This can prove useful in the future if we start getting many transactions with large number of outputs.

* Implement specialized implementation for smaller sets

* Add benchmark for the most common case of small number TxIn
Copy link
Contributor

@JaredCorduan JaredCorduan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for checking with db-analyser! LGTM

@lehins lehins force-pushed the lehins/extract-map-follow-up-fix branch from b24f88e to 2637d95 Compare May 20, 2022 10:45
@lehins lehins merged commit c415253 into master May 20, 2022
@iohk-bors iohk-bors bot deleted the lehins/extract-map-follow-up-fix branch May 20, 2022 13:11
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.

2 participants