Skip to content

Introduce SwissTable-based hashing (LongSwissHash, BytesRefSwissHash) for ES|QL STATS#139343

Merged
ChrisHegarty merged 133 commits intoelastic:mainfrom
MattAlp:swiss-table-proto
Jan 6, 2026
Merged

Introduce SwissTable-based hashing (LongSwissHash, BytesRefSwissHash) for ES|QL STATS#139343
ChrisHegarty merged 133 commits intoelastic:mainfrom
MattAlp:swiss-table-proto

Conversation

@ChrisHegarty
Copy link
Copy Markdown
Contributor

@ChrisHegarty ChrisHegarty commented Dec 11, 2025

This PR introduces two new hash-table implementations - LongSwissHash and BytesRefSwissHash - as the first step in improving the performance and memory behavior of the ES|QL STATS operator. These structures are based on SwissTable-style open addressing with SIMD-friendly control bytes, offering significantly better probe behavior and cache locality than the current hash implementation.

A larger multi-step plan and follow-up work are tracked in the corresponding meta issue. #138799

What this PR includes

  • New SwissTable-inspired hash structures:
    • LongSwissHash for long keys
    • BytesRefSwissHash for BytesRef keys
  • SIMD control-byte probing with boundary mirroring
  • Page-backed storage for keys and IDs with circuit-breaker accounting
  • Correct handling of probe sequences, wrap-around, and high-collision cases
  • Initial suite of correctness tests:
    • add/find semantics
    • rehash correctness
    • boundary mirroring
    • circuit-breaker interaction

These structures form the foundation for replacing the STATS operator’s existing hash table with something faster, more predictable, and more memory-efficient under high cardinality. The implementation follows the same principles as SwissTable/Abseil, adapted for Elasticsearch’s memory model.

swiss_heatmap

Contributors: @ChrisHegarty @nik9000 @MattAlp

@ChrisHegarty
Copy link
Copy Markdown
Contributor Author

Buildkite benchmark this with clickbench please

@ChrisHegarty
Copy link
Copy Markdown
Contributor Author

Buildkite benchmark this with clickbench please

@ChrisHegarty
Copy link
Copy Markdown
Contributor Author

Buildkite benchmark this with esql please

@elasticmachine
Copy link
Copy Markdown
Collaborator

elasticmachine commented Jan 5, 2026

💚 Build Succeeded

This build ran two esql benchmarks to evaluate performance impact of this PR.

History

cc @MattAlp @ChrisHegarty

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Analytics/Compute Engine Analytics in ES|QL :Analytics/ES|QL AKA ESQL >enhancement 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.

6 participants