First step optimizing tsdb doc values codec merging. (#125403)

The doc values codec iterates a few times over the doc value instance that needs to be written to disk. In case when merging and index sorting is enabled, this is much more expensive, as each time the doc values instance is iterated a merge sorting is performed (in order to get the doc ids of new segment in order of index sorting).

There are several reasons why the doc value instance is iterated multiple times:
* To compute stats (num values, number of docs with value) required for writing values to disk.
* To write bitset that indicate which documents have a value. (indexed disi, jump table)
* To write the actual values to disk.
* To write the addresses to disk (in case docs have multiple values)

This applies for numeric doc values, but also for the ordinals of sorted (set) doc values.

This PR addresses solving the first reason why doc value instance needs to be iterated. This is done only when in case of merging and when the segments to be merged with are also of type es87 doc values, codec version is the same and there are no deletes. Note this optimized merged is behind a feature flag for now.
This commit is contained in:
Martijn van Groningen 2025-04-09 07:50:16 +02:00 committed by GitHub
parent 4f9bfb0a3c
commit 065c5830cb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 2394 additions and 102 deletions

View file

@ -476,4 +476,5 @@ module org.elasticsearch.server {
exports org.elasticsearch.monitor.metrics;
exports org.elasticsearch.plugins.internal.rewriter to org.elasticsearch.inference;
exports org.elasticsearch.lucene.util.automaton;
exports org.elasticsearch.index.codec.perfield;
}