Add precompile result caching / memoization - #4366
Draft
bhartnett wants to merge 17 commits into
Draft
Conversation
bhartnett
marked this pull request as ready for review
June 30, 2026 17:20
bhartnett
marked this pull request as draft
July 1, 2026 01:36
Contributor
Author
|
Leaving this in draft for now, since it requires more time to collect the realistic hit rates of each of the precompiles over larger block ranges. I've removed sha256, ecAdd and blake2bf from the caching since these are not slow enough to bother caching. For the precompiles that can have a variable length input, it might be worth pre-hashing these inputs and only storing a Hash32 as the cache key but it remains to be seen if this is worth the computational overhead in order to save space in the caches. It might turn out that the precompile caching is only beneficial when re-executing blocks/transaction a second time, such as with optimistic state prefetching or when running eth_call via RPC. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Performance testing results
Running bench_precompiles.nim:
Imported 10K blocks starting at block 24 million with optimistic state prefetching disabled:
master - elapsed=17m3s84ms
precompiles - elapsed=16m59s570ms
Imported 10K blocks starting at block 24 million with optimistic state prefetching enabled:
master - elapsed=16m9s598ms
precompiles - elapsed=14m9s902ms