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

feat(tiering): Defragmentation #3021

Merged
merged 7 commits into from
May 29, 2024
Merged

Conversation

dranikpg
Copy link
Contributor

@dranikpg dranikpg commented May 7, 2024

No description provided.

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
@dranikpg
Copy link
Contributor Author

Finally with all the issues resolved, we can have proper defrag 🤓

@dranikpg dranikpg changed the title WIP feat(tiering): Defragmentation feat(tiering): Defragmentation May 29, 2024
Copy link
Collaborator

@romange romange left a comment

Choose a reason for hiding this comment

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

LGTM, minor comments

src/server/tiering/op_manager.cc Outdated Show resolved Hide resolved
ReadOp* info = &pending_reads_.at(offset);

// Reorder base read (offset 0) to be last, so reads for defragmentation are handled last
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you please explain this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we already have a page read for defragmentation pending and some other read for the sub-segment is enqueued, we first must handle the sub-segment read, only then the full page read

Copy link
Collaborator

Choose a reason for hiding this comment

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

I suggest copying this explanation into the comment

bool deleting_full = false;
std::string key_value;
for (auto& ko : info->key_ops) {
for (size_t i = 0; i < info->key_ops.size(); i++) { // more items can be read while iterating
Copy link
Collaborator

Choose a reason for hiding this comment

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

what does it mean more items can be read while iterating ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When we call ReportDelete, it might issue a read for the whole page to trigger defragmentation, which will be added to this list

Copy link
Collaborator

@romange romange May 29, 2024

Choose a reason for hiding this comment

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

please add a comment:
// Note that functions in the loop may append items to info->key_ops during the traversal.

src/server/tiering/op_manager.h Outdated Show resolved Hide resolved
return {full_segment, false /* fragmented */, true /* empty */};
}

if (bin.bytes < kPageSize / 2) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

is it the condition to trigger fragmentation?

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 🤓 Not very sophisticated

src/server/tiering/small_bins.h Show resolved Hide resolved
romange
romange previously approved these changes May 29, 2024
Copy link
Collaborator

@romange romange left a comment

Choose a reason for hiding this comment

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

LGTM, but please add comments that I asked.

@dranikpg
Copy link
Contributor Author

Added comments

@dranikpg dranikpg requested a review from romange May 29, 2024 16:11
@dranikpg dranikpg merged commit 99949ca into dragonflydb:main May 29, 2024
7 checks passed
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