VictoriaMetrics/lib/mergeset
Zakhar Bessarab 837d0d136d
lib/mergeset: add sparse indexdb cache (#7269)
Related issue:
https://github.com/VictoriaMetrics/VictoriaMetrics/issues/7182

- add a separate index cache for searches which might read through large
amounts of random entries. Primary use-case for this is retention and
downsampling filters, when applying filters background merge needs to
fetch large amount of random entries which pollutes an index cache.
Using different caches allows to reduce effect on memory usage and cache
efficiency of the main cache while still having high cache hit rate. A
separate cache size is 5% of allowed memory.

- reduce size of indexdb/dataBlocks cache in order to free memory for
new sparse cache. Reduced size by 5% and moved this to a separate cache.

- add a separate metricName search which does not cache metric names -
this is needed in order to allow disabling metric name caching when
applying downsampling/retention filters. Applying filters during
background merge accesses random entries, this fills up cache and does
not provide an actual improvement due to random access nature.


Merge performance and memory usage stats before and after the change:

- before

![image](https://github.com/user-attachments/assets/485fffbb-c225-47ae-b5c5-bc8a7c57b36e)


- after

![image](https://github.com/user-attachments/assets/f4ba3440-7c1c-4ec1-bc54-4d2ab431eef5)

---------

Signed-off-by: Zakhar Bessarab <z.bessarab@victoriametrics.com>
2024-10-24 15:21:17 +02:00
..
block_header.go lib/encoding: optimize UnmarshalVarUint64, UnmarshalVarInt64 and UnmarshalBytes a bit 2024-05-14 01:23:54 +02:00
block_stream_reader_test.go lib/mergeset: use deterministic random generator in tests 2023-01-23 19:43:49 -08:00
block_stream_reader.go lib/{storage,mergeset}: convert InitFromFilePart to MustInitFromFilePart 2023-04-14 15:46:12 -07:00
block_stream_writer.go lib/mergeset: properly record the firstItem in metaindexRow at blockStreamWriter.WriteBlock 2024-02-12 18:06:50 +02:00
encoding_test.go lib/mergeset: use deterministic random generator in tests 2023-01-23 19:43:49 -08:00
encoding_timing_test.go lib/mergeset: fix data race in BenchmarkInmemoryBlockMarshal 2023-01-23 19:43:18 -08:00
encoding.go lib/slicesutil: add helper functions for setting slice length and extending its capacity 2024-05-12 11:32:17 +02:00
filenames.go lib/mergeset: consistently use OS-independent separator in file paths 2023-03-25 13:39:41 -07:00
inmemory_part.go lib/mergeset: verify that the index block for in-memory part doesnt exceed the 3*maxIndexBlockSize 2024-02-08 13:50:14 +02:00
merge_test.go lib/mergeset: consistently use atomic.* types instead of atomic.* function calls on ordinary types 2024-02-23 23:29:35 +02:00
merge.go all: consistently use 'any' instead of 'interface{}' 2024-07-10 00:20:37 +02:00
metaindex_row.go lib/encoding: optimize UnmarshalVarUint64, UnmarshalVarInt64 and UnmarshalBytes a bit 2024-05-14 01:23:54 +02:00
part_header.go lib/mergeset: fix typos in comments 2024-08-07 15:54:15 +02:00
part_search_test.go lib/mergeset: add sparse indexdb cache (#7269) 2024-10-24 15:21:17 +02:00
part_search.go lib/mergeset: add sparse indexdb cache (#7269) 2024-10-24 15:21:17 +02:00
part.go lib/mergeset: add sparse indexdb cache (#7269) 2024-10-24 15:21:17 +02:00
table_search_test.go lib/mergeset: add sparse indexdb cache (#7269) 2024-10-24 15:21:17 +02:00
table_search_timing_test.go lib/mergeset: add sparse indexdb cache (#7269) 2024-10-24 15:21:17 +02:00
table_search.go lib/mergeset: add sparse indexdb cache (#7269) 2024-10-24 15:21:17 +02:00
table_test.go lib/mergeset: add sparse indexdb cache (#7269) 2024-10-24 15:21:17 +02:00
table.go lib/mergeset: add sparse indexdb cache (#7269) 2024-10-24 15:21:17 +02:00