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

perf(mux) use RWMutex #218

Merged
merged 1 commit into from
Oct 28, 2014
Merged

perf(mux) use RWMutex #218

merged 1 commit into from
Oct 28, 2014

Conversation

btc
Copy link
Contributor

@btc btc commented Oct 28, 2014

@btc btc added the status/in-progress In progress label Oct 28, 2014
@jbenet
Copy link
Member

jbenet commented Oct 28, 2014

i dont think that was mine? maybe.

jbenet added a commit that referenced this pull request Oct 28, 2014
@jbenet jbenet merged commit 77b6361 into master Oct 28, 2014
@jbenet jbenet removed the status/in-progress In progress label Oct 28, 2014
@jbenet jbenet deleted the fix/2014-10-29-mux-rwmutex branch October 28, 2014 03:44
@whyrusleeping
Copy link
Member

Uhmm.... dont do that. RWMutexes Standard lock operation takes twice as long as a normal mutex. The only proper use case for it is frequent reads with infrequent writes, GetBandwidth will be called rather infrequently.

@whyrusleeping
Copy link
Member

confusing branch name too, lol. Today is still the 27th...

@btc
Copy link
Contributor Author

btc commented Oct 28, 2014

Uhmm.... dont do that. RWMutexes Standard lock operation takes twice as long as a normal mutex. The only proper use case for it is frequent reads with infrequent writes, GetBandwidth will be called rather infrequently.

Ah. I didn't know that.

confusing branch name too, lol. Today is still the 27th...

And (omg), I started naming branches 2014-10-28 last night.

@btc
Copy link
Contributor Author

btc commented Oct 28, 2014

reverted

#219

@jbenet
Copy link
Member

jbenet commented Oct 28, 2014

RWMutexes Standard lock operation takes twice as long as a normal mutex.

@whyrusleeping where did you get this stat from?

GetBandwidth will be called rather infrequently.

watch this not be true later on :] maybe add a note referencing this conversation.

@whyrusleeping
Copy link
Member

Take a look at the source:

RWMutex:
http://golang.org/src/pkg/sync/rwmutex.go?s=1966:1991#L62

Mutex:
http://golang.org/src/pkg/sync/mutex.go?s=1078:1100#L31

And also run some benchmarks.
The RWMutex does more work than the standard mutex, and also uses a standard mutex internally to protect the waitcounts which allows it to starve out readers.

@whyrusleeping
Copy link
Member

Also, unless we are checking the bandwidth way more often than we are receiving a packet, this will still hold true.

ariescodescream pushed a commit to ariescodescream/go-ipfs that referenced this pull request Oct 23, 2021
docs: duplicate pkg documentation
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.

3 participants