Skip to content

Commit

Permalink
Change exemplars to slice of values instead of ptrs (#2402)
Browse files Browse the repository at this point in the history
Benchmarks before:
```
goos: darwin
goarch: amd64
pkg: go.opentelemetry.io/collector/consumer/pdata
BenchmarkMetricsFromOtlp
BenchmarkMetricsFromOtlp-16    	     322	   3809358 ns/op	 2271080 B/op	   51507 allocs/op
PASS
```

Benchmarks after
```
goos: darwin
goarch: amd64
pkg: go.opentelemetry.io/collector/consumer/pdata
BenchmarkMetricsFromOtlp
BenchmarkMetricsFromOtlp-16    	     331	   3594315 ns/op	 3212271 B/op	   34700 allocs/op
PASS
```

Significant improvement in the number of allocations. Increase in the number of total bytes allocated.

Signed-off-by: Bogdan Drutu <[email protected]>
  • Loading branch information
bogdandrutu authored Feb 3, 2021
1 parent e12dee4 commit 522fba3
Show file tree
Hide file tree
Showing 7 changed files with 149 additions and 145 deletions.
4 changes: 2 additions & 2 deletions cmd/pdatagen/internal/metrics_structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ var quantileValues = &messageValueStruct{
},
}

var intExemplarSlice = &sliceOfPtrs{
var intExemplarSlice = &sliceOfValues{
structName: "IntExemplarSlice",
element: intExemplar,
}
Expand All @@ -363,7 +363,7 @@ var intExemplar = &messageValueStruct{
},
}

var doubleExemplarSlice = &sliceOfPtrs{
var doubleExemplarSlice = &sliceOfValues{
structName: "DoubleExemplarSlice",
element: doubleExemplar,
}
Expand Down
62 changes: 26 additions & 36 deletions consumer/pdata/generated_metrics.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions consumer/pdata/generated_metrics_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 16 additions & 8 deletions consumer/simple/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ func TestMetrics(t *testing.T) {
}
],
"time_unix_nano": 1597266546570840817,
"value": 9000000
"value": 9000000,
"exemplars": null
}
]
}
Expand All @@ -142,7 +143,8 @@ func TestMetrics(t *testing.T) {
}
],
"time_unix_nano": 1597266546570840817,
"value": 50
"value": 50,
"exemplars": null
},
{
"labels": [
Expand All @@ -156,7 +158,8 @@ func TestMetrics(t *testing.T) {
}
],
"time_unix_nano": 1597266546570840817,
"value": 5
"value": 5,
"exemplars": null
}
]
}
Expand All @@ -175,7 +178,8 @@ func TestMetrics(t *testing.T) {
}
],
"time_unix_nano": 1597266546570840817,
"value": 30.5
"value": 30.5,
"exemplars": null
}
]
}
Expand All @@ -194,7 +198,8 @@ func TestMetrics(t *testing.T) {
}
],
"time_unix_nano": 1597266546570840817,
"value": 100.6
"value": 100.6,
"exemplars": null
}
]
}
Expand All @@ -217,7 +222,8 @@ func TestMetrics(t *testing.T) {
}
],
"time_unix_nano": 1597266546570840817,
"value": 40000
"value": 40000,
"exemplars": null
}
]
}
Expand All @@ -230,7 +236,8 @@ func TestMetrics(t *testing.T) {
"data_points": [
{
"labels": [],
"time_unix_nano": 1597266546570840817
"time_unix_nano": 1597266546570840817,
"exemplars": null
}
]
}
Expand All @@ -243,7 +250,8 @@ func TestMetrics(t *testing.T) {
"data_points": [
{
"labels": [],
"time_unix_nano": 1597266546570840817
"time_unix_nano": 1597266546570840817,
"exemplars": null
}
]
}
Expand Down
Loading

0 comments on commit 522fba3

Please sign in to comment.