Skip to content

perf: enhance tokens block memory usage - #486

Open
cheb0 wants to merge 4 commits into
mainfrom
0-enhance-token-block-memory
Open

perf: enhance tokens block memory usage#486
cheb0 wants to merge 4 commits into
mainfrom
0-enhance-token-block-memory

Conversation

@cheb0

@cheb0 cheb0 commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Description

Measurements

Memory

Memory reduction (prod fraction):

message:*foobar*
25335032 => 20584912 bytes

message:*87466437*
71844952 => 58236912

Query perf

V5 fractions
For V5 fractions (current version) we have same cold perf - unpack is unchanged, same hot perf for contains wildcard but a little slowdown for wildcards like suffix since GetToken is now includes version check and it's a bit more expensive. Please see the code of Block and contains function.

Query env Total cold, ms   hot, ms   cold (branch), ms   hot (branch), ms   cold diff hot diff
message:eldorado prod 0 96.52 ±3.54 11.99 ±0.09 97.22 ±2.77 12.03 ±0.24 0.7% 0.3%
request:010462589104432 prod 0 115.6 ±7.44 16.85 ±0.34 117.49 ±5.33 16.79 ±0.23 1.6% -0.4%
request:*010462589104432 prod 0 119.37 ±6.02 15.05 ±0.09 125.76 ±6.97 15.96 ±0.15 5.4% 6%

V6 fractions

For V6 (new format) we have slightly better cold perf - unpack is more cheap.

For hot queries it's also slightly faster for contains wildcards since getting a token is a bit more cheap and the new implementation has BCE optimization as well. Same for arbitrary wildcards - slightly more expensive GetToken, I suppose.

Query env Total cold, ms   hot, ms   cold (branch), ms   hot (branch), ms   cold diff hot diff
message:eldorado prod 0 96.52 ±3.54 11.99 ±0.09 93.14 ±4.48 9.87 ±0.15 -3.5% -17.7%
request:010462589104432 prod 0 115.6 ±7.44 16.85 ±0.34 107.73 ±7.44 15.29 ±0.20 -6.8% -9.3%
request:*010462589104432 prod 0 119.37 ±6.02 15.05 ±0.09 109.29 ±5.45 16.11 ±0.32 -8.4% 7%

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

@codecov-commenter

codecov-commenter commented Aug 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 65.07937% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.01%. Comparing base (a73114c) to head (71984cd).

Files with missing lines Patch % Lines
frac/sealed/token/block_loader.go 60.71% 18 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #486      +/-   ##
==========================================
- Coverage   71.33%   71.01%   -0.32%     
==========================================
  Files         233      233              
  Lines       18999    19053      +54     
==========================================
- Hits        13552    13531      -21     
- Misses       4419     4489      +70     
- Partials     1028     1033       +5     

☔ 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.

@dkharms

dkharms commented Aug 6, 2026

Copy link
Copy Markdown
Member

@seqbenchbot start search-regular main 'k8s_pod:-eu-' --duration 5m

@seqbenchbot

seqbenchbot commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

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

Started benchmark 58d2faa3.

Show details
  • scenario search-regular;
  • against main;
  • running for 5m0s;

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

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 58d2faa3 (scenario search-regular) 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 total
k8s_pod:*-eu-*
hot 11.80 0.74 12.17 17.54 18.20 2992 1437046

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

@dkharms

dkharms commented Aug 6, 2026

Copy link
Copy Markdown
Member

@seqbenchbot start search-regular 0-enhance-token-block-memory 'k8s_pod:-eu-' --duration 5m

@seqbenchbot

seqbenchbot commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

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

Started benchmark 43c61a79.

Show details
  • scenario search-regular;
  • against 0-enhance-token-block-memory;
  • running for 5m0s;

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

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 43c61a79 (scenario search-regular) 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 total
k8s_pod:*-eu-*
hot 12.15 2.71 10.95 16.47 17.00 2992 1437020

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

@dkharms dkharms added the performance Features or improvements that positively affect seq-db performance label Aug 6, 2026
@eguguchkin eguguchkin added this to the v0.77.0 milestone Aug 10, 2026
@eguguchkin
eguguchkin requested review from forshev and moflotas August 10, 2026 09:56
@cheb0
cheb0 force-pushed the 0-enhance-token-block-memory branch 2 times, most recently from d673940 to 6261f65 Compare August 12, 2026 11:03
@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 a73114 589c4e
678752766.00 B/op 784180884.00 B/op 1.16 🔴
MutexListAppend-4 a73114 589c4e
194.53 MB/s 176.75 MB/s 0.91 🔴

@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
MutexListAppend-4 a73114 1cbda1
194.53 MB/s 174.20 MB/s 0.90 🔴

@cheb0
cheb0 force-pushed the 0-enhance-token-block-memory branch 2 times, most recently from 8d0d84c to 71984cd Compare August 13, 2026 04:51
@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 a73114 e6e643
678752766.00 B/op 769594074.00 B/op 1.13 🔴

@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 a73114 82d86f
678752766.00 B/op 780099521.00 B/op 1.15 🔴

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.

5 participants