mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
cf1a8bce6b
* lib/index: reduce read/write load after indexDB rotation IndexDB in VM is responsible for storing TSID - ID's used for identifying time series. The index is stored on disk and used by both ingestion and read path. IndexDB is stored separately to data parts and is global for all stored data. It can't be deleted partially as VM deletes data parts. Instead, indexDB is rotated once in `retention` interval. The rotation procedure means that `current` indexDB becomes `previous`, and new freshly created indexDB struct becomes `current`. So in any time, VM holds indexDB for current and previous retention periods. When time series is ingested or queried, VM checks if its TSID is present in `current` indexDB. If it is missing, it checks the `previous` indexDB. If TSID was found, it gets copied to the `current` indexDB. In this way `current` indexDB stores only series which were active during the retention period. To improve indexDB lookups, VM uses a cache layer called `tsidCache`. Both write and read path consult `tsidCache` and on miss the relad lookup happens. When rotation happens, VM resets the `tsidCache`. This is needed for ingestion path to trigger `current` indexDB re-population. Since index re-population requires additional resources, every index rotation event may cause some extra load on CPU and disk. While it may be unnoticeable for most of the cases, for systems with very high number of unique series each rotation may lead to performance degradation for some period of time. This PR makes an attempt to smooth out resource usage after the rotation. The changes are following: 1. `tsidCache` is no longer reset after the rotation; 2. Instead, each entry in `tsidCache` gains a notion of indexDB to which they belong; 3. On ingestion path after the rotation we check if requested TSID was found in `tsidCache`. Then we have 3 branches: 3.1 Fast path. It was found, and belongs to the `current` indexDB. Return TSID. 3.2 Slow path. It wasn't found, so we generate it from scratch, add to `current` indexDB, add it to `tsidCache`. 3.3 Smooth path. It was found but does not belong to the `current` indexDB. In this case, we add it to the `current` indexDB with some probability. The probability is based on time passed since the last rotation with some threshold. The more time has passed since rotation the higher is chance to re-populate `current` indexDB. The default re-population interval in this PR is set to `1h`, during which entries from `previous` index supposed to slowly re-populate `current` index. The new metric `vm_timeseries_repopulated_total` was added to identify how many TSIDs were moved from `previous` indexDB to the `current` indexDB. This metric supposed to grow only during the first `1h` after the last rotation. https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1401 Signed-off-by: hagen1778 <roman@victoriametrics.com> * wip * wip Co-authored-by: Aliaksandr Valialkin <valyala@victoriametrics.com> |
||
---|---|---|
.. | ||
block.go | ||
block_header.go | ||
block_header_test.go | ||
block_stream_merger.go | ||
block_stream_reader.go | ||
block_stream_reader_test.go | ||
block_stream_reader_timing_test.go | ||
block_stream_writer.go | ||
block_stream_writer_timing_test.go | ||
block_test.go | ||
dedup.go | ||
dedup_test.go | ||
dedup_timing_test.go | ||
index_db.go | ||
index_db_test.go | ||
index_db_timing_test.go | ||
inmemory_part.go | ||
inmemory_part_test.go | ||
inmemory_part_timing_test.go | ||
merge.go | ||
merge_test.go | ||
merge_timing_test.go | ||
metaindex_row.go | ||
metaindex_row_test.go | ||
metric_name.go | ||
metric_name_test.go | ||
part.go | ||
part_header.go | ||
part_header_test.go | ||
part_search.go | ||
part_search_test.go | ||
partition.go | ||
partition_search.go | ||
partition_search_test.go | ||
partition_test.go | ||
raw_block.go | ||
raw_row.go | ||
search.go | ||
search_test.go | ||
storage.go | ||
storage_test.go | ||
storage_timing_test.go | ||
table.go | ||
table_search.go | ||
table_search_test.go | ||
table_search_timing_test.go | ||
table_test.go | ||
table_timing_test.go | ||
tag_filters.go | ||
tag_filters_test.go | ||
tag_filters_timing_test.go | ||
time.go | ||
time_test.go | ||
tsid.go | ||
tsid_test.go |