-
Notifications
You must be signed in to change notification settings - Fork 176
docs: proposal for thread safe thread manager #2739
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: master
Are you sure you want to change the base?
docs: proposal for thread safe thread manager #2739
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: irozzo-1A The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Perf diff from master - unit testsHeap diff from master - unit testsHeap diff from master - scap fileBenchmarks diff from master |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2739 +/- ##
==========================================
- Coverage 77.02% 74.57% -2.45%
==========================================
Files 296 292 -4
Lines 30818 30025 -793
Branches 4670 4657 -13
==========================================
- Hits 23738 22392 -1346
- Misses 7080 7633 +553
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
I read the proposal, and overall looks good. I just added some minor comments.
The critical point I would like to discuss is the global std::mutex protecting any modification to the topological structure in sinsp_thread_manager. This has a big impact, as it serializes any clone/clone3/fork/procexit or, in other terms, any thread addition/replacement. What is worse is that this applies also to unrelated topological thread operations.
In theory, if we adopt some form of partitioning, we could have each thread belonging, for its entire lifetime, to the same partition, and so being managed by the same worker thread. However, there are topological structures, both inside sinsp_thread_manager and sinsp_threadinfo that links thread belonging to different partitions. For example, the addition of one thread requires the insertion of a new element in sinsp_thread_manager::table_, sinsp_thread_manager::list_head_, and sinsp_thread_info::m_children on the parent side. I'm wondering if we could constraint this kind of accesses in such a way that always the same writer is designated for changes on the same threads/topological sectors... Following the above example, if we partition by thread id or, even better, by thread group id, we would solve the problem for sinsp_thread_manager::table_, bot not for the other ones...
Whatever is the mechanism, if we found a way of doing so, we could get rid of the global lock and have big benefits both in term of performance and code simplicity.
6d27c93 to
352a971
Compare
Yes, as pointed out the synchronization cost of writes is the weakest part of this approach, and I would like it would be possible to find a partition strategy to avoid the global writer lock. This proposal has to considered as a starting point for experimentation, but we may need several iterations. |
352a971 to
d407b67
Compare
Signed-off-by: irozzo-1A <iacopo@sysdig.com>
d407b67 to
0d6c9b0
Compare
What type of PR is this?
/kind design
Any specific area of the project related to this PR?
/area libsinsp
/area proposals
Does this PR require a change in the driver versions?
What this PR does / why we need it:
ref: falcosecurity/falco#3749
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?: