Skip to content
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 log sdk #4891

Merged
merged 1 commit into from Nov 2, 2022
Merged

Conversation

jack-berg
Copy link
Member

@jack-berg jack-berg commented Oct 26, 2022

The typical usage for logs presents the opportunity for hotspots that don't exist in traces or metrics.

The main use case we want to support is writing log appenders, which bridge other log APIs / frameworks into opentelemetry. Its very typical for these frameworks to have the notion of named loggers, which maps nicely to OpenTelemetry instrumentation scope name. However, this requires that appender implementations obtain a Logger instance for each log record processed. Here's an example. Its not typical to obtain a new tracer or meter for each span / measurement, so optimizing this area has not been a priority.

This code path is currently suboptimal, particularly in terms of allocations, since it requires creating a new SdkLoggerBuilder, which creates a new InstrumentationScopeInfoBuilder and a new InstrumentationScopeInfo.

There are a couple of obvious ways to optimize this. This PR establishes a benchmark representative of the typical appender use case to evaluate potential performance improvements.

Baseline performance on my machine:

Benchmark                                                  Mode  Cnt     Score     Error   Units
LogsBenchmarks.emitSimpleLog                               avgt   10    35.035 ±   0.732   ns/op
LogsBenchmarks.emitSimpleLog:·gc.alloc.rate                avgt   10  2173.006 ±  43.649  MB/sec
LogsBenchmarks.emitSimpleLog:·gc.alloc.rate.norm           avgt   10   120.000 ±   0.001    B/op
LogsBenchmarks.emitSimpleLog:·gc.churn.G1_Eden_Space       avgt   10  2191.457 ± 429.679  MB/sec
LogsBenchmarks.emitSimpleLog:·gc.churn.G1_Eden_Space.norm  avgt   10   120.983 ±  23.200    B/op
LogsBenchmarks.emitSimpleLog:·gc.count                     avgt   10    37.000            counts
LogsBenchmarks.emitSimpleLog:·gc.time                      avgt   10    30.000                ms

@jack-berg jack-berg requested a review from a team as a code owner October 26, 2022 20:16
@codecov
Copy link

codecov bot commented Oct 26, 2022

Codecov Report

Base: 90.83% // Head: 90.83% // No change to project coverage 👍

Coverage data is based on head (f4d0f70) compared to base (21d5597).
Patch has no changes to coverable lines.

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #4891   +/-   ##
=========================================
  Coverage     90.83%   90.83%           
  Complexity     4857     4857           
=========================================
  Files           556      556           
  Lines         14475    14475           
  Branches       1410     1410           
=========================================
  Hits          13149    13149           
  Misses          908      908           
  Partials        418      418           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@jkwatson
Copy link
Contributor

Can you paste the current benchmark results into the PR description, so we have a historical record? Thanks!

@jack-berg
Copy link
Member Author

Done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants