-
Notifications
You must be signed in to change notification settings - Fork 180
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
[Access] Add registerDB pruning module #6397
base: master
Are you sure you want to change the base?
[Access] Add registerDB pruning module #6397
Conversation
…ub.com:The-K-R-O-K/flow-go into UlyanaAndrukhiv/6068-registerDB-pruning-module
…ub.com:The-K-R-O-K/flow-go into UlyanaAndrukhiv/6068-registerDB-pruning-module
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6397 +/- ##
==========================================
- Coverage 41.26% 41.24% -0.02%
==========================================
Files 2061 2067 +6
Lines 182702 183019 +317
==========================================
+ Hits 75384 75485 +101
- Misses 101010 101211 +201
- Partials 6308 6323 +15
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
…ub.com:The-K-R-O-K/flow-go into UlyanaAndrukhiv/6068-registerDB-pruning-module
node.Logger, | ||
builder.RegisterDB, | ||
pstorage.WithPrunerMetrics(builder.RegisterDBPrunerMetrics), | ||
//pstorage.WithPruneThreshold(builder.registerDBPruneThreshold), |
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.
WithPruneThreshold
is temporarily commented out and will be re-enabled once PR #6345 is merged.
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.
nice work! I haven't finished reviewing everything, but here are my comments so far.
…ling according to comments
…ub.com:The-K-R-O-K/flow-go into UlyanaAndrukhiv/6068-registerDB-pruning-module
} | ||
|
||
// Reset batchKeysToRemove to empty slice while retaining capacity | ||
batchKeysToRemove = batchKeysToRemove[:0] |
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.
We could reset before sleeping.
also clear(batchKeysToRemove)
would be better
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.
I thought about this as well. it turns our clear()
called on a slice just sets all of the elements in the array to nil rather than changing the size of slice, so it wouldn't work here
}() | ||
|
||
for _, key := range lookupKeys { | ||
if err := dbBatch.Delete(key, nil); err != nil { |
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.
Pebble batch support DeleteRange
.
I wonder if it would be more efficient with it.
For instance, if we have the following registers and different height:
registerA-height100
registerA-height99
registerA-height98
registerA-height90
And we'd like to prune by height 100.
Instead of calling:
dbBatch.Delete(registerA-height99, pebble.Sync)
dbBatch.Delete(registerA-height98, pebble.Sync)
dbBatch.Delete(registerA-height90, pebble.Sync)
we could call:
dbBatch.DeleteRange(registerA-height99, registerA-height0, pebble.Sync)
I wonder if that would make a difference?
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.
In a lookupKeys
variable we could have a mix of keys from different batches. For example:
registerA-height98
registerA-height90
...
registerB-height98
...
registerC-height98
registerC-height97
So, we need to call lookupKeyToRegisterID
one extra time to group them, or we should group them on a step when we check the key.
Another Idea could be, to save them as a map of ranges, for example:
[registerA]{registerA-height98, registerA-height90},
[registerB]{registerB-height98, registerB-height98},
[registerC]{registerC-height98, registerC-height97}
…ub.com:The-K-R-O-K/flow-go into UlyanaAndrukhiv/6068-registerDB-pruning-module
…drukhiv/6068-registerDB-pruning-module
Closes #6068
In this PR:
pruner
module forregisterDB
which will ensure that unneeded pruned data is removed from the db, freeing up disk space.pruner
into Access and Observer nodes.