refactor: extract modes and move logic into feature folders - #43
Merged
Conversation
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.
Move store Bitmap off memory.go and split engine Bitmap into public API, owner apply, and cluster hops. No contract change.
Move store Counter off memory.go and split engine Counter into public API, owner write, and GetOrLoad. Peer CounterIncr unchanged.
Move Geo store methods out of memory.go and split the engine file into public verbs, owner write/apply, and cluster forward. Same contract, including dirty gCache and FlagGeoAdd/FlagGeoRem item fan-out.
Move ZSet store methods out of memory.go and split the engine file into public verbs, owner write/apply, and cluster forward. Same contract, including dirty zCache and FlagZSetAdd/FlagZSetRem item fan-out.
Move Set store methods out of memory.go and split the engine file into public verbs, owner write/apply, and cluster forward. Same contract, including dirty setCache and FlagSetAdd/FlagSetRemove item fan-out. PeekVersion stays in memory.go.
Move Bloom store methods out of memory.go and split the engine file into public verbs, owner write/apply, and cluster forward. Same contract, including FlagBloomAdd item-hint fan-out and no install on GetOrLoad.
Move JSON store methods out of memory.go and split the engine file into public verbs, owner write/apply, and cluster forward. Same contract, including dirty jCache and FlagJSONSet/FlagJSONDel inbox then FlagJSON snapshot.
Move Hash store methods out of memory.go and split the engine file into public verbs, owner write/apply, and cluster forward. Same contract, including dirty hCache and FlagHashSet/FlagHashDel item fan-out.
Move List store methods out of memory.go and split the engine file into public verbs, owner write/apply, and cluster forward. Same contract, including dirty lCache and FlagList snapshot fan-out.
After stacking the mode extracts, memory.go no longer references bloom or jsonx. errOwnerNoAddress is declared once so the engine package builds with every extract merged.
Engine keeps thin public verbs and a shared modeHost. Owner write, snapshot/GetOrLoad, and mode tests live under pkg/<mode>/eng and the feature package. listx becomes pkg/list. Same Engine/Store API.
SuperCache bench vs
|
| cell | ops/s (main → PR) | Δ ops/s | p50 | p99 |
|---|---|---|---|---|
get/hit n=1 c=1 uniform |
8978 → 9051 | +0.8% | 111µs → 111µs | 188µs → 192µs |
get/hit n=1 c=10 uniform |
33771 → 34635 | +2.6% | 268µs → 264µs | 820µs → 775µs |
get/hit n=3 c=10 uniform |
39461 → 38832 | -1.6% | 223µs → 227µs | 879µs → 904µs |
miss/miss-cacheonly n=1 c=1 uniform |
8664 → 8764 | +1.2% | 114µs → 113µs | 233µs → 206µs |
miss/miss-cacheonly n=1 c=10 uniform |
36254 → 34243 | -5.5% | 253µs → 266µs | 767µs → 832µs |
set/put n=1 c=1 uniform |
8695 → 8684 | -0.1% | 113µs → 112µs | 201µs → 239µs |
set/put n=1 c=10 uniform |
33314 → 33674 | +1.1% | 274µs → 271µs | 815µs → 811µs |
Δ ops/s: green-ish is higher throughput. Latency: lower is better.
go test -bench (ns/op)
| benchmark | ns/op (main → PR) | Δ | allocs/op |
|---|---|---|---|
BenchmarkEngineDelete |
762 → 758 | -0.5% | 6 → 6 |
BenchmarkEngineGetHit |
1198 → 1162 | -3.0% | 15 → 15 |
BenchmarkEngineGetHitParallel |
1229 → 1235 | +0.5% | 15 → 15 |
BenchmarkEngineGetMissCacheOnly |
888 → 867 | -2.3% | 14 → 14 |
BenchmarkEngineGetMissCacheOnlyParallel |
680 → 649 | -4.6% | 14 → 14 |
BenchmarkEngineGetMissLoadThrough |
1859 → 1610 | -13.4% | 24 → 24 |
BenchmarkEngineGetMissLoadThroughParallel |
2134 → 1856 | -13.0% | 23 → 23 |
BenchmarkEnginePut |
1601 → 1535 | -4.1% | 18 → 18 |
BenchmarkEnginePutParallel |
1438 → 1356 | -5.7% | 18 → 18 |
BenchmarkStoreBitSet |
112 → 113 | +0.6% | 1 → 1 |
BenchmarkStoreCGetHit |
74 → 73 | -2.1% | 0 → 0 |
BenchmarkStoreCIncr |
101 → 100 | -1.0% | 1 → 1 |
BenchmarkStoreCMSIncr |
121 → 120 | -0.7% | 0 → 0 |
BenchmarkStoreCMSIncrN |
125 → 121 | -3.2% | 0 → 0 |
BenchmarkStoreGeoAdd |
9548 → 9225 | -3.4% | 2 → 2 |
BenchmarkStoreGeoPosHit |
88 → 89 | +0.8% | 0 → 0 |
BenchmarkStoreGeoPosMiss |
87 → 87 | +0.6% | 0 → 0 |
BenchmarkStoreGetHit |
300 → 317 | +5.8% | 2 → 2 |
BenchmarkStoreGetHitParallel |
363 → 376 | +3.6% | 2 → 2 |
BenchmarkStoreHGetHit |
92 → 91 | -0.7% | 1 → 1 |
BenchmarkStoreHGetMiss |
85 → 85 | +0.1% | 0 → 0 |
BenchmarkStoreHLLAdd |
99 → 100 | +0.3% | 0 → 0 |
BenchmarkStoreHSet |
10592 → 10586 | -0.1% | 3 → 3 |
BenchmarkStoreJsonSet |
26345 → 26512 | +0.6% | 207 → 207 |
BenchmarkStorePut |
302 → 301 | -0.4% | 2 → 2 |
BenchmarkStorePutParallel |
351 → 360 | +2.7% | 2 → 2 |
BenchmarkStoreSetAdd |
9214 → 9691 | +5.2% | 2 → 2 |
BenchmarkStoreSetContainsHit |
87 → 88 | +0.9% | 0 → 0 |
BenchmarkStoreSetContainsMiss |
84 → 84 | -0.2% | 0 → 0 |
BenchmarkStoreTopKAdd |
988 → 1006 | +1.8% | 20 → 20 |
BenchmarkStoreZAdd |
9562 → 9601 | +0.4% | 2 → 2 |
BenchmarkStoreZScoreHit |
86 → 87 | +1.6% | 0 → 0 |
BenchmarkStoreZScoreMiss |
87 → 86 | -0.5% | 0 → 0 |
Posted by CI bench job. Not a merge gate.
Go LIFO defers closed FanoutPool while warmup workers still called Submit. CI -race failed on TestJoinHandoffAvoidsDataSourceReload. Test-only teardown order; production Submit/Close left unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Same-contract layout cleanup, no API / proto / fan-out / dirty-cache change.
memory.go; engine split into public / apply / cluster files (HLL, Bitmap, Counter, List, Hash, JSON, Bloom, Set, ZSet, Geo).pkg/<mode>/eng(andpkg/listfor the formerlistxcodec). Engine keeps thin public verbs plus a sharedmodeHost. Callers still useengine.Engine.LPushetc.Design: docs/design/2026-09-02-feature-folders.md.
Release
--- / release: vX.Y.Z / ---)[release: vX.Y.Z]v..__Test plan
go test ./...locallyStoreGetHit/EngineGetHitallocs/op stayed 2 / 15test+benchgreen; read<!-- supercache-bench-comment -->Notes for reviewers
pkg/hashx/pkg/jsonx/pkg/hllx/pkg/bitmapx/pkg/cmsx/pkg/topkxkeep thexnames (stdlib clashes).Memorymethods stay inpkg/storebecause of unexported dirty-cache fields. Import cycle avoided withpkg/<mode>/engso store can still import the codec package.Merge only if every shared smoke/micro cell is within ±10% and Get-hit allocs are flat.