prometheus/util
Oleg Zaytsev 6e2905a4d4
Use zeropool.Pool to workaround SA6002 (#12189)
* Use zeropool.Pool to workaround SA6002

I built a tiny library called https://github.com/colega/zeropool to
workaround the SA6002 staticheck issue.

While searching for the references of that SA6002 staticheck issues on
Github first results was Prometheus itself, with quite a lot of ignores
of it.

This changes the usages of `sync.Pool` to `zeropool.Pool[T]` where a
pointer is not available.

Also added a benchmark for HeadAppender Append/Commit when series
already exist, which is one of the most usual cases IMO, as I didn't find
any.

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>

* Improve BenchmarkHeadAppender with more cases

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>

* A little copying is better than a little dependency

https://www.youtube.com/watch?v=PAAkCSZUG1c&t=9m28s

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>

* Fix imports order

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>

* Add license header

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>

* Copyright should be on one of the first 3 lines

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>

* Use require.Equal for testing

I don't depend on testify in my lib, but here we have it available.

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>

* Avoid flaky test

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>

* Also use zeropool for pointsPool in engine.go

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>

---------

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
2023-03-29 20:34:34 +01:00
..
documentcli Document command line tools 2023-03-13 14:20:55 +01:00
gate Move packages out of deprecated pkg directory 2021-11-09 08:03:10 +01:00
httputil refactor: move from io/ioutil to io and os packages (#10528) 2022-04-27 11:24:36 +02:00
jsonutil api: export point marshaling functions (#11323) 2022-09-29 20:16:48 +05:30
logging refactor (util): move from github.com/pkg/errors to 'errors' and 'fmt' (#10877) 2022-06-27 18:16:58 +02:00
osutil Format Go source files using 'gofumpt -w -s -extra' 2021-11-02 19:52:34 +01:00
pool Move packages out of deprecated pkg directory 2021-11-09 08:03:10 +01:00
runtime util/runtime: use ByteSliceToString from golang.org/x/sys/unix in Uname (#11070) 2022-07-30 19:35:03 +02:00
stats Changing TotalQueryableSamples from int to int64 (#10549) 2022-04-12 01:22:25 +02:00
strutil Implement SanitizeLabelName and Full variant 2023-02-03 15:28:33 +00:00
teststorage Add a feature flag to control native histogram ingestion (#11253) 2022-09-14 17:38:34 +05:30
testutil refactor: move from io/ioutil to io and os packages (#10528) 2022-04-27 11:24:36 +02:00
treecache refactor (util): move from github.com/pkg/errors to 'errors' and 'fmt' (#10877) 2022-06-27 18:16:58 +02:00
zeropool Use zeropool.Pool to workaround SA6002 (#12189) 2023-03-29 20:34:34 +01:00