Skip to content

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

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

perf: do not match each token in aggregation#474
dkharms wants to merge 2 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 70.97%. Comparing base (9506076) to head (d4289c3).
⚠️ Report is 1 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%   70.97%   +0.29%     
==========================================
  Files         233      232       -1     
  Lines       18399    18306      -93     
==========================================
- Hits        13005    12993      -12     
+ Misses       4416     4339      -77     
+ Partials      978      974       -4     

☔ 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
@dkharms

dkharms commented Jul 27, 2026

Copy link
Copy Markdown
Member Author

@seqbenchbot up main bulk

@seqbenchbot

seqbenchbot commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

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

Your request was successfully served.
Identificator for your ongoing benchmark - d9f37ee3.

Here is a list of helpful links:

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

Have a great time!

@ozontech ozontech deleted a comment from github-actions Bot Jul 27, 2026
@dkharms

dkharms commented Jul 27, 2026

Copy link
Copy Markdown
Member Author

@seqbenchbot down d9f37ee3

@seqbenchbot

seqbenchbot commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

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

The benchmark with identificator d9f37ee3 was 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
base comp diff base comp diff base comp diff base comp diff base comp diff base comp diff
bulk
warm 23.45 24.94 +6.37% 6.87 7.08 +2.98% 21.00 22.00 +4.76% 38.50 39.00 +1.30% 50.00 51.00 +2.00% 60000.00 60068.00 +0.11%

Have a great time!

@dkharms

dkharms commented Jul 27, 2026

Copy link
Copy Markdown
Member Author

@seqbenchbot up main bulk

@seqbenchbot

seqbenchbot commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

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

Your request was successfully served.
Identificator for your ongoing benchmark - c6db62b9.

Here is a list of helpful links:

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

Have a great time!

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