Skip to content

Commit 71957ca

Browse files
authored
Add fast path for single value in VALUES aggregator (elastic#130510)
This change introduces a fast path for the VALUES aggregator in the single-value case. For the first value seen in each group, we add it the new big array without touching the hash. For subsequent values, if they are the same as the current value, we skip them; if they differ, we trigger the slow path and add them to the hash. This optimization speeds up VALUES when the number of groups is large and most groups have only one value. Before: ``` Benchmark (dataType) (groups) Mode Cnt Score Error Units ValuesAggregatorBenchmark.run BytesRef 1 avgt 3 177.756 ± 2.111 ms/op ValuesAggregatorBenchmark.run BytesRef 1000 avgt 3 126.174 ± 0.431 ms/op ValuesAggregatorBenchmark.run BytesRef 1000000 avgt 3 66920.144 ± 53588.490 ms/op ``` After: ``` Benchmark (dataType) (groups) Mode Cnt Score Error Units ValuesAggregatorBenchmark.run BytesRef 1 avgt 3 180.269 ± 4.019 ms/op ValuesAggregatorBenchmark.run BytesRef 1000 avgt 3 107.051 ± 3.149 ms/op ValuesAggregatorBenchmark.run BytesRef 1000000 avgt 3 26277.863 ± 7214.319 ms/op ```
1 parent 83b05c6 commit 71957ca

File tree

7 files changed

+1279
-961
lines changed

7 files changed

+1279
-961
lines changed

docs/changelog/130510.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 130510
2+
summary: Add fast path for single value in VALUES aggregator
3+
area: ES|QL
4+
type: enhancement
5+
issues: []

x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/aggregation/ValuesBytesRefAggregator.java

Lines changed: 199 additions & 166 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/aggregation/ValuesDoubleAggregator.java

Lines changed: 192 additions & 135 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/aggregation/ValuesFloatAggregator.java

Lines changed: 200 additions & 142 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/aggregation/ValuesIntAggregator.java

Lines changed: 200 additions & 142 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/aggregation/ValuesLongAggregator.java

Lines changed: 192 additions & 135 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)