-
Notifications
You must be signed in to change notification settings - Fork 8
Remap thread id to avoid bitmap contention #223
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
Conversation
🔧 Report generated by pr-comment-scanbuild |
Would the contention not remain if you only swap lower bits ? |
I think the proposal here is still performing better:
Versus this one:
As a first step can we deliver the bench in a separate PR to get it running in CI ? This way, we could get more stable results. My laptop has a lot of noise. |
Also a different bench would be interesting. |
As discussed, I updated PR to reverse lower 32 bits that will further more distant 2 consecutive number to ensure they are not mapped to the same cache line. |
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.
How do the benchmarks look with the latest changes?
Otherwise, LGTM!
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.
This is faster than main, so LGTM
I would still need to check the #224 PR to understand the impact of JNI
Is this superseded by #229 ? |
What does this PR do?:
An application starts a few threads in short period of window, the newly created threads are likely to have consecutive or close thread ids. When
ThreadFilter
maps them to the bits on bitmap, there are high chances that they may be mapped to a single cache line, that results cache line contention when updating the bitmap concurrently.The PR purposes to remap thread id by reversing lower 2 bytes of thread id, so that consecutive/close thread ids map to different cache lines.
The reason for only reversing lower 2 bytes, is that, thread id is remapped within the same bitmap.
Motivation:
Reduce cache line contention, improve performance.
Additional Notes:
How to test the change?:
For Datadog employees:
credentials of any kind, I've requested a review from
@DataDog/security-design-and-guidance
.Unsure? Have a question? Request a review!