From 7ad36505d554cf488a77ab0a119257b82b3b9aba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Rabenstein?= Date: Thu, 15 Sep 2022 09:41:57 +0200 Subject: [PATCH] tsdb: Update comment about a possible space optimization (#11303) See also #11195 for the detailed reasoning. Signed-off-by: beorn7 Signed-off-by: beorn7 --- tsdb/chunkenc/varbit.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tsdb/chunkenc/varbit.go b/tsdb/chunkenc/varbit.go index 4220819b9..b3b14cf41 100644 --- a/tsdb/chunkenc/varbit.go +++ b/tsdb/chunkenc/varbit.go @@ -23,11 +23,14 @@ import ( // optimized for the dod's observed in histogram buckets, plus a few additional // buckets for large numbers. // -// TODO(Dieterbe): We could improve this further: Each branch doesn't need to -// support any values of any of the prior branches. So we can expand the range -// of each branch. Do more with fewer bits. It comes at the price of more -// expensive encoding and decoding (cutting out and later adding back that -// center-piece we skip). +// For optimal space utilization, each branch didn't need to support any values +// of any of the prior branches. So we could expand the range of each branch. Do +// more with fewer bits. It would come at the price of more expensive encoding +// and decoding (cutting out and later adding back that center-piece we +// skip). With the distributions of values we see in practice, we would reduce +// the size by around 1%. A more detailed study would be needed for precise +// values, but it's appears quite certain that we would end up far below 10%, +// which would maybe convince us to invest the increased coding/decoding cost. func putVarbitInt(b *bstream, val int64) { switch { case val == 0: // Precisely 0, needs 1 bit.