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

Split BlobFileState into an immutable and a mutable part #6502

Closed
wants to merge 10 commits into from

Conversation

ltamasi
Copy link
Contributor

@ltamasi ltamasi commented Mar 9, 2020

Summary:
It's never too soon to refactor something. The patch splits the recently
introduced (VersionEdit related) BlobFileState into two classes
BlobFileAddition and BlobFileGarbage. The idea is that once blob files
are closed, they are immutable, and the only thing that changes is the
amount of garbage in them. In the new design, BlobFileAddition contains
the immutable attributes (currently, the count and total size of all blobs, checksum
method, and checksum value), while BlobFileGarbage contains the mutable
GC-related information elements (count and total size of garbage blobs). This is a
better fit for the GC logic and is more consistent with how SST files are handled.

Test Plan:
make check

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@ltamasi has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Contributor

@riversand963 riversand963 left a comment

Choose a reason for hiding this comment

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

LGTM.

Status BlobFileState::DecodeFrom(Slice* input) {
constexpr char class_name[] = "BlobFileState";
Status BlobFileAddition::DecodeFrom(Slice* input) {
constexpr char class_name[] = "BlobFileAddition";
Copy link
Contributor

Choose a reason for hiding this comment

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

Wonder whether this can be class static.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could be done but for now, it's only used in a single method so I think it would make sense to keep it there.

db/blob_file_garbage.h Outdated Show resolved Hide resolved
db/blob_file_garbage_test.cc Outdated Show resolved Hide resolved
});
SyncPoint::GetInstance()->EnableProcessing();

constexpr uint64_t blob_file_number = 678;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: maybe rename constants to kBlobFileNumber or something similar?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not a huge fan of the Google C++ style guide :) but fortunately, for local variables this naming scheme is optional (see https://google.github.io/styleguide/cppguide.html#Constant_Names).

@ltamasi
Copy link
Contributor Author

ltamasi commented Mar 10, 2020

Thanks for the review @riversand963 !

@facebook-github-bot
Copy link
Contributor

@ltamasi has updated the pull request. Re-import the pull request

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@ltamasi has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@ltamasi merged this pull request in f5bc3b9.

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

Successfully merging this pull request may close these issues.

3 participants