VictoriaMetrics/lib/storage
Aliaksandr Valialkin 6f61fd367a lib/storage: add BenchmarkHeadPostingForMatchers similar to the benchmark from Prometheus
See the corresponding benchmark in Prometheus - 23c0299d85/tsdb/head_bench_test.go (L52)

The benchmark allows performing apples-to-apples comparison of time series search
in Prometheus and VictoriaMetrics. The following article - https://www.robustperception.io/evaluating-performance-and-correctness -
contains incorrect numbers for VictoriaMetrics, since there wasn't this benchmark yet. Fix it.

Benchmarks can be repeated with the following commands from Prometheus and VictoriaMetrics source code roots:

- Prometheus: GOMAXPROCS=1 go test ./tsdb/ -run=111 -bench=BenchmarkHeadPostingForMatchers
- VictoriaMetrics: GOMAXPROCS=1 go test ./lib/storage/ -run=111 -bench=BenchmarkHeadPostingForMatchers

Benchmark results:
benchmark                                                          old ns/op      new ns/op     delta
BenchmarkHeadPostingForMatchers/n="1"                              272756688      364977        -99.87%
BenchmarkHeadPostingForMatchers/n="1",j="foo"                      138132923      1181636       -99.14%
BenchmarkHeadPostingForMatchers/j="foo",n="1"                      134723762      1141578       -99.15%
BenchmarkHeadPostingForMatchers/n="1",j!="foo"                     195823953      1148056       -99.41%
BenchmarkHeadPostingForMatchers/i=~".*"                            7962582919     8716755       -99.89%
BenchmarkHeadPostingForMatchers/i=~".+"                            7589543864     12096587      -99.84%
BenchmarkHeadPostingForMatchers/i=~""                              1142371741     16164560      -98.59%
BenchmarkHeadPostingForMatchers/i!=""                              9964150263     12230021      -99.88%
BenchmarkHeadPostingForMatchers/n="1",i=~".*",j="foo"              216995884      1173476       -99.46%
BenchmarkHeadPostingForMatchers/n="1",i=~".*",i!="2",j="foo"       202541348      1299743       -99.36%
BenchmarkHeadPostingForMatchers/n="1",i!=""                        486285711      11555193      -97.62%
BenchmarkHeadPostingForMatchers/n="1",i!="",j="foo"                350776931      5607506       -98.40%
BenchmarkHeadPostingForMatchers/n="1",i=~".+",j="foo"              380888565      6380335       -98.32%
BenchmarkHeadPostingForMatchers/n="1",i=~"1.+",j="foo"             89500296       2078970       -97.68%
BenchmarkHeadPostingForMatchers/n="1",i=~".+",i!="2",j="foo"       379529654      6561368       -98.27%
BenchmarkHeadPostingForMatchers/n="1",i=~".+",i!~"2.*",j="foo"     424563825      6757132       -98.41%

The first column (old) is for Prometheus, the second column (new) is for VictoriaMetrics.

