mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 05:34:05 -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> |
||
---|---|---|
.. | ||
chunked.go | ||
chunked_test.go | ||
client.go | ||
client_test.go | ||
codec.go | ||
codec_test.go | ||
ewma.go | ||
intern.go | ||
intern_test.go | ||
max_timestamp.go | ||
metadata_watcher.go | ||
metadata_watcher_test.go | ||
queue_manager.go | ||
queue_manager_test.go | ||
read.go | ||
read_handler.go | ||
read_handler_test.go | ||
read_test.go | ||
storage.go | ||
storage_test.go | ||
write.go | ||
write_handler.go | ||
write_handler_test.go | ||
write_test.go |