-
Notifications
You must be signed in to change notification settings - Fork 8
Thread filter optim #238
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
base: main
Are you sure you want to change the base?
Thread filter optim #238
Conversation
🔧 Report generated by pr-comment-scanbuild |
e5bce28
to
0918008
Compare
I have reasonable performance on most runs:
I'm not sure why some runs still blow up for higher numbers of threads. |
e0ac246
to
2421ba9
Compare
if (_thread_filter.enabled()) { | ||
_thread_filter.remove(tid); | ||
int slot_id = _thread_filter.registerThread(); | ||
current->setFilterSlotId(slot_id); |
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 code path should not happen, though I still need to think about whether it is safe if it happens (possible allocs)
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 not happening in the signal context - this is a standard JVMTI callback - so allocation is fine here.
Also, I didn't really get the comment this code path should not happen
- this is the path where we register newly created Java threads. This will happen quite often in a Java program.
} | ||
ThreadFilter::SlotID ThreadFilter::popFromFreeList() { | ||
// Lock-free sharded Treiber stack pop | ||
int hash = static_cast<int>(std::hash<std::thread::id>{}(std::this_thread::get_id())); |
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.
interesting!
What is missing to merge this:
|
- Reserve padded slots - Introduce a register / unregister to retrieve slots - manage a free list
2421ba9
to
50a8d5f
Compare
I did run some comparison of native memory usage with different thread filter implementations - data is in the notebook TL;DR there is no observable increase in the native memory usage (the |
What does this PR do?:
Motivation:
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!