-
Notifications
You must be signed in to change notification settings - Fork 770
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
Add benchmark for DiagnosticSourceSubscriber #1391
Add benchmark for DiagnosticSourceSubscriber #1391
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1391 +/- ##
==========================================
- Coverage 81.34% 81.33% -0.02%
==========================================
Files 226 226
Lines 6090 6090
==========================================
- Hits 4954 4953 -1
- Misses 1136 1137 +1
|
If u try with 5 or 10, the time will increase proportionally? |
Good question. Yes, it does appear to grow proportionally:
|
Thanks for adding that. We can see that we shouldn't add multiple since it will increase in a 60-70ns * subscriber! |
this.UseIsEnabledFilter ? this.isEnabledFilter : null); | ||
|
||
this.subscribers.Add(subscriber); | ||
DiagnosticListener.AllListeners.Subscribe(subscriber); |
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.
why not use our own wrappers to make this consistent? subscriber.Subscribe()
should do
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.
Good catch
I think its okay to have multiple subscribers rather than refactor the trace/metric to share common subscriber. The benefit is small perf gain, but we need to do complex refactoring to ensure disabling Trace has no impact on Metric and vice versa etc. Once .NET 6 ships with new Metric API, we can try to get the common .net libraries (asp.net core, httpclient) to emit metrics directly using it, which avoids the need of these instrumentations. Most .NET libraries are instrumented currently with |
Apologies for delay. Here are some benchmark results of DiagnosticSource per recent conversations in SIG meetings.
#1347 raised the question of the impact of multiple DiagnosticSource subscribers for a single source. Currently, #1347 sets up an additional DiagnosticSource subscriber to capture HTTP response time metrics for ASP.NET Core. Another approach would be to refactor things and capture these metrics with the existing subscriber used for traces.
There does appear to be an increase in computation time when invoking multiple subscribers. It was mentioned in a SIG meeting that using an event filter may also have a significant impact, however, these results do not seem to suggest that (perhaps if the filter were less trivial).
Questions