Prometheus was using 3.5GB of RAM during the benchmark, while VictoriaMetrics was using 400MB of RAM.
2019-11-18 18:47:02 +02:00
..
block_header_test.go all: open-sourcing cluster version 2019-05-23 00:25:38 +03:00
block_header.go lib/storage: pre-allocate memory for blockHeader slice in unmarshalBlockHeaders 2019-08-19 12:46:45 +03:00
block_stream_merger.go all: open-sourcing single-node version 2019-05-23 00:18:06 +03:00
block_stream_reader_test.go all: add support for GOARCH=386 and fix all the issues related to 32-bit architectures such as GOARCH=arm 2019-10-17 18:27:49 +03:00
block_stream_reader_timing_test.go all: open-sourcing single-node version 2019-05-23 00:18:06 +03:00
block_stream_reader.go lib/storage: remove interface conversion in hot path during block merging 2019-11-03 12:33:48 +02:00
block_stream_writer_timing_test.go all: open-sourcing single-node version 2019-05-23 00:18:06 +03:00
block_stream_writer.go lib/storage: remove interface conversion in hot path during block merging 2019-11-03 12:33:48 +02:00
block.go lib/storage: do not change timestamps to constant rate if values are constant or have constant delta 2019-08-06 15:40:17 +03:00
index_db_test.go lib/storage: remove inmemory index for recent hour, since it uses too much memory 2019-11-13 18:08:58 +02:00
index_db_timing_test.go lib/storage: add BenchmarkHeadPostingForMatchers similar to the benchmark from Prometheus 2019-11-18 18:47:02 +02:00
index_db.go lib/storage: remove inmemory index for recent hour, since it uses too much memory 2019-11-13 18:08:58 +02:00
inmemory_part_test.go all: open-sourcing single-node version 2019-05-23 00:18:06 +03:00
inmemory_part_timing_test.go all: open-sourcing single-node version 2019-05-23 00:18:06 +03:00
inmemory_part.go all: add vm_data_size_bytes metrics for easy monitoring of on-disk data size and on-disk inverted index size 2019-07-04 19:43:04 +03:00
merge_test.go all: add support for GOARCH=386 and fix all the issues related to 32-bit architectures such as GOARCH=arm 2019-10-17 18:27:49 +03:00
merge_timing_test.go all: open-sourcing single-node version 2019-05-23 00:18:06 +03:00
merge.go lib/storage: create and use lib/uint64set instead of map[uint64]struct{} 2019-09-24 21:18:04 +03:00
metaindex_row_test.go all: open-sourcing cluster version 2019-05-23 00:25:38 +03:00
metaindex_row.go all: open-sourcing single-node version 2019-05-23 00:18:06 +03:00
metric_name_test.go lib/storage: pass pointer to MetricName in Fatalf, so it is properly detected as an interface with String() method 2019-11-04 01:06:45 +02:00
metric_name.go lib/{storage,mergeset}: merge tag->metricID rows into tag->metricIDs rows for common tag values 2019-09-20 22:06:23 +03:00
part_header_test.go all: open-sourcing single-node version 2019-05-23 00:18:06 +03:00
part_header.go all: open-sourcing single-node version 2019-05-23 00:18:06 +03:00
part_search_test.go app/vmselect: optimize /api/v1/series by skipping storage data 2019-08-04 23:00:46 +03:00
part_search.go lib/storage: share tsids across all the partSearch instances 2019-09-23 22:36:16 +03:00
part.go all: add support for GOARCH=386 and fix all the issues related to 32-bit architectures such as GOARCH=arm 2019-10-17 18:27:49 +03:00
partition_search_test.go lib/storage: create and use lib/uint64set instead of map[uint64]struct{} 2019-09-24 21:18:04 +03:00
partition_search.go lib/storage: share tsids across all the partSearch instances 2019-09-23 22:36:16 +03:00
partition_test.go all: add support for GOARCH=386 and fix all the issues related to 32-bit architectures such as GOARCH=arm 2019-10-17 18:27:49 +03:00
partition.go lib/storage: return back finalPartsToMerge from 2 to 3 in order to prevent from excessive merges in old partitions 2019-11-05 17:28:57 +02:00
raw_block.go all: open-sourcing single-node version 2019-05-23 00:18:06 +03:00
raw_row.go lib/storage: optimize TSID comparison 2019-09-26 14:20:02 +03:00
search_test.go lib/storage: remove inmemory index for recent hour, since it uses too much memory 2019-11-13 18:08:58 +02:00
search.go app/vmselect: optimize /api/v1/series by skipping storage data 2019-08-04 23:00:46 +03:00
storage_test.go lib/storage: remove inmemory index for recent hour, since it uses too much memory 2019-11-13 18:08:58 +02:00
storage_timing_test.go all: open-sourcing cluster version 2019-05-23 00:25:38 +03:00
storage.go lib/storage: add vm_cache_size_bytes{type="storage/hour_metric_ids"} metric 2019-11-13 20:26:05 +02:00
table_search_test.go app/vmselect: optimize /api/v1/series by skipping storage data 2019-08-04 23:00:46 +03:00
table_search_timing_test.go app/vmselect: optimize /api/v1/series by skipping storage data 2019-08-04 23:00:46 +03:00
table_search.go lib/storage: share tsids across all the partSearch instances 2019-09-23 22:36:16 +03:00
table_test.go all: open-sourcing single-node version 2019-05-23 00:18:06 +03:00
table_timing_test.go all: open-sourcing single-node version 2019-05-23 00:18:06 +03:00
table.go lib/storage: populate partition names from both small and big directories 2019-11-06 19:50:21 +02:00
tag_filters_test.go lib/storage: properly match labels against regexp with (?i) flag 2019-09-26 11:03:26 +03:00
tag_filters_timing_test.go all: open-sourcing single-node version 2019-05-23 00:18:06 +03:00
tag_filters.go lib/storage: properly match labels against regexp with (?i) flag 2019-09-26 11:03:26 +03:00
time_test.go all: open-sourcing single-node version 2019-05-23 00:18:06 +03:00
time.go lib/storage: remove unused code from getMetricIDsForTimeRange: it is expected that time range is always non-zero 2019-11-09 19:03:51 +02:00
tsid_test.go all: open-sourcing cluster version 2019-05-23 00:25:38 +03:00
tsid.go lib/storage: optimize TSID comparison 2019-09-26 14:20:02 +03:00