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

[utils] Implement PriorityMutex #244

Merged
merged 6 commits into from
Nov 23, 2020
Merged

Conversation

patrick-ogrady
Copy link
Contributor

@patrick-ogrady patrick-ogrady commented Nov 23, 2020

Related: https://github.com/coinbase/rosetta-sdk-go/tree/patrick/priority-lock

In an effort to optimize rosetta-cli performance, we discovered that a priority lock could be used to prioritize the "hot path" (i.e. the syncing loop). This PR adds a basic implementation of such a lock called PriorityMutex.

Changes

  • Add implementation
  • Add tests

@coveralls
Copy link

coveralls commented Nov 23, 2020

Pull Request Test Coverage Report for Build 11943

  • 33 of 33 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.07%) to 78.919%

Totals Coverage Status
Change from base Build 11298: 0.07%
Covered Lines: 7682
Relevant Lines: 9734

💛 - Coveralls

@patrick-ogrady patrick-ogrady changed the title [utils] PriorityMutex [utils] Implement PriorityMutex Nov 23, 2020
utils/priority_mutex.go Outdated Show resolved Hide resolved
func TestPriorityMutex(t *testing.T) {
arr := []bool{}
expected := make([]bool, 60)
l := new(PriorityMutex)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good callout, @bobg !

@patrick-ogrady patrick-ogrady merged commit ee99f0f into master Nov 23, 2020
@patrick-ogrady patrick-ogrady deleted the patrick/just-priority-lock branch November 23, 2020 18:33
Comment on lines +34 to +35
m sync.Mutex
l bool
Copy link
Contributor

Choose a reason for hiding this comment

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

small nit: use more descriptive variable names. l is not intuitive to somebody not implementing this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants