-
Notifications
You must be signed in to change notification settings - Fork 461
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
Refactor BatchLogProcessor #2494
base: main
Are you sure you want to change the base?
Refactor BatchLogProcessor #2494
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2494 +/- ##
=======================================
- Coverage 77.9% 77.8% -0.1%
=======================================
Files 123 123
Lines 22888 22950 +62
=======================================
+ Hits 17839 17876 +37
- Misses 5049 5074 +25 ☔ View full report in Codecov by Sentry. |
Excellent approach! Please make this ready for review once you feel it's ready :) |
// Check if the a control message for exporting logs is already sent to the worker thread. | ||
// If not, send a control message to export logs. | ||
// `export_log_message_sent` is set to false ONLY when the worker thread has processed the control message. | ||
if !self.export_log_message_sent.swap(true, Ordering::Relaxed) { |
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.
should we use compare_exchange
instead of swap
. This will avoid redundant writes if the export_log_message_sent
is already true?
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 used swap
because it's less verbose. Note that both swap
and compare_exchange
need exclusive access to the cache line. More importantly, a compare_exchange
operation would need exclusive access even to perform the comparison.
I pushed some new changes. I have added a new if check using atomic load to avoid aggressively calling swap
. We would now call swap
only if the atomic load value returned false
. Let me know what you think.
…om/utpilla/opentelemetry-rust into utpilla/Refactor-BatchLogProcessor
Towards #2478
Changes
BatchLogProcessor
to wake up the background thread ONLY when needed BatchProcessor shutdown issue #2478 (comment)Performance
There is a significant performance improvement mainly because of
mpsc:Receiver
not being excessively active (unlike how it is on main branch). It looks like there is a significant amount of synchronization overhead with senders and receivers actively working on the channel all the time. With this PR, the channel receivers are only woken up when needed so the logging threads incur a lesser synchronization overhead cost.I updated the
Logging_Comparable_To_Appender
benchmark and logs stress test to use aBatchProcessor
with a no-op exporter and ran the tests. Here are the results:Merge requirement checklist
CHANGELOG.md
files updated for non-trivial, user-facing changes