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

log/sdk: Add benchmarks #5054

Closed
pellared opened this issue Mar 13, 2024 · 3 comments
Closed

log/sdk: Add benchmarks #5054

pellared opened this issue Mar 13, 2024 · 3 comments
Assignees
Labels
area:logs Part of OpenTelemetry logs pkg:SDK Related to an SDK package
Milestone

Comments

@pellared
Copy link
Member

No description provided.

@pellared pellared added pkg:SDK Related to an SDK package area:logs Part of OpenTelemetry logs labels Mar 13, 2024
@dmathieu dmathieu self-assigned this May 30, 2024
pellared added a commit that referenced this issue Jun 3, 2024
Towards #5219

Towards #5054

This benchmarks are supposed
- Validate the the `Processor` interface design from performance
perspective. E.g. they are used to check if a processor that is
modifying a log record is causing an additional heap allocations.
- Benchmark the processors supported by the SDK.

These are "almost-end-to-end" benchmarks (with noopExporter) so that it
checks the performance of the SDK log processing without the actual
exporting part.

```
cpu: Intel(R) Core(TM) i9-10885H CPU @ 2.40GHz
BenchmarkProcessor/Simple-16         	 1990946	       644.6 ns/op	     417 B/op	       1 allocs/op
BenchmarkProcessor/Batch-16          	  835135	      1211 ns/op	     597 B/op	       0 allocs/op
BenchmarkProcessor/ModifyTimestampSimple-16         	 1782510	       644.3 ns/op	     417 B/op	       1 allocs/op
BenchmarkProcessor/ModifyTimestampBatch-16          	  945699	      1222 ns/op	     637 B/op	       0 allocs/op
BenchmarkProcessor/ModifyAttributesSimple-16        	 1570214	       717.6 ns/op	     465 B/op	       2 allocs/op
BenchmarkProcessor/ModifyAttributesBatch-16         	  768399	      1383 ns/op	     653 B/op	       1 allocs/op
```
pellared pushed a commit that referenced this issue Jun 27, 2024
This benchmark currently tests two rather different methods within the
same loop, which makes it hard to see what could be causing a
performance degradation.

Related: #5054.

```
BenchmarkSetAddAttributes/SetAttributes-10              14066331                82.80 ns/op           48 B/op          1 allocs/op
BenchmarkSetAddAttributes/AddAttributes-10              19333711               114.7 ns/op             0 B/op          0 allocs/op
```
pellared pushed a commit that referenced this issue Jun 27, 2024
This adds a benchmark for `record.WalkAttributes`.

Part of #5054.

```
BenchmarkWalkAttributes/1_attributes-10                 346989372                3.449 ns/op           0 B/op          0 allocs/op
BenchmarkWalkAttributes/10_attributes-10                345712522                3.459 ns/op           0 B/op          0 allocs/op
BenchmarkWalkAttributes/100_attributes-10               349380534                3.455 ns/op           0 B/op          0 allocs/op
BenchmarkWalkAttributes/1000_attributes-10              342041373                3.484 ns/op           0 B/op          0 allocs/op
```
pellared pushed a commit that referenced this issue Jun 27, 2024
This adds a benchmark to create a logger from a logger provider.

Related: #5054.

```
BenchmarkLoggerProviderLogger-10                         3145390               548.8 ns/op           330 B/op          1 allocs/op
```
@MrAlias
Copy link
Contributor

MrAlias commented Jun 27, 2024

From SIG meeting: this looks almost complete. @dmathieu plans to another audit and review all coverage.

@dmathieu
Copy link
Member

dmathieu commented Jul 2, 2024

From the public SDK methods, we are now benchmarking:

  • Record.WalkAttributes()
  • Record.SetAttributes
  • Record.AddAttributes
  • LoggerProvider.Logger
  • logger.newRecord
  • SimpleProcessor.OnEmit
  • BatchProcessor.OnEmit
  • Create a record, with body, severity, attributes, and run SimpleProcessor.OnEmit
  • Create a record, with body, severity, attributes, and run BatchProcessor.OnEmit
  • Create a record, with body, severity, attributes, modify the observed timestamp and run SimpleProcessor.OnEmit
  • Create a record, with body, severity, attributes, modify the observed timestamp and run BatchProcessor.OnEmit

At this stage, all hot public APIs appear to be benchmarked in the log SDK. I believe this issue can be closed.

@pellared
Copy link
Member Author

pellared commented Jul 2, 2024

We can always add more benchmarks later. Great job.

@pellared pellared closed this as completed Jul 2, 2024
@XSAM XSAM added this to the untracked milestone Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:logs Part of OpenTelemetry logs pkg:SDK Related to an SDK package
Projects
Status: Done
Development

No branches or pull requests

4 participants