prometheus/model
Bryan Boreham b2c2146d7c
Labels: simpler/faster stringlabels encoding (#16069)
Instead of using varint to encode the size of each label, use a single
byte for size 0-254, or a flag value of 255 followed by the size in
3 bytes little-endian.

This reduces the amount of code, and also the number of branches in
commonly-executed code, so it runs faster.

The maximum allowed label name or value length is now 2^24 or 16MB.

Memory used by labels changes as follows:
* Labels from 0 to 127 bytes length: same
* From 128 to 254: 1 byte less
* From 255 to 16383: 2 bytes more
* From 16384 to 2MB: 1 byte more
* From 2MB to 16MB: same

Labels: panic on string too long.

Slightly more user-friendly than encoding bad data and finding out when
we decode.

Clarify that Labels.Bytes() encoding can change

---------

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
2025-04-30 10:53:48 +01:00
..
exemplar update links to openmetrics to reference the v1.0.0 release 2024-12-13 21:32:27 +00:00
histogram fix TestCuttingNewHeadChunks/really_large_histograms on 32-bit 2024-12-16 10:45:01 -05:00
labels Labels: simpler/faster stringlabels encoding (#16069) 2025-04-30 10:53:48 +01:00
metadata Fix: metadata API using wrong field names (#13633) 2024-02-26 09:53:39 +00:00
relabel utf8: Remove support for legacy global validation setting 2025-03-13 10:47:24 -04:00
rulefmt chore: Export rulefmt.ruleNode (#16252) 2025-03-20 22:58:32 +00:00
textparse parser: remove expired link from comment (#16189) 2025-03-23 12:41:48 +01:00
timestamp Move packages out of deprecated pkg directory 2021-11-09 08:03:10 +01:00
value Move packages out of deprecated pkg directory 2021-11-09 08:03:10 +01:00