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

feat(l1): compute block hash once #1021

Merged
merged 3 commits into from
Oct 30, 2024
Merged

feat(l1): compute block hash once #1021

merged 3 commits into from
Oct 30, 2024

Conversation

Arkenan
Copy link
Contributor

@Arkenan Arkenan commented Oct 30, 2024

Description

Use OnceCell to cache hash computations for a single block in a thread safe way. It also doesn't require the block to be mutable in order to update the cache, which is ideal.

On a mac M1:

  • The first hash computation (for a default block) takes about 150-450 μs. Storing it in the OnceCell is about 10μs.
  • The subsequent hash() calls that get from the cache take ~40ns (10k times better).

Follow-up from #962
closes #1014

@Arkenan Arkenan requested a review from a team as a code owner October 30, 2024 15:55
@Arkenan Arkenan changed the title feat: compute block hash once feat(L1): compute block hash once Oct 30, 2024
@Arkenan Arkenan changed the title feat(L1): compute block hash once feat(l1): compute block hash once Oct 30, 2024
@Arkenan Arkenan added this pull request to the merge queue Oct 30, 2024
Merged via the queue into main with commit 3e0a4cf Oct 30, 2024
11 checks passed
@Arkenan Arkenan deleted the block-hash-cache branch October 30, 2024 16:30
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.

Have a block.compute_hash() function that is cached.
2 participants