-
Notifications
You must be signed in to change notification settings - Fork 107
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
Do not use vacuum when pruning #1103
Conversation
fluffy/content_db.nim
Outdated
## Return size of pages which are used by databse, but are currently empty i.e | ||
## they can be re-used for new content |
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.
## Return size of pages which are used by databse, but are currently empty i.e | |
## they can be re-used for new content | |
## Returns the total size of the pages which are unused by the database, | |
## i.e they can be re-used for new content. |
fluffy/content_db.nim
Outdated
@@ -172,6 +183,18 @@ proc size*(db: ContentDB): int64 = | |||
size = res).expectDb() | |||
return size | |||
|
|||
proc unusedSize*(db: ContentDB): int64 = |
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.
This can probably remain private?
fluffy/content_db.nim
Outdated
|
||
let dbSize = db.size() | ||
|
||
# We use real size for our pruning treshold, which means that database file |
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 use real size for our pruning treshold, which means that database file | |
# We use real size for our pruning threshold, which means that database file |
fluffy/content_db.nim
Outdated
let dbSize = db.size() | ||
|
||
# We use real size for our pruning treshold, which means that database file | ||
# will reach size specified in db.maxSize, and will stay that size thourough |
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.
# will reach size specified in db.maxSize, and will stay that size thourough | |
# will reach size specified in db.maxSize, and will stay that size thorough |
fluffy/content_db.nim
Outdated
# 1. Devise vacuum strategy - after few pruning cycles database can be | ||
# fragmented which may impact performance, so at some point in time `VACCUM` | ||
# will need to be run to defragment db. | ||
# 2. Deal with edge case when user would configre max db size lower than | ||
# current db.size(). With such config data base would try to prune iteslf with | ||
# each addition |
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.
# 1. Devise vacuum strategy - after few pruning cycles database can be | |
# fragmented which may impact performance, so at some point in time `VACCUM` | |
# will need to be run to defragment db. | |
# 2. Deal with edge case when user would configre max db size lower than | |
# current db.size(). With such config data base would try to prune iteslf with | |
# each addition | |
# 1. Devise vacuum strategy - after few pruning cycles database can become | |
# fragmented which may impact performance, so at some point in time `VACUUM` | |
# will need to be run to defragment the db. | |
# 2. Deal with the edge case where a user configures max db size lower than | |
# current db.size(). With such config the database would try to prune itself with | |
# each addition. |
|
Agreed that for now it is not an urgent thing. I will create a task for it.
Deleting database sounds harsh, and would probably incur some unhappy users do not expecting such behaviour. (although we still do not have users yet so 😅 ) Probably the most comprehensive solution would be to have database in incremental vacuum mode, delete enough data so db size will drop to the half of provided new limit, then change db size by incremental delete pragma and then vacuum. That way are within limit all the time, and end up with correct database state. Drawback is that client start up can probably take a while when such thing happen. |
Yes, I did call it the simplest solution, not the one with best UX. A more complex solution is for example what you mentioned. But, as you mention yourself already, when a user requests to use only half of the current storage that is being used now, it will practically keep only ~25% of their original database instead of ~50%. Better than a full reset, but still not great (And especially for small storage size settings, perhaps not worth it). The incremental vacuum setting will also increase the db overhead (although I don't know by how much, perhaps negligible). |
Yep agree 👍 , for now maybe it would be enough to return error to the user in such case |
Removes usage of vacuum from fluffy pruning. With new approach fluffy node will reach specified maxDb size, and than stay with this size through its life time as pages freed by deleting items will be re-used for further additions.
Two follow up tasks are necessary:
VACCUM
will need to be run to defragment db.current db.size(). With such config data base would try to prune iteslf with
each addition