-
Notifications
You must be signed in to change notification settings - Fork 9
refactor(fracmanager): using fifo queues of fractions #268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
3e082e3 to
e956ab5
Compare
e956ab5 to
245b875
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #268 +/- ##
==========================================
+ Coverage 71.29% 71.73% +0.44%
==========================================
Files 200 202 +2
Lines 14557 14516 -41
==========================================
+ Hits 10378 10413 +35
+ Misses 3450 3366 -84
- Partials 729 737 +8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| fm.fracMu.Unlock() | ||
| logger.Info("stats loop is started") | ||
| // Run stats collection every 10 seconds | ||
| util.RunEvery(ctx.Done(), time.Second*10, func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: maybe make interval configurable?
|
|
||
| stats registryStats // Size statistics for monitoring | ||
| oldestTotal uint64 // Creation time of oldest fraction | ||
| oldestLocal uint64 // Creation time of oldest fraction |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Creation time of oldest fraction -> // Creation time of oldest local fraction?
| remotes []*remoteProxy // Offloaded fractions (can be thousands) | ||
|
|
||
| stats registryStats // Size statistics for monitoring | ||
| oldestTotal uint64 // Creation time of oldest fraction |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Creation time of oldest fraction -> // Creation time of oldest fraction including remote?
| go func() { | ||
| defer wg.Done() | ||
|
|
||
| remote, _ := lc.TryOffload(ctx, sealed.instance) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we ignore error here?
| MaintenanceDelay: 0, | ||
| CacheGCDelay: 0, | ||
| CacheCleanupDelay: 0, | ||
| MinSealFracSize: uint64(cfg.Storage.TotalSize) * consts.DefaultMinSealPercent / 100, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I don't get it. It's min seal size for a single frac? Or all fracs? And it's default equal to 20 percent from total size? If total size is 100 gig, then MinSealFracSize is 20 gig. Am I missing something?
| func (p *activeProxy) Finalize() error { | ||
| p.mu.Lock() | ||
| if p.finalized { | ||
| p.mu.Unlock() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can we use defer here?
|
|
||
| // Lifecycle queues (FIFO order, oldest at lower indexes) | ||
| sealing []*activeProxy // Fractions being sealed (0-5 typical) | ||
| locals []*sealedProxy // Local sealed fractions (can be thousands) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: is local is a common name for us? seems like sealed is a better name, because local vs remote is harder to understand. I'd expect everything which is not remote to be local by default. But I also understand that sealed clashes with sealing which makes a code harder to read.
| }) | ||
| } | ||
|
|
||
| // Init oldest local value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: a comment doesn't help in understanding a code
| return nil, errors.New("active fraction must be specified") | ||
| } | ||
|
|
||
| // Set current active fraction |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: a comments states that we are settings an active fraction, but we actually create a new instance of frac registry
| } | ||
| return local | ||
| } | ||
| // Stop indexer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: same thing. IMO unneeded comment
| // Ensures correct state transitions while maintaining chronological order. | ||
| // The entire structure is thread-safe due to internal synchronization. | ||
| // Lifecycle: Created once, persists through application lifetime. | ||
| type fractionRegistry struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: looks like this test has to have some kind of concurrency test. Maybe in a different PR
I'd have something which spams bulk concurrently with offloading enabled and with tiny frac size so that we constantly offload and seal. And checking if we see all data as expected at the same time.
|
|
||
| // Seal converts an active fraction to sealed state | ||
| // Freezes writes, waits for pending operations, then seals the fraction. | ||
| func (lc *lifecycleManager) Seal(active *activeProxy) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: once again trying to figure out the naming rule. Can it be named seal here? it's called only from this struct
| oldestTotal uint64 // Creation time of oldest fraction | ||
| oldestLocal uint64 // Creation time of oldest fraction | ||
|
|
||
| muAll sync.RWMutex // Mutex specifically for all fractions list |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: This comment states Mutex specifically for all fractions list, however r.active and r.oldestTotal are also protected by this lock.
Fixes #156