Skip to content

Conversation

@martijnvg
Copy link
Member

Avoid iterating over SortedNumericDocValues that merges on the fly when building DISI bit set. This applies when index sorting is active. Capture which doc ids have at least one value and then encode that to disk later after values have been encoded to disk.

This is an optimization mentioned in #125403.

…when building DISI bit set.

Capture which doc ids have at least one value and then encode that to disk later after values have been encoded to disk.

This is an optimization mentioned in elastic#125403.
@martijnvg
Copy link
Member Author

Running tsdb track without this change as baseline and with this change as contender:

|                                                                   Metric |                    Task |        Baseline |       Contender |       Diff |   Unit |   Diff % |
|-------------------------------------------------------------------------:|------------------------:|----------------:|----------------:|-----------:|-------:|---------:|
|                               Cumulative indexing time of primary shards |                         |   267.277       |   264.702       |   -2.57447 |    min |   -0.96% |
|                        Min cumulative indexing time across primary shard |                         |     0           |     0           |    0       |    min |    0.00% |
|                     Median cumulative indexing time across primary shard |                         |     0           |     0           |    0       |    min |    0.00% |
|                        Max cumulative indexing time across primary shard |                         |   267.277       |   264.702       |   -2.57447 |    min |   -0.96% |
|                      Cumulative indexing throttle time of primary shards |                         |     0           |     0           |    0       |    min |    0.00% |
|               Min cumulative indexing throttle time across primary shard |                         |     0           |     0           |    0       |    min |    0.00% |
|            Median cumulative indexing throttle time across primary shard |                         |     0           |     0           |    0       |    min |    0.00% |
|               Max cumulative indexing throttle time across primary shard |                         |     0           |     0           |    0       |    min |    0.00% |
|                                  Cumulative merge time of primary shards |                         |    88.0096      |    80.1026      |   -7.90705 |    min |   -8.98% |
|                                 Cumulative merge count of primary shards |                         |    60           |    58           |   -2       |        |   -3.33% |
|                           Min cumulative merge time across primary shard |                         |     0           |     0           |    0       |    min |    0.00% |
|                        Median cumulative merge time across primary shard |                         |     0           |     0           |    0       |    min |    0.00% |
|                           Max cumulative merge time across primary shard |                         |    88.0096      |    80.1026      |   -7.90705 |    min |   -8.98% |
|                         Cumulative merge throttle time of primary shards |                         |    15.859       |    15.3762      |   -0.48287 |    min |   -3.04% |
|                  Min cumulative merge throttle time across primary shard |                         |     0           |     0           |    0       |    min |    0.00% |
|               Median cumulative merge throttle time across primary shard |                         |     0           |     0           |    0       |    min |    0.00% |
|                  Max cumulative merge throttle time across primary shard |                         |    15.859       |    15.3762      |   -0.48287 |    min |   -3.04% |
|                                Cumulative refresh time of primary shards |                         |     1.61935     |     1.66042     |    0.04107 |    min |   +2.54% |
|                               Cumulative refresh count of primary shards |                         |   163           |   162           |   -1       |        |   -0.61% |
|                         Min cumulative refresh time across primary shard |                         |     0           |     0           |    0       |    min |    0.00% |
|                      Median cumulative refresh time across primary shard |                         |     0           |     0           |    0       |    min |    0.00% |
|                         Max cumulative refresh time across primary shard |                         |     1.61935     |     1.66042     |    0.04107 |    min |   +2.54% |
|                                  Cumulative flush time of primary shards |                         |     0.0152333   |     0.000966667 |   -0.01427 |    min |  -93.65% |
|                                 Cumulative flush count of primary shards |                         |    14           |    13           |   -1       |        |   -7.14% |
|                           Min cumulative flush time across primary shard |                         |     3.33333e-05 |     3.33333e-05 |    0       |    min |    0.00% |
|                        Median cumulative flush time across primary shard |                         |     3.33333e-05 |     5e-05       |    2e-05   |    min |  +50.00% |
|                           Max cumulative flush time across primary shard |                         |     0.0147667   |     0.000416667 |   -0.01435 |    min |  -97.18% |
|                                                  Total Young Gen GC time |                         |    36.007       |    37.033       |    1.026   |      s |   +2.85% |
|                                                 Total Young Gen GC count |                         |  1598           |  1604           |    6       |        |   +0.38% |
|                                                    Total Old Gen GC time |                         |     0           |     0           |    0       |      s |    0.00% |
|                                                   Total Old Gen GC count |                         |     0           |     0           |    0       |        |    0.00% |
|                                                               Store size |                         |     4.64955     |     4.73673     |    0.08718 |     GB |   +1.87% |
|                                                            Translog size |                         |     6.65896e-07 |     6.65896e-07 |    0       |     GB |    0.00% |
|                                                   Heap used for segments |                         |     0           |     0           |    0       |     MB |    0.00% |
|                                                 Heap used for doc values |                         |     0           |     0           |    0       |     MB |    0.00% |
|                                                      Heap used for terms |                         |     0           |     0           |    0       |     MB |    0.00% |
|                                                      Heap used for norms |                         |     0           |     0           |    0       |     MB |    0.00% |
|                                                     Heap used for points |                         |     0           |     0           |    0       |     MB |    0.00% |
|                                              Heap used for stored fields |                         |     0           |     0           |    0       |     MB |    0.00% |
|                                                            Segment count |                         |     6           |    20           |   14       |        | +233.33% |
|                                              Total Ingest Pipeline count |                         |     0           |     0           |    0       |        |    0.00% |
|                                               Total Ingest Pipeline time |                         |     0           |     0           |    0       |     ms |    0.00% |
|                                             Total Ingest Pipeline failed |                         |     0           |     0           |    0       |        |    0.00% |
|                                                           Min Throughput |                   index | 82125.6         | 82283.5         |  157.844   | docs/s |   +0.19% |
|                                                          Mean Throughput |                   index | 87956.1         | 88536.5         |  580.374   | docs/s |   +0.66% |
|                                                        Median Throughput |                   index | 88444.2         | 88938.9         |  494.711   | docs/s |   +0.56% |
|                                                           Max Throughput |                   index | 93514.4         | 92704.2         | -810.273   | docs/s |   -0.87% |
|                                                  50th percentile latency |                   index |   851.696       |   835.099       |  -16.5971  |     ms |   -1.95% |
|                                                  90th percentile latency |                   index |  1113.73        |  1101.3         |  -12.426   |     ms |   -1.12% |
|                                                  99th percentile latency |                   index |  2823.29        |  2881.95        |   58.6595  |     ms |   +2.08% |
|                                                99.9th percentile latency |                   index |  4246.65        |  4372.74        |  126.094   |     ms |   +2.97% |
|                                               99.99th percentile latency |                   index |  5733.52        |  5871.27        |  137.75    |     ms |   +2.40% |
|                                                 100th percentile latency |                   index |  5980.77        |  6076.45        |   95.6851  |     ms |   +1.60% |
|                                             50th percentile service time |                   index |   851.235       |   834.796       |  -16.4386  |     ms |   -1.93% |
|                                             90th percentile service time |                   index |  1122.35        |  1102.6         |  -19.7471  |     ms |   -1.76% |
|                                             99th percentile service time |                   index |  2823.5         |  2879.83        |   56.3283  |     ms |   +1.99% |
|                                           99.9th percentile service time |                   index |  4220.14        |  4380.22        |  160.079   |     ms |   +3.79% |
|                                          99.99th percentile service time |                   index |  5733.52        |  5871.27        |  137.75    |     ms |   +2.40% |
|                                            100th percentile service time |                   index |  5980.77        |  6076.45        |   95.6851  |     ms |   +1.60% |
|                                                               error rate |                   index |     0           |     0           |    0       |      % |    0.00% |
|                                                           Min Throughput |                 default |    72.7266      |    72.2107      |   -0.51593 |  ops/s |   -0.71% |
|                                                          Mean Throughput |                 default |    72.7266      |    72.2107      |   -0.51593 |  ops/s |   -0.71% |
|                                                        Median Throughput |                 default |    72.7266      |    72.2107      |   -0.51593 |  ops/s |   -0.71% |
|                                                           Max Throughput |                 default |    72.7266      |    72.2107      |   -0.51593 |  ops/s |   -0.71% |
|                                                  50th percentile latency |                 default |    11.3524      |    11.2259      |   -0.12646 |     ms |   -1.11% |
|                                                  90th percentile latency |                 default |    11.9501      |    11.6014      |   -0.34869 |     ms |   -2.92% |
|                                                  99th percentile latency |                 default |    17.505       |    11.7868      |   -5.71829 |     ms |  -32.67% |
|                                                 100th percentile latency |                 default |    17.6197      |    12.5464      |   -5.07328 |     ms |  -28.79% |
|                                             50th percentile service time |                 default |    11.3524      |    11.2259      |   -0.12646 |     ms |   -1.11% |
|                                             90th percentile service time |                 default |    11.9501      |    11.6014      |   -0.34869 |     ms |   -2.92% |
|                                             99th percentile service time |                 default |    17.505       |    11.7868      |   -5.71829 |     ms |  -32.67% |
|                                            100th percentile service time |                 default |    17.6197      |    12.5464      |   -5.07328 |     ms |  -28.79% |
|                                                               error rate |                 default |     0           |     0           |    0       |      % |    0.00% |
|                                                           Min Throughput |              default_1k |    29.1361      |    28.604       |   -0.53209 |  ops/s |   -1.83% |
|                                                          Mean Throughput |              default_1k |    29.5797      |    29.12        |   -0.45968 |  ops/s |   -1.55% |
|                                                        Median Throughput |              default_1k |    29.6672      |    29.2112      |   -0.45602 |  ops/s |   -1.54% |
|                                                           Max Throughput |              default_1k |    29.8482      |    29.4536      |   -0.39462 |  ops/s |   -1.32% |
|                                                  50th percentile latency |              default_1k |    32.2199      |    32.4703      |    0.25035 |     ms |   +0.78% |
|                                                  90th percentile latency |              default_1k |    33.0007      |    33.6026      |    0.6019  |     ms |   +1.82% |
|                                                  99th percentile latency |              default_1k |    51.6371      |    34.9506      |  -16.6865  |     ms |  -32.31% |
|                                                 100th percentile latency |              default_1k |    54.7434      |    41.9825      |  -12.7608  |     ms |  -23.31% |
|                                             50th percentile service time |              default_1k |    32.2199      |    32.4703      |    0.25035 |     ms |   +0.78% |
|                                             90th percentile service time |              default_1k |    33.0007      |    33.6026      |    0.6019  |     ms |   +1.82% |
|                                             99th percentile service time |              default_1k |    51.6371      |    34.9506      |  -16.6865  |     ms |  -32.31% |
|                                            100th percentile service time |              default_1k |    54.7434      |    41.9825      |  -12.7608  |     ms |  -23.31% |
|                                                               error rate |              default_1k |     0           |     0           |    0       |      % |    0.00% |
|                                                           Min Throughput | date-histo-entire-range |   317.361       |   325.893       |    8.5322  |  ops/s |   +2.69% |
|                                                          Mean Throughput | date-histo-entire-range |   317.361       |   325.893       |    8.5322  |  ops/s |   +2.69% |
|                                                        Median Throughput | date-histo-entire-range |   317.361       |   325.893       |    8.5322  |  ops/s |   +2.69% |
|                                                           Max Throughput | date-histo-entire-range |   317.361       |   325.893       |    8.5322  |  ops/s |   +2.69% |
|                                                  50th percentile latency | date-histo-entire-range |     2.66948     |     2.73271     |    0.06323 |     ms |   +2.37% |
|                                                  90th percentile latency | date-histo-entire-range |     2.94906     |     3.03944     |    0.09037 |     ms |   +3.06% |
|                                                  99th percentile latency | date-histo-entire-range |     3.67115     |     3.5255      |   -0.14565 |     ms |   -3.97% |
|                                                 100th percentile latency | date-histo-entire-range |     3.7502      |     3.67067     |   -0.07953 |     ms |   -2.12% |
|                                             50th percentile service time | date-histo-entire-range |     2.66948     |     2.73271     |    0.06323 |     ms |   +2.37% |
|                                             90th percentile service time | date-histo-entire-range |     2.94906     |     3.03944     |    0.09037 |     ms |   +3.06% |
|                                             99th percentile service time | date-histo-entire-range |     3.67115     |     3.5255      |   -0.14565 |     ms |   -3.97% |
|                                            100th percentile service time | date-histo-entire-range |     3.7502      |     3.67067     |   -0.07953 |     ms |   -2.12% |
|                                                               error rate | date-histo-entire-range |     0           |     0           |    0       |      % |    0.00% |
|                                                           Min Throughput |          esql-fetch-500 |     8.95722     |     9.05782     |    0.1006  |  ops/s |   +1.12% |
|                                                          Mean Throughput |          esql-fetch-500 |     9.60207     |     9.75112     |    0.14905 |  ops/s |   +1.55% |
|                                                        Median Throughput |          esql-fetch-500 |     9.65652     |     9.83393     |    0.17741 |  ops/s |   +1.84% |
|                                                           Max Throughput |          esql-fetch-500 |    10.0294      |    10.1784      |    0.14902 |  ops/s |   +1.49% |
|                                                  50th percentile latency |          esql-fetch-500 |    90.0991      |    89.9754      |   -0.12368 |     ms |   -0.14% |
|                                                  90th percentile latency |          esql-fetch-500 |    97.2384      |    94.2602      |   -2.97815 |     ms |   -3.06% |
|                                                  99th percentile latency |          esql-fetch-500 |   108.207       |   109.403       |    1.19617 |     ms |   +1.11% |
|                                                 100th percentile latency |          esql-fetch-500 |   110.563       |   118.274       |    7.71101 |     ms |   +6.97% |
|                                             50th percentile service time |          esql-fetch-500 |    90.0991      |    89.9754      |   -0.12368 |     ms |   -0.14% |
|                                             90th percentile service time |          esql-fetch-500 |    97.2384      |    94.2602      |   -2.97815 |     ms |   -3.06% |
|                                             99th percentile service time |          esql-fetch-500 |   108.207       |   109.403       |    1.19617 |     ms |   +1.11% |
|                                            100th percentile service time |          esql-fetch-500 |   110.563       |   118.274       |    7.71101 |     ms |   +6.97% |
|                                                               error rate |          esql-fetch-500 |     0           |     0           |    0       |      % |    0.00% |

Cumulative merging is ~9% lower.

@martijnvg martijnvg closed this Apr 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants