feat: implement STCS compaction#430
Conversation
| fracManagerStop func() | ||
|
|
||
| SkipMaskManager *skipmaskmanager.SkipMaskManager | ||
| Executor *compaction.Executor |
There was a problem hiding this comment.
nit: maybe rename Executor field to something associated with compaction? like CompactionExecutor or Compactor
| zap.Strings("names", names), | ||
| ) | ||
|
|
||
| preloaded, err := Merge(t.filename, common.SealParams{}, srcs...) |
There was a problem hiding this comment.
nit: should seal params be empty here?
|
|
||
| "go.uber.org/zap" | ||
|
|
||
| "github.com/alecthomas/units" |
d3e1c9e to
0f1955e
Compare
0f1955e to
aa2aecf
Compare
aa2aecf to
50256a3
Compare
50256a3 to
b017111
Compare
| } | ||
| } | ||
|
|
||
| func (fm *FracManager) FractionName() string { |
There was a problem hiding this comment.
nit: maybe we should move the implementation to fractionProvider to avoid duplication in fractionProvider.CreateActive
| func NewPlanner(ctx context.Context, fm *fracmanager.FracManager, cfg Config) *planner { | ||
| p := planner{ | ||
| cfg: cfg, | ||
| ctx: ctx, |
There was a problem hiding this comment.
nit: a small simplification here (and I think this would be more canonical) — we need to create a child context with cancellation
ctx, cancel := context.WithCancel(ctx)and instead of storing done, store cancel and call it in Stop.
| return ordered | ||
| } | ||
|
|
||
| func names[T interface{ Info() *common.Info }, S ~[]T](fracs S) []string { |
There was a problem hiding this comment.
nit: since we declared the fraction interface, maybe we should use it here too?
func names[T fraction, S ~[]T](fracs S) []string {|
|
||
| select { | ||
| case p.tasks <- task: | ||
| case <-time.NewTimer(time.Second).C: |
There was a problem hiding this comment.
We don't release claimed factions here
| continue | ||
| } | ||
|
|
||
| buckets = append(buckets, bucket{uint64(avg), current}) |
There was a problem hiding this comment.
Let's explicitly specify fields everywhere. Not all IDEs can handle implicit field initialization, and there's a risk of breaking initialization during refactoring.
| return fnames | ||
| } | ||
|
|
||
| func powerOfTwo(v uint64) uint64 { |
There was a problem hiding this comment.
nit: this name confused me at first. I suggest ceilPowerOfTwo
|
|
||
| onComplete: func(s *sealed.PreloadedData, err error) { | ||
| if err != nil { | ||
| compactionResultTotal.WithLabelValues(bucketSize, "error").Inc() |
There was a problem hiding this comment.
And here we don't release claimed factions
Description
Adds a STCS (Size-Tiered Compaction Strategy) planner that groups sealed fractions into time-bins and selects compaction candidates, and an executor that merges them into a new sealed fraction via k-way merge.
If you have used LLM/AI assistance please provide model name and full prompt: