Skip to content

perf: do not match each token in aggregation - #474

Open
dkharms wants to merge 3 commits into
mainfrom
0-skip-matching
Open

perf: do not match each token in aggregation#474
dkharms wants to merge 3 commits into
mainfrom
0-skip-matching

Conversation

@dkharms

@dkharms dkharms commented Jul 24, 2026

Copy link
Copy Markdown
Member

Description

When getting tokens for aggregation, we scan each token and checking it against * -- so basically, useless computations and IO (we have to load+unpack token blocks). I suggest to return range [firstTID; lastTID].

Obviously, this optimization will have more impact on high-cardinality fields that span over several token blocks (like remote_addr or something).

I will collect better measurements but for cold queries (flushed userspace cache and page cache) I got following results:

# query: * | group by (remote_addr) | count

# Before (restart seq-db, flush page cache)
% hyperfine -r=1 'curl --json @search.json http://localhost:9002/complex-search'
Benchmark 1: curl --json @search.json http://localhost:9002/complex-search
  Time (abs ≡):         2.561 s               [User: 0.003 s, System: 0.010 s]

% hyperfine -r=10 'curl --json @search.json http://localhost:9002/complex-search'
Benchmark 1: curl --json @search.json http://localhost:9002/complex-search
  Time (mean ± σ):      1.222 s ±  0.046 s    [User: 0.004 s, System: 0.006 s]
  Range (min … max):    1.163 s …  1.279 s    10 runs

# After (restart seq-db, flush page cache)
% hyperfine -r=1 'curl --json @search.json http://localhost:9002/complex-search'
Benchmark 1: curl --json @search.json http://localhost:9002/complex-search
  Time (abs ≡):         1.440 s               [User: 0.003 s, System: 0.010 s]

% hyperfine -r=10 'curl --json @search.json http://localhost:9002/complex-search'
Benchmark 1: curl --json @search.json http://localhost:9002/complex-search
  Time (mean ± σ):      1.208 s ±  0.051 s    [User: 0.004 s, System: 0.006 s]
  Range (min … max):    1.128 s …  1.277 s    10 runs

  • I have read and followed all requirements in CONTRIBUTING.md;
  • I used LLM/AI assistance to make this pull request;

If you have used LLM/AI assistance please provide model name and full prompt:

Model: {{model-name}}
Prompt: {{prompt}}

@dkharms dkharms added the performance Features or improvements that positively affect seq-db performance label Jul 24, 2026
@codecov-commenter

codecov-commenter commented Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.75000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 71.11%. Comparing base (9506076) to head (1651f58).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
frac/processor/eval_tree.go 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #474      +/-   ##
==========================================
+ Coverage   70.68%   71.11%   +0.43%     
==========================================
  Files         233      232       -1     
  Lines       18399    18417      +18     
==========================================
+ Hits        13005    13098      +93     
+ Misses       4416     4339      -77     
- Partials      978      980       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

Copy link
Copy Markdown
Contributor

🔴 Performance Degradation

Some benchmarks have degraded compared to the previous run.
Click on Show table button to see full list of degraded benchmarks.

Show table
Name Previous Current Ratio Verdict
Indexer-4 4ad8f1 900dcf
677543019.00 B/op 771867370.00 B/op 1.14 🔴

@eguguchkin
eguguchkin requested review from cheb0 and forshev July 27, 2026 10:56
@ozontech ozontech deleted a comment from seqbenchbot Jul 27, 2026
@ozontech ozontech deleted a comment from seqbenchbot Jul 27, 2026
@ozontech ozontech deleted a comment from seqbenchbot Jul 27, 2026
@ozontech ozontech deleted a comment from seqbenchbot Jul 27, 2026
@ozontech ozontech deleted a comment from github-actions Bot Jul 27, 2026
@ozontech ozontech deleted a comment from seqbenchbot Jul 28, 2026
@ozontech ozontech deleted a comment from seqbenchbot Jul 28, 2026
@ozontech ozontech deleted a comment from seqbenchbot Jul 28, 2026
@ozontech ozontech deleted a comment from seqbenchbot Jul 28, 2026
@ozontech ozontech deleted a comment from seqbenchbot Jul 28, 2026
@ozontech ozontech deleted a comment from seqbenchbot Jul 28, 2026
@ozontech ozontech deleted a comment from seqbenchbot Jul 28, 2026
@ozontech ozontech deleted a comment from seqbenchbot Jul 28, 2026
@ozontech ozontech deleted a comment from seqbenchbot Jul 28, 2026
@ozontech ozontech deleted a comment from seqbenchbot Jul 28, 2026
@ozontech ozontech deleted a comment from seqbenchbot Jul 28, 2026
@ozontech ozontech deleted a comment from seqbenchbot Jul 28, 2026
@ozontech ozontech deleted a comment from seqbenchbot Jul 28, 2026
@ozontech ozontech deleted a comment from seqbenchbot Jul 28, 2026
@ozontech ozontech deleted a comment from seqbenchbot Jul 28, 2026
@ozontech ozontech deleted a comment from seqbenchbot Jul 28, 2026
@ozontech ozontech deleted a comment from seqbenchbot Jul 28, 2026
@ozontech ozontech deleted a comment from seqbenchbot Jul 28, 2026
@ozontech ozontech deleted a comment from seqbenchbot Jul 28, 2026
@ozontech ozontech deleted a comment from seqbenchbot Jul 28, 2026
@ozontech ozontech deleted a comment from seqbenchbot Jul 28, 2026
@ozontech ozontech deleted a comment from seqbenchbot Jul 28, 2026
@seqbenchbot

seqbenchbot commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Nice, @dkharms <(-^,^-)=b!

Started benchmark cf3cffd6:

  • scenario bulk;
  • against main;
  • running for 5m0s;

I'll post the statistics here once it finishes.
To end it early, run @seqbenchbot stop cf3cffd6.

Here is a list of helpful links:

  • Take a look at Grafana dashboard;
  • Live-tailing logs are also available;

Have a great time!

@seqbenchbot

Copy link
Copy Markdown
Collaborator

Nice, @dkharms <(-^,^-)=b!

Benchmark cf3cffd6 (scenario bulk) has finished.
I've prepared a summary for you. Click on Show summary button to see it:

Show summary
Query Type mean (ms) stddev (ms) p(50) (ms) p(95) (ms) p(99) (ms) iterations
bulk
warm 27.23 7.76 25.00 41.00 58.00 10785.00

Compare it against another run with @seqbenchbot compare cf3cffd6 <other-id>.

@dkharms

dkharms commented Jul 28, 2026

Copy link
Copy Markdown
Member Author

@seqbenchbot compare 41da199f cf3cffd6

@seqbenchbot

seqbenchbot commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Nice, @dkharms <(-^,^-)=b!

Comparison of baseline 41da199f against comparison cf3cffd6:

Show comparison
Query Type mean (ms) stddev (ms) p(50) (ms) p(95) (ms) p(99) (ms) iterations
base comp diff base comp diff base comp diff base comp diff base comp diff base comp diff
bulk
warm 27.13 27.23 +0.37% 7.72 7.76 +0.40% 25.00 25.00 0.00% 40.00 41.00 +2.50% 58.00 58.00 0.00% 10785.00 10785.00 0.00%

See both runs overlaid (baseline aligned to comparison) on the Grafana dashboard.

Have a great time!

@dkharms

dkharms commented Jul 28, 2026

Copy link
Copy Markdown
Member Author

@seqbenchbot start bulk 0-skip-matching --duration=5m

@seqbenchbot

seqbenchbot commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Nice, @dkharms <(-^,^-)=b!

Started benchmark 4818607c:

  • scenario bulk;
  • against 0-skip-matching;
  • running for 5m0s;

I'll post the statistics here once it finishes.
To end it early, run @seqbenchbot stop 4818607c.

Here is a list of helpful links:

  • Take a look at Grafana dashboard;
  • Live-tailing logs are also available;

Have a great time!

@seqbenchbot

Copy link
Copy Markdown
Collaborator

Nice, @dkharms <(-^,^-)=b!

Benchmark 4818607c (scenario bulk) has finished.
I've prepared a summary for you. Click on Show summary button to see it:

Show summary
Query Type mean (ms) stddev (ms) p(50) (ms) p(95) (ms) p(99) (ms) iterations
bulk
warm 27.16 7.65 25.00 40.00 58.00 10785.00

Compare it against another run with @seqbenchbot compare 4818607c <other-id>.

@ozontech ozontech deleted a comment from seqbenchbot Jul 28, 2026
@ozontech ozontech deleted a comment from seqbenchbot Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance Features or improvements that positively affect seq-db performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants