Skip to content

refactor: extract ModeBitmap files (no contract change) - #41

Closed
Code0987 wants to merge 1 commit into
mainfrom
feat/refactor-bitmap
Closed

Code0987 wants to merge 1 commit into
mainfrom
feat/refactor-bitmap

Conversation

@Code0987

@Code0987 Code0987 commented Sep 2, 2026

Copy link
Copy Markdown
Owner

Design

docs/design/2026-09-02-refactor-bitmap.md

Independent of #40 (HLL extract). Same layout, Bitmap only.

What landed

Same BitSet / BitGet / BitCount / BitPos contract.

File Role
pkg/store/bitmap.go store methods (out of memory.go)
pkg/engine/bitmap.go public verbs
pkg/engine/bitmap_apply.go owner write + inbox apply
pkg/engine/bitmap_cluster.go forward / snapshot / GetOrLoad

Tests

go test ./pkg/bitmapx ./pkg/store ./pkg/engine

Local bench

BenchmarkStoreGetHit 2 allocs/op, BenchmarkEngineGetHit 15 allocs/op (flat).

Bench risk

No new Get/Peek logic. Shared smoke/micro ±10%. Get-hit allocs must stay flat.

Move store Bitmap off memory.go and split engine Bitmap into public
API, owner apply, and cluster hops. No contract change.
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

SuperCache bench vs main

Both sides ran once on this same GitHub runner (main, then this PR). Not a merge gate.

Baseline: 34679e7 (2026-09-02T13:44:13Z) → this run: 34679e7 (2026-09-02T13:42:58Z)

scbench smoke

cell ops/s (main → PR) Δ ops/s p50 p99
get/hit n=1 c=1 uniform 8795 → 8805 +0.1% 113µs → 113µs 190µs → 196µs
get/hit n=1 c=10 uniform 34035 → 33595 -1.3% 267µs → 270µs 812µs → 828µs
get/hit n=3 c=10 uniform 39001 → 38051 -2.4% 224µs → 228µs 928µs → 975µs
miss/miss-cacheonly n=1 c=1 uniform 8707 → 8584 -1.4% 114µs → 115µs 214µs → 217µs
miss/miss-cacheonly n=1 c=10 uniform 36056 → 35880 -0.5% 252µs → 253µs 803µs → 801µs
set/put n=1 c=1 uniform 8601 → 8640 +0.4% 114µs → 114µs 210µs → 198µs
set/put n=1 c=10 uniform 32339 → 32818 +1.5% 279µs → 277µs 871µs → 830µs

Δ ops/s: green-ish is higher throughput. Latency: lower is better.

go test -bench (ns/op)

