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

Wrap cached state in async mutex to avoid duplicate state calculation #785

Merged
merged 8 commits into from
Oct 26, 2020

Conversation

austinabell
Copy link
Contributor

@austinabell austinabell commented Oct 25, 2020

Summary of changes
Changes introduced in this pull request:

  • So I documented the behaviour, but tldr tasks will wait for ones already computing state to finish instead of doing duplicate work in parallel, without blocking separate tipset's state transitions
  • Changed callback function to references, to avoid unnecessary clones

You can test the functionality by uncommenting the full sync test and setting the RUST_LOG env variable to see logs, no duplicate tipset state calculation should happen

Reference issue to close (if applicable)

Closes #776

Other information and links

// mutex until the value is updated, which task `B` will await.
//
// If two tasks are computing different tipset states, they will only block computation
// when accessing/ initializing the entry in cache, not during the whole tipset calc.
Copy link
Member

Choose a reason for hiding this comment

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

remove space after "/"


/// This is a cache which indexes tipsets to their calculated state.
/// The calculated state is wrapped in a mutex to avoid duplicate computation
/// of the state/ receipt root.
Copy link
Member

Choose a reason for hiding this comment

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

remove space after "/"

@austinabell austinabell merged commit 36e38c6 into main Oct 26, 2020
@austinabell austinabell deleted the austin/dedupstcalc branch October 26, 2020 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Avoid duplicate state computations by awaiting a seperate task's computation
3 participants