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.
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
[EBPF-595] Create a common process consumer for eventmonitor #30559
[EBPF-595] Create a common process consumer for eventmonitor #30559
Changes from 1 commit
52219d7
1165d41
a1d8614
bf5dc6a
8b07947
26768ee
e6ef65f
35be299
99baa4e
d632825
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
what is the common pattern to use this struct?
in some cases rwmutex perform worse than the regular mutex
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 took the same pattern as there is in process-monitor, I assumed it was tested to be the best option.
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.
cc @guyarb @vitkyrka
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.
common use case - adding all callbacks (write lock), and then calling them (read lock)
normally, all callbacks are being added (or removed) before (or after) the operation.
We can use regular mutex here, but, if we do intend to make the change - it should be tested to show it improves the usage of rwmutex
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.
me and @brycekahle discussed rwmutex in some other context. and in some cases the rwmutex actually creates slight overhead (even when just using the readerlock without writer lock).
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 don't think we can do that, we're always going to (potentially) have two goroutines accessing the callback map concurrently, one from the event stream and another one from the subscription.
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.
do we have any subscriptions happening in "execution" phase or rather we can limit the subscription during the "init" phase before the handler go-routine starts?
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.
also these benchmarks for reference
(maybe
sync.Map
is a better choice)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.
It might not always be possible to limit the subscriptions, specially considering that the current way of adding event stream consumers requires having a global variable to share the consumer, and that could probably change later. Also, it'd require changing the
SubscribeX
signatures to be able to return an error.I think it's a good idea to research this a bit more, but I think we should have a better view of dependencies in system-probe modules first to see how that fits with those phases.
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 agree that we can leave it out of scope for this PR. Resolving the comment