prometheus/tsdb/index
Oleg Zaytsev 8553a98267
Optimize postings offset table reading (#11535)
* Add BenchmarkOpenBlock

* Use specific types when reading offset table

Instead of reading a generic-ish []string, we can read a generic type
which would be specifically labels.Label.

This avoid allocating a slice that escapes to the heap, making it both
faster and more efficient in terms of memory management.

* Update error message for unexpected number of keys

* s/posting offset table/postings offset table/

* Remove useless lastKey assignment

* Use two []bytes vars, simplify

Applied PR feedback: removed generics, moved the label indices reading
to that specific test as we're not using it in production anyway, we're
just testing what we've just built.

Also using two []bytes variables for name and value that use the backing
buffer instead of using strings, this reduces allocations a lot as we
only copy them when we store them (this is optimized by the compiler).

* Fix the dumb bug

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
Co-authored-by: Marco Pracucci <marco@pracucci.com>
2022-11-14 17:48:16 +01:00
..
index.go Optimize postings offset table reading (#11535) 2022-11-14 17:48:16 +01:00
index_test.go Optimize postings offset table reading (#11535) 2022-11-14 17:48:16 +01:00
postings.go Replace sort.Strings and sort.Ints with faster slices.Sort (#11318) 2022-09-30 20:03:56 +05:30
postings_test.go Tidy postingsWithIndexHeap (#10123) 2022-01-06 16:03:44 +05:30
postingsstats.go Format Go source files using 'gofumpt -w -s -extra' 2021-11-02 19:52:34 +01:00
postingsstats_test.go Format Go source files using 'gofumpt -w -s -extra' 2021-11-02 19:52:34 +01:00