benchmark ns/op (main → PR) Δ allocs/op
BenchmarkEngineBitCount 170 → 170 +0.5% 0 → 0
BenchmarkEngineBitGetHit 167 → 165 -1.4% 0 → 0
BenchmarkEngineBitGetHitParallel 215 → 206 -4.1% 0 → 0
BenchmarkEngineBitSet 505 → 504 -0.3% 2 → 2
BenchmarkEngineBitSetParallel 561 → 586 +4.5% 2 → 2
BenchmarkEngineCMSIncr 8209 → 9178 +11.8% 1 → 1
BenchmarkEngineCMSIncrN 8261 → 10961 +32.7% worse 1 → 1
BenchmarkEngineCMSIncrParallel 12204 → 15114 +23.8% worse 1 → 1
BenchmarkEngineCMSQueryHit 202 → 203 +0.5% 1 → 1
BenchmarkEngineCMSQueryHitParallel 249 → 252 +0.9% 1 → 1
BenchmarkEngineCounterGet 162 → 159 -1.8% 0 → 0
BenchmarkEngineCounterGetParallel 203 → 186 -8.3% 0 → 0
BenchmarkEngineDelete 769 → 772 +0.4% 6 → 6
BenchmarkEngineGeoAdd 9870 → 9930 +0.6% 8 → 8
BenchmarkEngineGeoCard 160 → 162 +1.3% 0 → 0
BenchmarkEngineGeoPosHit 108 → 102 -5.1% 0 → 0
BenchmarkEngineGeoRadius 350645 → 355585 +1.4% 1016 → 1016
BenchmarkEngineGetHit 1253 → 1284 +2.5% 15 → 15
BenchmarkEngineGetHitParallel 1248 → 1215 -2.6% 15 → 15
BenchmarkEngineGetMissCacheOnly 873 → 877 +0.4% 14 → 14
BenchmarkEngineGetMissCacheOnlyParallel 657 → 671 +2.1% 14 → 14
BenchmarkEngineGetMissLoadThrough 1616 → 1631 +0.9% 24 → 24
BenchmarkEngineGetMissLoadThroughParallel 1794 → 1880 +4.8% 23 → 23
BenchmarkEngineHGetAll 15137 → 15713 +3.8% 134 → 134
BenchmarkEngineHGetHit 108 → 109 +0.4% 1 → 1
BenchmarkEngineHGetHitParallel 138 → 136 -1.8% 1 → 1
BenchmarkEngineHGetMiss 174 → 179 +3.1% 0 → 0
BenchmarkEngineHLLAdd 2072 → 2770 +33.7% worse 1 → 1
BenchmarkEngineHLLAddParallel 2874 → 3560 +23.9% worse 1 → 1
BenchmarkEngineHLLCountHit 115689 → 116107 +0.4% 0 → 0
BenchmarkEngineHLLCountHitParallel 119676 → 162134 +35.5% worse 0 → 0
BenchmarkEngineHLen 160 → 163 +2.1% 0 → 0
BenchmarkEngineHSet 10921 → 10990 +0.6% 6 → 6
BenchmarkEngineHSetParallel 12047 → 12348 +2.5% 6 → 6
BenchmarkEngineIncr 382 → 381 -0.4% 1 → 1
BenchmarkEngineIncrParallel 462 → 425 -7.8% 1 → 1
BenchmarkEngineJsonGet 195 → 195 +0.4% 1 → 1
BenchmarkEngineJsonGetHit 416 → 432 +3.8% 5 → 5
BenchmarkEngineJsonGetHitParallel 467 → 496 +6.2% 5 → 5
BenchmarkEngineJsonSet 28473 → 29965 +5.2% 215 → 215
BenchmarkEngineJsonSetParallel 16582 → 19773 +19.2% 118 → 119
BenchmarkEngineLIndexHit 182 → 184 +1.2% 1 → 1
BenchmarkEngineLLen 159 → 159 +0.0% 0 → 0
BenchmarkEngineLPush 10214 → 10952 +7.2% 18 → 18
BenchmarkEngineLRange 446 → 465 +4.3% 11 → 11
BenchmarkEnginePut 1626 → 1600 -1.6% 18 → 18
BenchmarkEnginePutParallel 1401 → 1470 +4.9% 18 → 18
BenchmarkEngineSetAdd 9557 → 9508 -0.5% 4 → 4
BenchmarkEngineSetCard 165 → 165 +0.2% 0 → 0
BenchmarkEngineSetContainsHit 104 → 103 -0.2% 0 → 0
BenchmarkEngineSetContainsHitParallel 120 → 121 +1.5% 0 → 0
BenchmarkEngineSetContainsMiss 183 → 175 -4.5% 0 → 0
BenchmarkEngineSetMembers 5690 → 5818 +2.2% 66 → 66
BenchmarkEngineSetRemove 1013 → 1004 -0.9% 1 → 1
BenchmarkEngineTopKAdd 1468 → 1545 +5.2% 21 → 21
BenchmarkEngineTopKAddParallel 1772 → 1837 +3.7% 21 → 21
BenchmarkEngineTopKListHit 569 → 595 +4.6% 11 → 11
BenchmarkEngineTopKListHitParallel 649 → 690 +6.3% 11 → 11
BenchmarkEngineZAdd 10251 → 10221 -0.3% 8 → 8
BenchmarkEngineZCard 160 → 159 -0.6% 0 → 0
BenchmarkEngineZRange 194431 → 195112 +0.4% 1017 → 1017
BenchmarkEngineZRangeByScore 197413 → 199418 +1.0% 1021 → 1021
BenchmarkEngineZScoreHit 103 → 103 +0.4% 0 → 0
BenchmarkStoreBitSet 112 → 112 -0.2% 1 → 1
BenchmarkStoreCGetHit 72 → 72 -0.1% 0 → 0
BenchmarkStoreCIncr 101 → 101 +0.0% 1 → 1
BenchmarkStoreCMSIncr 120 → 121 +1.0% 0 → 0
BenchmarkStoreCMSIncrN 121 → 121 +0.0% 0 → 0
BenchmarkStoreGeoAdd 9543 → 9675 +1.4% 2 → 2
BenchmarkStoreGeoPosHit 88 → 88 -0.4% 0 → 0
BenchmarkStoreGeoPosMiss 87 → 88 +1.2% 0 → 0
BenchmarkStoreGetHit 294 → 293 -0.6% 2 → 2
BenchmarkStoreGetHitParallel 363 → 345 -4.9% 2 → 2
BenchmarkStoreHGetHit 92 → 95 +3.7% 1 → 1
BenchmarkStoreHGetMiss 85 → 85 +0.8% 0 → 0
BenchmarkStoreHLLAdd 102 → 101 -0.7% 0 → 0
BenchmarkStoreHSet 10589 → 10598 +0.1% 3 → 3
BenchmarkStoreJsonSet 26956 → 26585 -1.4% 207 → 207
BenchmarkStorePut 311 → 306 -1.8% 2 → 2
BenchmarkStorePutParallel 343 → 358 +4.5% 2 → 2
BenchmarkStoreSetAdd 9242 → 9236 -0.1% 2 → 2
BenchmarkStoreSetContainsHit 87 → 89 +1.7% 0 → 0
BenchmarkStoreSetContainsMiss 84 → 84 +0.1% 0 → 0
BenchmarkStoreTopKAdd 1013 → 991 -2.2% 20 → 20
BenchmarkStoreZAdd 9509 → 9514 +0.1% 2 → 2
BenchmarkStoreZScoreHit 89 → 88 -0.4% 0 → 0
BenchmarkStoreZScoreMiss 88 → 86 -2.3% 0 → 0

Posted by CI bench job. Not a merge gate.

@Code0987

Code0987 commented Sep 2, 2026

Copy link
Copy Markdown
Owner Author

Opened too early — you wanted to review first. Branch feat/refactor-bitmap kept.

@Code0987

Code0987 commented Sep 2, 2026

Copy link
Copy Markdown
Owner Author

Closing — you asked to review locally, not commit/PR.

@Code0987 Code0987 closed this Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant