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

internal/ethapi: AddrLocker - add read fast path; less look-ups; no lazy init #50

Merged
merged 1 commit into from
Mar 9, 2018

Conversation

jmank88
Copy link
Contributor

@jmank88 jmank88 commented Mar 9, 2018

No description provided.

l.locks[address] = new(sync.Mutex)
func newAddrLocker() *AddrLocker {
return &AddrLocker{
locks: make(map[common.Address]*sync.Mutex),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No need to lazy init later while holding the lock.

l.mu.RUnlock()
if ok {
return mu
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Read lock fast path to main map.

defer s.nonceLock.UnlockAddr(args.From)
l := s.nonceLock.lock(args.From)
l.Lock()
defer l.Unlock()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't lock the main map again to get the same lock, just keep it.

@jmank88 jmank88 requested a review from treeder March 9, 2018 01:46
@jmank88 jmank88 merged commit 2ad5f66 into master Mar 9, 2018
@jmank88 jmank88 deleted the addr-locker branch March 9, 2018 02:10
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.

None yet

1 participant