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

Cache Fork Digest Computation #11931

Merged
merged 1 commit into from
Jan 29, 2023
Merged

Cache Fork Digest Computation #11931

merged 1 commit into from
Jan 29, 2023

Conversation

nisdas
Copy link
Member

@nisdas nisdas commented Jan 29, 2023

What type of PR is this?

Optimization

What does this PR do? Why is it needed?

Computing the fork digest is a very hot path in gossip, we have to compute the digest for each message we
receive in gossip. This PR caches the computation, so that we can easily received the result through a map. Also
a relevant unit test is added here.

Which issues(s) does this PR fix?

N.A

Other notes for review

@nisdas nisdas requested a review from a team as a code owner January 29, 2023 11:37
Copy link
Member

@terencechain terencechain left a comment

Choose a reason for hiding this comment

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

This looks good to me. There are two feedbacks to consider that I don't feel strongly about. Anyone feel free to block this if you think they are necessary:

  1. Refactor string(version)+string(root) into its own helper function
  2. Add a lock around computeForkDataRoot to avoid race

Keep in mind that there's no pruning for the map after a while and that's probably ok given this is a rare event

@prylabs-bulldozer prylabs-bulldozer bot merged commit e8c25ef into develop Jan 29, 2023
@delete-merged-branch delete-merged-branch bot deleted the cachedDigest branch January 29, 2023 16:07
@terencechain
Copy link
Member

Ops. I didn't see ok-to-merge label was applied

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