Skip to content

refactor: extract ModeHLL files (no contract change) - #40

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

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

Conversation

@Code0987

@Code0987 Code0987 commented Sep 2, 2026

Copy link
Copy Markdown
Owner

Design

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

What landed

Same HLLAdd / HLLCount contract. File layout only:

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

hllx.Merge is now unexported (merge). Engine never called it.

Tests

go test ./pkg/hllx ./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 HLL off memory.go and split engine HLL into public API,
owner apply, and cluster hops (same layout as TopK/CMS). Unexport
hllx.merge — install is LWW replace. 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: 48e5f71 (2026-09-02T13:44:09Z) → this run: 48e5f71 (2026-09-02T13:42:58Z)

scbench smoke

cell ops/s (main → PR) Δ ops/s p50 p99
get/hit n=1 c=1 uniform 7259 → 7274 +0.2% 137µs → 138µs 220µs → 217µs
get/hit n=1 c=10 uniform 28325 → 29123 +2.8% 327µs → 318µs 891µs → 869µs
get/hit n=3 c=10 uniform 33546 → 34478 +2.8% 263µs → 258µs 1.022ms → 930µs
miss/miss-cacheonly n=1 c=1 uniform 7041 → 7196 +2.2% 142µs → 143µs 242µs → 221µs
miss/miss-cacheonly n=1 c=10 uniform 28658 → 30328 +5.8% 323µs → 304µs 928µs → 887µs
set/put n=1 c=1 uniform 6887 → 6973 +1.3% 142µs → 142µs 257µs → 226µs
set/put n=1 c=10 uniform 27471 → 28188 +2.6% 336µs → 327µs 946µs → 922µ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 162 → 162 +0.1% 0 → 0
BenchmarkEngineBitGetHit 155 → 157 +0.9% 0 → 0
BenchmarkEngineBitGetHitParallel 194 → 187 -3.6% 0 → 0
BenchmarkEngineBitSet 483 → 484 +0.3% 2 → 2
BenchmarkEngineBitSetParallel 523 → 555 +6.2% 2 → 2
BenchmarkEngineCMSIncr 9189 → 9509 +3.5% 1 → 1
BenchmarkEngineCMSIncrN 11376 → 9218 -19.0% 1 → 1
BenchmarkEngineCMSIncrParallel 14030 → 13484 -3.9% 1 → 1
BenchmarkEngineCMSQueryHit 196 → 194 -0.9% 1 → 1
BenchmarkEngineCMSQueryHitParallel 240 → 238 -0.7% 1 → 1
BenchmarkEngineCounterGet 151 → 151 +0.1% 0 → 0
BenchmarkEngineCounterGetParallel 170 → 172 +1.3% 0 → 0
BenchmarkEngineDelete 819 → 818 -0.2% 6 → 6
BenchmarkEngineGeoAdd 12142 → 12511 +3.0% 8 → 8
BenchmarkEngineGeoCard 152 → 152 -0.1% 0 → 0
BenchmarkEngineGeoPosHit 97 → 94 -2.6% 0 → 0
BenchmarkEngineGeoRadius 334996 → 362684 +8.3% 1016 → 1016
BenchmarkEngineGetHit 1265 → 1243 -1.7% 15 → 15
BenchmarkEngineGetHitParallel 1088 → 1080 -0.7% 15 → 15
BenchmarkEngineGetMissCacheOnly 943 → 923 -2.0% 14 → 14
BenchmarkEngineGetMissCacheOnlyParallel 674 → 712 +5.7% 14 → 14
BenchmarkEngineGetMissLoadThrough 1683 → 1680 -0.2% 24 → 24
BenchmarkEngineGetMissLoadThroughParallel 1902 → 1986 +4.4% 23 → 23
BenchmarkEngineHGetAll 16412 → 15963 -2.7% 134 → 134
BenchmarkEngineHGetHit 107 → 105 -1.9% 1 → 1
BenchmarkEngineHGetHitParallel 136 → 132 -2.9% 1 → 1
BenchmarkEngineHGetMiss 164 → 167 +1.6% 0 → 0
BenchmarkEngineHLLAdd 2054 → 2042 -0.6% 1 → 1
BenchmarkEngineHLLAddParallel 3414 → 3306 -3.2% 1 → 1
BenchmarkEngineHLLCountHit 107704 → 107925 +0.2% 0 → 0
BenchmarkEngineHLLCountHitParallel 117117 → 120667 +3.0% 0 → 0
BenchmarkEngineHLen 151 → 159 +5.8% 0 → 0
BenchmarkEngineHSet 13307 → 13298 -0.1% 6 → 6
BenchmarkEngineHSetParallel 15284 → 13855 -9.3% 6 → 6
BenchmarkEngineIncr 366 → 363 -0.9% 1 → 1
BenchmarkEngineIncrParallel 430 → 403 -6.2% 1 → 1
BenchmarkEngineJsonGet 189 → 190 +0.7% 1 → 1
BenchmarkEngineJsonGetHit 466 → 464 -0.5% 5 → 5
BenchmarkEngineJsonGetHitParallel 550 → 558 +1.5% 5 → 5
BenchmarkEngineJsonSet 28846 → 28523 -1.1% 215 → 215
BenchmarkEngineJsonSetParallel 16883 → 17374 +2.9% 119 → 118
BenchmarkEngineLIndexHit 179 → 173 -3.4% 1 → 1
BenchmarkEngineLLen 156 → 151 -3.1% 0 → 0
BenchmarkEngineLPush 10802 → 10524 -2.6% 18 → 18
BenchmarkEngineLRange 479 → 479 -0.1% 11 → 11
BenchmarkEnginePut 1585 → 1560 -1.6% 18 → 18
BenchmarkEnginePutParallel 1386 → 1441 +4.0% 18 → 18
BenchmarkEngineSetAdd 11847 → 11914 +0.6% 4 → 4
BenchmarkEngineSetCard 202 → 156 -22.5% 0 → 0
BenchmarkEngineSetContainsHit 98 → 98 +0.1% 0 → 0
BenchmarkEngineSetContainsHitParallel 117 → 120 +2.7% 0 → 0
BenchmarkEngineSetContainsMiss 167 → 167 -0.2% 0 → 0
BenchmarkEngineSetMembers 6638 → 6547 -1.4% 66 → 66
BenchmarkEngineSetRemove 1966 → 1809 -8.0% 1 → 1
BenchmarkEngineTopKAdd 1586 → 1550 -2.3% 21 → 21
BenchmarkEngineTopKAddParallel 1739 → 1740 +0.1% 21 → 21
BenchmarkEngineTopKListHit 621 → 616 -0.9% 11 → 11
BenchmarkEngineTopKListHitParallel 703 → 707 +0.5% 11 → 11
BenchmarkEngineZAdd 12629 → 12116 -4.1% 8 → 8
BenchmarkEngineZCard 153 → 151 -1.3% 0 → 0
BenchmarkEngineZRange 183072 → 183732 +0.4% 1017 → 1017
BenchmarkEngineZRangeByScore 183402 → 183141 -0.1% 1021 → 1021
BenchmarkEngineZScoreHit 100 → 99 -1.7% 0 → 0
BenchmarkStoreBitSet 107 → 106 -0.1% 1 → 1
BenchmarkStoreCGetHit 68 → 68 -0.0% 0 → 0
BenchmarkStoreCIncr 94 → 95 +0.1% 1 → 1
BenchmarkStoreCMSIncr 109 → 111 +1.5% 0 → 0
BenchmarkStoreCMSIncrN 109 → 109 +0.1% 0 → 0
BenchmarkStoreGeoAdd 12255 → 12007 -2.0% 2 → 2
BenchmarkStoreGeoPosHit 78 → 86 +10.4% 0 → 0
BenchmarkStoreGeoPosMiss 79 → 81 +1.9% 0 → 0
BenchmarkStoreGetHit 297 → 298 +0.5% 2 → 2
BenchmarkStoreGetHitParallel 368 → 355 -3.7% 2 → 2
BenchmarkStoreHGetHit 85 → 87 +2.4% 1 → 1
BenchmarkStoreHGetMiss 80 → 80 +0.8% 0 → 0
BenchmarkStoreHLLAdd 95 → 95 +0.5% 0 → 0
BenchmarkStoreHSet 12962 → 13024 +0.5% 3 → 3
BenchmarkStoreJsonSet 26200 → 26662 +1.8% 207 → 207
BenchmarkStorePut 307 → 305 -0.7% 2 → 2
BenchmarkStorePutParallel 392 → 338 -13.7% 2 → 2
BenchmarkStoreSetAdd 11644 → 11374 -2.3% 2 → 2
BenchmarkStoreSetContainsHit 75 → 79 +4.4% 0 → 0
BenchmarkStoreSetContainsMiss 76 → 79 +4.2% 0 → 0
BenchmarkStoreTopKAdd 1030 → 1039 +0.9% 20 → 20
BenchmarkStoreZAdd 11950 → 11908 -0.4% 2 → 2
BenchmarkStoreZScoreHit 77 → 83 +7.7% 0 → 0
BenchmarkStoreZScoreMiss 77 → 81 +4.5% 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-hll 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