prometheus/storage
Oleg Zaytsev beb7d3b80f
remote.Client: store urlString
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>
2023-03-16 09:53:10 +01:00
..
remote remote.Client: store urlString 2023-03-16 09:53:10 +01:00
buffer.go federate: Fix PeekBack usage 2023-01-12 20:43:02 +05:30
buffer_test.go federate: Fix PeekBack usage 2023-01-12 20:43:02 +05:30
fanout.go Support FloatHistogram in TSDB (#11522) 2022-12-28 14:25:07 +05:30
fanout_test.go storage: allow re-use of iterators 2022-12-15 18:32:45 +00:00
generic.go Move packages out of deprecated pkg directory 2021-11-09 08:03:10 +01:00
interface.go Support FloatHistogram in TSDB (#11522) 2022-12-28 14:25:07 +05:30
lazy.go tsdb: Added ChunkQueryable implementations to db; unified MergeSeriesSets and vertical to single struct. (#7069) 2020-07-31 16:03:02 +01:00
memoized_iterator.go Merge branch 'main' into sparsehistogram 2021-12-15 13:49:33 +01:00
memoized_iterator_test.go Merge 'main' into sparsehistogram 2022-10-05 22:14:49 +02:00
merge.go histograms: Fix counter reset header during merging 2023-01-25 18:23:10 +01:00
merge_test.go Refactor tsdbutil for tests/native histograms (#11948) 2023-02-10 17:09:33 +05:30
noop.go Move packages out of deprecated pkg directory 2021-11-09 08:03:10 +01:00
secondary.go Move packages out of deprecated pkg directory 2021-11-09 08:03:10 +01:00
series.go Support FloatHistogram in TSDB (#11522) 2022-12-28 14:25:07 +05:30
series_test.go package storage: fix up test not to access Labels internals 2023-01-16 18:48:49 +00:00