VictoriaMetrics/lib/mergeset
Aliaksandr Valialkin fa566c68a6
lib/mergeset: really limit the number of in-memory parts to 15
It has been appeared that the registration of new time series slows down linearly
with the number of indexdb parts, since VictoriaMetrics needs to check every indexdb part
when it searches for TSID by newly ingested metric name.

The number of in-memory parts grows when new time series are registered
at high rate. The number of in-memory parts grows faster on systems with big number
of CPU cores, because the mergeset maintains per-CPU buffers with newly added entries
for the indexdb, and every such entry is transformed eventually into a separate in-memory part.

The solution has been suggested in https://github.com/VictoriaMetrics/VictoriaMetrics/pull/5212
by @misutoth - to limit the number of in-memory parts with buffered channel.
This solution is implemented in this commit. Additionally, this commit merges per-CPU parts
into a single part before adding it to the list of in-memory parts. This reduces CPU load
when searching for TSID by newly ingested metric name.

The https://github.com/VictoriaMetrics/VictoriaMetrics/pull/5212 recommends setting the limit on the number
of in-memory parts to 100, but my internal testing shows that much lower limit 15 works with the same efficiency
on a system with 16 CPU cores while reducing memory usage for `indexdb/dataBlocks` cache by up to 50%.

Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/5190
2024-01-24 03:38:12 +02:00
..
block_header.go lib/mergeset: properly reset bsr.bhIdx after the call to blockStreamReader.readNextBHS() 2022-11-16 21:23:35 +02:00
block_stream_reader.go lib/{storage,mergeset}: convert InitFromFilePart to MustInitFromFilePart 2023-04-14 15:46:12 -07:00
block_stream_reader_test.go lib/mergeset: use deterministic random generator in tests 2023-01-23 19:43:49 -08:00
block_stream_writer.go lib/{storage,mergeset}: convert InitFromFilePart to MustInitFromFilePart 2023-04-14 15:46:12 -07:00
encoding.go app,lib: fix typos in comments (#3804) 2023-02-13 13:27:13 +01: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
filenames.go lib/mergeset: consistently use OS-independent separator in file paths 2023-03-25 13:39:41 -07:00
inmemory_part.go lib/{storage,mergeset}: convert InitFromFilePart to MustInitFromFilePart 2023-04-14 15:46:12 -07:00
merge.go lib/mergeset: make sure that the first and the last items are in the original range after prepareBlock() 2024-01-23 12:58:32 +02:00
merge_test.go lib/{storage,mergeset}: convert InitFromFilePart to MustInitFromFilePart 2023-04-14 15:46:12 -07:00
metaindex_row.go all: subsitute ioutil.ReadAll with io.ReadAll 2022-08-22 00:16:37 +03:00
part.go lib/{storage,mergeset}: convert InitFromFilePart to MustInitFromFilePart 2023-04-14 15:46:12 -07:00
part_header.go lib/{storage,mergeset}: convert InitFromFilePart to MustInitFromFilePart 2023-04-14 15:46:12 -07:00
part_search.go lib/mergeset: skip common prefix in binarySearchKey() function 2023-07-13 22:04:59 -07:00
part_search_test.go lib/{storage,mergeset}: convert InitFromFilePart to MustInitFromFilePart 2023-04-14 15:46:12 -07:00
table.go lib/mergeset: really limit the number of in-memory parts to 15 2024-01-24 03:38:12 +02:00
table_search.go optimized code (#2103) 2022-01-28 14:15:41 +02:00
table_search_test.go lib/fs: add MustReadDir() function 2023-04-14 22:10:46 -07:00
table_search_timing_test.go lib/fs: add MustReadDir() function 2023-04-14 22:10:46 -07:00
table_test.go lib/mergeset: close and open the table before making snapshots at TestTableCreateSnapshotAt() 2023-05-16 14:55:11 -07:00