Skip to content

perf(state-res): use roaring bitmaps for faster auth difference computing#481

Open
gamesguru wants to merge 3 commits into
matrix-construct:mainfrom
gamesguru:guru/perf/state-res-v2.1-roaring-bitmaps-transitive-closures
Open

perf(state-res): use roaring bitmaps for faster auth difference computing#481
gamesguru wants to merge 3 commits into
matrix-construct:mainfrom
gamesguru:guru/perf/state-res-v2.1-roaring-bitmaps-transitive-closures

Conversation

@gamesguru

@gamesguru gamesguru commented Jun 5, 2026

Copy link
Copy Markdown

One of the few magical times where adding more lines of code makes things run significantly faster.

Rapidly computes set unions and intersections with hardware-accelerated bitwise operations, keeping the L1/L2 cache hot throughout. Sometimes this means performing comparisons or operations on up to 256 graph nodes per clock cycle.


Future work / Next steps

Ultimately, this would further greatly benefit from a refactor which enabled loading the full auth chain into memory at once (if the machine's throughput would allow).

That's when you would start to see large evals happen in a tiny fraction of a second, because you could compute full topological sweeps and pre-compute transitive auth closures virtually at the silicon limit.


EDIT: About to push some commits that read directly from DB into roaring data types, should achieve similar speedup as this benchmark:

Starting Comparative Performance Benchmark...

--- Benchmark with size: 100 elements across 20 sets ---
Origin/Main (BTreeMap Counts):      2.856805795s (avg: 142.84µs)
Cached/Pre-computed Roaring:      189.769309ms (avg: 9.488µs)
Speedup of Cached Roaring over origin/main: 15.05x

--- Benchmark with size: 2000 elements across 20 sets ---
Origin/Main (BTreeMap Counts):     89.105965617s (avg: 4.455298ms)
Cached/Pre-computed Roaring:        4.187627498s (avg: 209.381µs)
Speedup of Cached Roaring over origin/main: 21.28x

@jevolk jevolk added the performance Something isn't fast enough label Jun 8, 2026
@gamesguru

Copy link
Copy Markdown
Author

@coderabbitai review

@gamesguru

Copy link
Copy Markdown
Author

@cubic-dev-ai review

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

Labels

performance Something isn't fast enough

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants