Skip to content

ES819 Binary doc values: compact doc offsets using bit packing - #142772

Merged
martijnvg merged 15 commits into
elastic:mainfrom
martijnvg:binary_doc_values_encode_offsets_using_bitpacking
Feb 25, 2026
Merged

martijnvg merged 15 commits into
elastic:mainfrom
martijnvg:binary_doc_values_encode_offsets_using_bitpacking

Conversation

@martijnvg

@martijnvg martijnvg commented Feb 20, 2026 •

Copy link
Copy Markdown
Member

The doc offsets are currently being delta encoded into encoded as grouped vints. For some queries reading grouped vints is a relative expensive operations. This PR changes grouped vint encoding with a more simplistic bit packing method.

This change results in slightly lower disk usage and lower query latencies in cases binary doc values is used. In case of clickbench benchmark, a number of queries showed lower latencies: q28 from 16s to 13s, q27 from 715 ms to 551 ms, q39 from 1065ms to 802 ms.

Because this PR makes a format a new doc values format is added that extends from ES819TSDBDocValuesFormat. Only new indices will use this new doc value format. This is required because otherwise in mixed clusters bwc doc values format issues will still occur (even with a new codec version). This is because there is no mechanism that prevents shard recovery from a newer node with higher codec version to an older node with lower codec version. Tying the new doc values format to index version avoids this problem.

The doc offsets are currently being delta encoded into encoded as grouped vints.
For some queries reading grouped vints is a relative expensive operations.
This PR changes grouped vint encoding with a more simplistic bit packing method.

Because this PR makes a format a new new codec version is added and a bwc test
is added to TsdbDocValueBwcTests (and version2 of doc values format was forked in test code).
@elasticsearchmachine

Copy link
Copy Markdown
Collaborator

Hi @martijnvg, I've created a changelog YAML for you.

@martijnvg

Copy link
Copy Markdown
Member Author

Buildkite benchmark this with clickbench-columnar-mode please

…ew codec that uses BITPACKING codec.

Before the grouped vint or bitpacking compression was picked based on codec version, but that doesn't work well in mixed clusters.

The new codec is now used based on index version and that should work well in mixed clusters regardless of whether shard recovery is happening.
@martijnvg
martijnvg force-pushed the binary_doc_values_encode_offsets_using_bitpacking branch from 64bc91e to 7631d66 Compare February 21, 2026 16:43
@martijnvg

Copy link
Copy Markdown
Member Author

Buildkite benchmark this with clickbench-columnar-mode please

@martijnvg

Copy link
Copy Markdown
Member Author

Buildkite benchmark this with clickbench-columnar-mode please

@martijnvg
martijnvg marked this pull request as ready for review February 23, 2026 12:39
@elasticsearchmachine

Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-storage-engine (Team:StorageEngine)

@parkertimmins

Copy link
Copy Markdown
Contributor

I didn't finish reviewing this PR. Looks great so far, but I want to understand more about the indexing versioning before approving.

@martijnvg

Copy link
Copy Markdown
Member Author

but I want to understand more about the indexing versioning before approving.

Something that I forgot to point out is that with the third commit, the CI ran all tests, but even with codec version check the serverless upgrade tests fail: https://buildkite.com/elastic/elasticsearch-serverless-es-pr-check/builds/64030

This made me realize the problem with codec version and why we can't rely on it for bwc checks.

if (indexCreatedVersion.onOrAfter(IndexVersions.TIME_SERIES_DOC_VALUES_FORMAT_VERSION_3)) {
return new ES819Version3TSDBDocValuesFormat(useLargeBlockSize);
} else {
return useLargeBlockSize ? ES819TSDBDocValuesFormat.getInstance(true) : ES819TSDBDocValuesFormat.getInstance(false);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: ES819TSDBDocValuesFormat.getInstance(useLargeBlockSize)

@parkertimmins parkertimmins left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@martijnvg
martijnvg force-pushed the binary_doc_values_encode_offsets_using_bitpacking branch from 496847d to 9ebbe3c Compare February 24, 2026 19:31
@martijnvg

Copy link
Copy Markdown
Member Author

Buildkite benchmark this with clickbench-columnar-mode please

@elasticmachine

elasticmachine commented Feb 24, 2026 •

Copy link
Copy Markdown
Collaborator

💚 Build Succeeded

This build ran two clickbench-columnar-mode benchmarks to evaluate performance impact of this PR.

History

@martijnvg
martijnvg enabled auto-merge (squash) February 25, 2026 09:29
@martijnvg
martijnvg merged commit a201f5c into elastic:main Feb 25, 2026
35 checks passed
smalyshev pushed a commit to smalyshev/elasticsearch that referenced this pull request Feb 25, 2026
…ic#142772)

The doc offsets are currently being delta encoded into encoded as grouped vints.
For some queries reading grouped vints is a relative expensive operations.
This PR changes grouped vint encoding with a more simplistic bit packing method.

Because this PR makes a format a new doc values format is added that extends from ES819TSDBDocValuesFormat. Only new indices will use this new doc value format. This is required because otherwise in mixed clusters bwc doc values format issues will still occur (even with a new codec version). This is because there is no mechanism that prevents shard recovery from a newer node with higher codec version to an older node with lower codec version. Tying the new doc values format to index version avoids this problem.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants