mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-26 22:19:40 -08:00
beb7d3b80f
During remote write, we call url.String() twice: - to add the Endpoint() to the span - to actually know where whe should send the request This value does not change over time, and it's not really that lightweight to calculate. I wrote this simple benchmark: func BenchmarkURLString(b *testing.B) { u, err := url.Parse("https://remote.write.com/api/v1") require.NoError(b, err) b.Run("string", func(b *testing.B) { count := 0 for i := 0; i < b.N; i++ { count += len(u.String()) } }) } And the results are ~200ns/op, 80B/op, 3 allocs/op. Yes, we're going to go to the network here, which is a huge amount of resources compared to this, but still, on agents that send 500 requests per second, that is 1500 wasteful allocations per second. Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com> |
||
---|---|---|
.. | ||
remote | ||
buffer.go | ||
buffer_test.go | ||
fanout.go | ||
fanout_test.go | ||
generic.go | ||
interface.go | ||
lazy.go | ||
memoized_iterator.go | ||
memoized_iterator_test.go | ||
merge.go | ||
merge_test.go | ||
noop.go | ||
secondary.go | ||
series.go | ||
series_test.go |