Skip to content

Commit cb4d407

Browse files
committed
fixes after rebase
1 parent e984d77 commit cb4d407

File tree

4 files changed

+5
-14
lines changed

4 files changed

+5
-14
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
1515
- Improve performance of concurrent histogram measurements in `go.opentelemetry.io/otel/sdk/metric`. (#7474)
1616
- Add experimental observability metrics in `go.opentelemetry.io/otel/exporters/stdout/stdoutmetric`. (#7492)
1717
- Improve the concurrent performance of `HistogramReservoir` in `go.opentelemetry.io/otel/sdk/metric/exemplar` by 4x. (#7443)
18-
- Improve the concurrent performance of `FixedSizeReservoir` in `go.opentelemetry.io/otel/sdk/metric/exemplar` by 3x. (#7447)
18+
- Improve the concurrent performance of `FixedSizeReservoir` in `go.opentelemetry.io/otel/sdk/metric/exemplar` by 4x. (#7447)
1919

2020
<!-- Released section -->
2121
<!-- Don't change this section unless doing release -->

sdk/metric/exemplar/benchmark_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ func BenchmarkFixedSizeReservoirOffer(b *testing.B) {
2222
// reservoirs records exemplars very infrequently after a large
2323
// number of collect calls.
2424
if i%100 == 99 {
25-
reservoir.mu.Lock()
2625
reservoir.reset()
27-
reservoir.mu.Unlock()
2826
}
2927
i++
3028
}

sdk/metric/exemplar/fixed_size_reservoir.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,11 @@ func (r *FixedSizeReservoir) Offer(ctx context.Context, t time.Time, n Value, a
104104
count, next := r.incrementCount()
105105
intCount := int(count) // nolint:gosec // count is at most 32 bits in length
106106
if intCount < r.k {
107-
r.store(intCount, newMeasurement(ctx, t, n, a))
107+
r.store(ctx, intCount, t, n, a)
108108
} else if count == next {
109109
// Overwrite a random existing measurement with the one offered.
110110
idx := rand.IntN(r.k)
111-
r.store(idx, newMeasurement(ctx, t, n, a))
111+
r.store(ctx, idx, t, n, a)
112112
r.wMu.Lock()
113113
defer r.wMu.Unlock()
114114
r.advance()

sdk/metric/exemplar/fixed_size_reservoir_test.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,8 @@ func TestNewFixedSizeReservoirSamplingCorrectness(t *testing.T) {
4545
}
4646

4747
var sum float64
48-
for _, val := range r.measurements {
49-
loaded := val.Load()
50-
if loaded == nil {
51-
continue
52-
}
53-
m := loaded.(*measurement)
54-
if m != nil {
55-
sum += m.Value.Float64()
56-
}
48+
for i := range r.measurements {
49+
sum += r.measurements[i].Value.Float64()
5750
}
5851
mean := sum / float64(sampleSize)
5952

0 commit comments

Comments
 (0)