Closed iksaif closed 11 months ago
Before: BenchmarkGetContextNoTags-10 39929401 29.70 ns/op 16 B/op 1 allocs/op
BenchmarkGetContextNoTags-10 39929401 29.70 ns/op 16 B/op 1 allocs/op
After: BenchmarkGetContextNoTags-10 419886585 2.902 ns/op 0 B/op 0 allocs/op
BenchmarkGetContextNoTags-10 419886585 2.902 ns/op 0 B/op 0 allocs/op
This might look not much, but this makes a lot of difference in term of allocation when a counter is called repeatedly inside a loop.
This also fixes the other benchmarks that I wanted to run to validate I didn't cause regression but where not able to run properly
We can see it in this profile (referencing line 182 explicitely):
Referencing https://github.com/DataDog/datadog-go/blob/master/statsd/aggregator.go#L182 as the main cause of allocation
From a simple call to Count: statsd.Count("rollout.done", 1, nil, 1.0)
statsd.Count("rollout.done", 1, nil, 1.0)
Before:
BenchmarkGetContextNoTags-10 39929401 29.70 ns/op 16 B/op 1 allocs/op
After:
BenchmarkGetContextNoTags-10 419886585 2.902 ns/op 0 B/op 0 allocs/op
This might look not much, but this makes a lot of difference in term of allocation when a counter is called repeatedly inside a loop.
This also fixes the other benchmarks that I wanted to run to validate I didn't cause regression but where not able to run properly
We can see it in this profile (referencing line 182 explicitely):
Referencing https://github.com/DataDog/datadog-go/blob/master/statsd/aggregator.go#L182 as the main cause of allocation
From a simple call to Count:
statsd.Count("rollout.done", 1, nil, 1.0)