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

fix: Run defrag on dbs > 0 as well #1737

Merged
merged 3 commits into from
Aug 27, 2023

Conversation

dranikpg
Copy link
Contributor

No description provided.

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
@dranikpg dranikpg marked this pull request as ready for review August 25, 2023 06:20
Comment on lines 166 to 172
// Once we're done with a db, jump to the next
if (defrag_state_.cursor == kCursorDoneState) {
defrag_state_.dbid++;
// Skip null dbs that still take up slots in the array
while (defrag_state_.dbid < slice.db_array_size() && !slice.IsDbValid(defrag_state_.dbid))
defrag_state_.dbid++;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, if the db has less elements than kMaxTraverses, then it will proceed with the next db only on the next phase. I don't see it as a big flaw given that kMaxTraverses is only 40 now.

@@ -137,8 +141,8 @@ bool EngineShard::DoDefrag() {
const float threshold = GetFlag(FLAGS_mem_defrag_page_utilization_threshold);

auto& slice = db_slice();
DCHECK(slice.IsDbValid(kDefaultDbIndex));
auto [prime_table, expire_table] = slice.GetTables(kDefaultDbIndex);
DCHECK(slice.IsDbValid(defrag_state_.dbid));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we ever reduce number of our databases? i.e. flushall?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't, see DbSlice::FlushDb

But I can change it a little nonetheless to make it safer

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
@dranikpg dranikpg requested a review from romange August 25, 2023 11:07
Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
@dranikpg dranikpg merged commit e020f87 into dragonflydb:main Aug 27, 2023
7 checks passed
kostasrim pushed a commit that referenced this pull request Aug 29, 2023
* fix: Run defrag on dbs > 0 as well

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
@dranikpg dranikpg deleted the defrag-on-all-dbd branch September 15, 2023 06:37
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

Successfully merging this pull request may close these issues.

None yet

3 participants