-
Notifications
You must be signed in to change notification settings - Fork 5.3k
lockless buffer reservation/release in EventPipe #50797
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
Merged
josalem
merged 4 commits into
dotnet:main
from
josalem:dev/josalem/eventpipe-throughput-improvement1
Apr 15, 2021
Merged
lockless buffer reservation/release in EventPipe #50797
josalem
merged 4 commits into
dotnet:main
from
josalem:dev/josalem/eventpipe-throughput-improvement1
Apr 15, 2021
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* prevents needless lock holding for dropping events which frees up the lock to make more progress on flushing and making new buffers allowing each thread to send more events when the buffer limit is reached.
noahfalk
reviewed
Apr 8, 2021
sywhang
approved these changes
Apr 13, 2021
Contributor
sywhang
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM modulo a couple of minor things!
josalem
commented
Apr 13, 2021
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
<insert associated issues here>
Description
Makes the reservation of a buffer lockless. Allocating the buffer still requires us to take the lock, but now we can fail buffer creation without taking the lock.
Prior to this change, when the buffer limit is reached and the event rate is still high, we would end up having all the writing threads waiting on the buffer manager lock to request a new buffer. The writing threads would wait on that lock, even if the buffer request was going to fail. This would cause a lock caravan slowing down event writing and reducing the number of events that actually get written to the wire.
With this change, the reservation is outside the lock, allowing the saturated scenario above to make more progress. This increases the throughput in high event count and high thread count scenarios.
Performance Changes
The following all show statistics for stress runs with the following characteristics:
Stream.CopyAsyncto copy the EventPipe stream directly to diskmacOS
2017 MacBook Pro 17" 2.8 GHz quad core i7 w/ 16GB RAM
Baseline (current main):
Patch:
Result: +63.9% events read, +47.9% total events attempted
Windows
4x12 core Intel Xeon E7 v2 2.7 GHz (48 physical cores, 96 logical cores) w/ 128 GB RAM
baseline:
Patch:
result: +20% events read, +32% total events attempted
4 core Intel i7-7700 3.6 GHz w/ 64 GB RAM
baseline:
patch:
result: +80% events read, +40% total events attempted
CC @noahfalk @sywhang @lateralusX