Skip to content

ESQL: GroupedTopNOperator benchmark#144003

Merged
ivancea merged 36 commits intoelastic:mainfrom
ivancea:grouped-topn-benchmark
Mar 18, 2026
Merged

ESQL: GroupedTopNOperator benchmark#144003
ivancea merged 36 commits intoelastic:mainfrom
ivancea:grouped-topn-benchmark

Conversation

@ivancea
Copy link
Copy Markdown
Contributor

@ivancea ivancea commented Mar 11, 2026

Operator added in #143476

Similar structure as TopNBenchmark, with similar parameters to keep the comparison consistent.

Benchmark results for some similar cases (Compared with TopN):

TopNBenchmark
Benchmark                                (data)  (sortedInput)  (topCount)  Mode  Cnt   Score   Error  Units
TopNBenchmark.run  longs_asc_and_bytes_refs_asc          false          10  avgt    7  56.292 ± 0.922  ns/op
TopNBenchmark.run  longs_asc_and_bytes_refs_asc          false        1000  avgt    7  54.866 ± 1.091  ns/op

GroupedTopNBenchmark
Benchmark                                       (data)  (groupCount)  (groupKeys)  (topCount)  Mode  Cnt    Score    Error  Units
GroupedTopNBenchmark.run  longs_asc_and_bytes_refs_asc             1        longs          10  avgt    7  103.886 ± 10.041  ns/op
GroupedTopNBenchmark.run  longs_asc_and_bytes_refs_asc             1        longs        1000  avgt    7  103.321 ±  5.021  ns/op
GroupedTopNBenchmark.run  longs_asc_and_bytes_refs_asc           100        longs          10  avgt    7  118.975 ±  7.685  ns/op
GroupedTopNBenchmark.run  longs_asc_and_bytes_refs_asc           100        longs        1000  avgt    7  205.589 ± 30.058  ns/op

ivancea and others added 30 commits March 3, 2026 15:02
# Conflicts:
#	test/framework/src/main/java/org/elasticsearch/common/util/MockBigArrays.java
#	x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/operator/topn/TopNOperatorTests.java
@ivancea ivancea requested a review from Copilot March 11, 2026 10:40
@ivancea ivancea added >non-issue Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) :Analytics/ES|QL AKA ESQL v9.4.0 labels Mar 11, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new JMH benchmark for the ESQL GroupedTopNOperator (LIMIT BY) following the existing TopNBenchmark structure, plus a small test harness to run the benchmark’s selfTest() under the test suite.

Changes:

  • Introduce GroupedTopNBenchmark JMH benchmark with parameters for sort keys, group keys, and sizes.
  • Add GroupedTopNBenchmarkTests to execute GroupedTopNBenchmark.selfTest().

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
benchmarks/src/main/java/org/elasticsearch/benchmark/_nightly/esql/GroupedTopNBenchmark.java Implements the grouped top-N benchmark and its self-test.
benchmarks/src/test/java/org/elasticsearch/benchmark/_nightly/esql/GroupedTopNBenchmarkTests.java Adds an ESTestCase wrapper to run the benchmark self-test.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@ivancea ivancea marked this pull request as ready for review March 12, 2026 16:54
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-analytical-engine (Team:Analytics)

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 12, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fdc7eea7-1551-4e27-a2b7-2221471410e7

📥 Commits

Reviewing files that changed from the base of the PR and between 498aa28 and b92407e.

📒 Files selected for processing (3)
  • benchmarks/src/main/java/org/elasticsearch/benchmark/_nightly/esql/GroupedTopNBenchmark.java
  • benchmarks/src/main/java/org/elasticsearch/benchmark/_nightly/esql/TopNBenchmark.java
  • benchmarks/src/test/java/org/elasticsearch/benchmark/_nightly/esql/GroupedTopNBenchmarkTests.java

📝 Walkthrough

Walkthrough

This change introduces a new JMH benchmark class GroupedTopNBenchmark for testing Elasticsearch ESQL grouped top-N operations. The benchmark features parametrized configurations for data shape, top-N count, group count, and group key types, with helper methods for constructing operators, pages, and blocks. An existing TopNBenchmark class is updated to improve resource management using try-finally blocks and a shared constant for data parsing. A corresponding test class GroupedTopNBenchmarkTests is added to validate the new benchmark via its self-test method.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • 🛠️ Update Documentation: Commit on current branch
  • 🛠️ Update Documentation: Create PR
📝 Coding Plan
  • ❌ Error while generating coding plan for human review comments - (🔄 Check again to try again)

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 12, 2026

Planning has been disabled by your administrator. You can enable it by adding the following to your .coderabbit.yaml:

issue_enrichment:
  planning:
    enabled: true

@ivancea ivancea requested review from ncordon and nik9000 March 13, 2026 11:57
Copy link
Copy Markdown
Member

@nik9000 nik9000 left a comment

Choose a reason for hiding this comment

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

Looks good to me. Let's get it in.

It isn't a surprise that it's slower to topn with groups. It's slower to agg with groups too.

@nik9000
Copy link
Copy Markdown
Member

nik9000 commented Mar 18, 2026

And we can and will optimize this more as time goes on.

@ivancea ivancea merged commit 406d2fd into elastic:main Mar 18, 2026
36 checks passed
@ivancea ivancea deleted the grouped-topn-benchmark branch March 18, 2026 16:17
michalborek pushed a commit to michalborek/elasticsearch that referenced this pull request Mar 23, 2026
Operator added in elastic#143476

Similar structure as TopNBenchmark, with similar parameters to keep the comparison consistent.

Benchmark results for some similar cases (Compared with TopN):
```
TopNBenchmark
Benchmark                                (data)  (sortedInput)  (topCount)  Mode  Cnt   Score   Error  Units
TopNBenchmark.run  longs_asc_and_bytes_refs_asc          false          10  avgt    7  56.292 ± 0.922  ns/op
TopNBenchmark.run  longs_asc_and_bytes_refs_asc          false        1000  avgt    7  54.866 ± 1.091  ns/op

GroupedTopNBenchmark
Benchmark                                       (data)  (groupCount)  (groupKeys)  (topCount)  Mode  Cnt    Score    Error  Units
GroupedTopNBenchmark.run  longs_asc_and_bytes_refs_asc             1        longs          10  avgt    7  103.886 ± 10.041  ns/op
GroupedTopNBenchmark.run  longs_asc_and_bytes_refs_asc             1        longs        1000  avgt    7  103.321 ±  5.021  ns/op
GroupedTopNBenchmark.run  longs_asc_and_bytes_refs_asc           100        longs          10  avgt    7  118.975 ±  7.685  ns/op
GroupedTopNBenchmark.run  longs_asc_and_bytes_refs_asc           100        longs        1000  avgt    7  205.589 ± 30.058  ns/op
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Analytics/ES|QL AKA ESQL >non-issue Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants