Skip to content
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

Feature Request: CubDB.number_of_writes/1 #58

Open
eksperimental opened this issue Aug 3, 2022 · 4 comments
Open

Feature Request: CubDB.number_of_writes/1 #58

eksperimental opened this issue Aug 3, 2022 · 4 comments

Comments

@eksperimental
Copy link

I would like to propose, on the same vein as CubDB.dirt_factor/1, I think it will be useful to have a public API with CubDB.number_of_writes/1, so we could manually trigger CubDB.compact/1 based these two factors.

Thank you.

@lucaong
Copy link
Owner

lucaong commented Aug 4, 2022

Hi @eksperimental ,
Would that return the number of writes since the last compaction?

The dirt factor is calculated on the basis of the number of writes since the last compaction, and the number of entries in the database. It basically estimates how much data stored in the file is unreachable “garbage” relative to the size of the database. Automatic compaction is triggered when the dirt factor is over a given threshold, AND the number of writes since the last compaction is at least a given number.

If I understand, you would like to have a function that tells you the number of writes since the last compaction. That’s possible, but can I ask what’s the use case, and in particular why auto compaction won’t work in that case?

@eksperimental
Copy link
Author

eksperimental commented Aug 4, 2022

I have a cron job and I want to manually compact only when the cron job is executed, so I would be checking the number of writes since the last compaction AND the dirt factor, but based on what you say the dirt factor is already calculated, but the docs mentions both value as a requirement to trigger the autocompact.

@lucaong
Copy link
Owner

lucaong commented Aug 6, 2022

I can add such feature in the next release, possibly under a slightly different name (maybe CubDB.writes_since_compaction).

@eksperimental
Copy link
Author

Sounds great. Looking forward to it.
Thank you @lucaong

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants