-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
Compaction filter support for (new) BlobDB #7974
Compaction filter support for (new) BlobDB #7974
Conversation
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.
@riversand963 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
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.
Thanks a lot for the PR @riversand963 ! Could you also update db_bench
and db_stress
/ db_crashtest.py
so they allow using compaction filters with the new BlobDB?
db/compaction/compaction_iterator.cc
Outdated
} | ||
if (CompactionFilter::Decision::kUndetermined == filter) { | ||
filter = CompactionFilter::Decision::kKeep; | ||
} else if (CompactionFilter::Decision::kChangeBlobIndex == filter && |
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.
👍
The same holds for kIOError
as well (i.e. only the stacked BlobDB's internal filter could potentially return it).
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.
I think that's added already.
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.
Sorry, I might be missing something; where is it checked? I can see an assertion further down but not a check like this...
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.
Oh I see you are referring to returning an error. Just added.
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.
Again, maybe I'm misreading the code but now I think we have two checks for CompactionFilter::Decision::kChangeBlobIndex == filter && !compaction_filter_->IsStackedBlobDbInternalCompactionFilter()
? If so, we could remove this one (line 282-283)
Thanks @ltamasi for the review. Can this be in a separate PR? |
Sure, absolutely! Thanks! |
@riversand963 has updated the pull request. You must reimport the pull request before landing. |
39e5991
to
0bb355e
Compare
@riversand963 has updated the pull request. You must reimport the pull request before landing. |
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.
@riversand963 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Thanks @ltamasi for the detailed review! |
@riversand963 has updated the pull request. You must reimport the pull request before landing. |
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.
@riversand963 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
@riversand963 has updated the pull request. You must reimport the pull request before landing. |
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.
@riversand963 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
@riversand963 has updated the pull request. You must reimport the pull request before landing. |
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.
@riversand963 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
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.
Thanks once again for the change @riversand963 !
|
||
namespace ROCKSDB_NAMESPACE { | ||
|
||
class DBBlobCompactionTest : public DBTestBase { |
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.
Thanks for the really comprehensive unit tests! This is awesome :)
db/blob/db_blob_compaction_test.cc
Outdated
class DummyStackedBlobDbCompactionFilter : public CompactionFilter { | ||
public: | ||
explicit DummyStackedBlobDbCompactionFilter() = default; | ||
const char* Name() const override { | ||
return "rocksdb.compaction.filter.dummy.stacked.blobdb"; | ||
} | ||
bool IsStackedBlobDbInternalCompactionFilter() const override { return true; } | ||
}; |
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.
I think this is no longer in use
db/compaction/compaction_iterator.cc
Outdated
} | ||
if (CompactionFilter::Decision::kUndetermined == filter) { | ||
filter = CompactionFilter::Decision::kKeep; | ||
} else if (CompactionFilter::Decision::kChangeBlobIndex == filter && |
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.
Again, maybe I'm misreading the code but now I think we have two checks for CompactionFilter::Decision::kChangeBlobIndex == filter && !compaction_filter_->IsStackedBlobDbInternalCompactionFilter()
? If so, we could remove this one (line 282-283)
761f270
to
1a2d299
Compare
@riversand963 has updated the pull request. You must reimport the pull request before landing. |
Thanks @ltamasi for the review! |
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.
@riversand963 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
@riversand963 merged this pull request in cef4a6c. |
Summary: Allow applications to implement a custom compaction filter and pass it to BlobDB. The compaction filter's custom logic can operate on blobs. To do so, application needs to subclass `CompactionFilter` abstract class and implement `FilterV2()` method. Optionally, a method called `ShouldFilterBlobByKey()` can be implemented if application's custom logic rely solely on the key to make a decision without reading the blob, thus saving extra IO. Examples can be found in db/blob/db_blob_compaction_test.cc. Pull Request resolved: facebook#7974 Test Plan: make check Reviewed By: ltamasi Differential Revision: D26509280 Pulled By: riversand963 fbshipit-source-id: 59f9ae5614c4359de32f4f2b16684193cc537b39
Allow applications to implement a custom compaction filter and pass it to BlobDB.
The compaction filter's custom logic can operate on blobs.
To do so, application needs to subclass
CompactionFilter
abstract class and implementFilterV2()
method.Optionally, a method called
ShouldFilterBlobByKey()
can be implemented if application's custom logic rely solelyon the key to make a decision without reading the blob, thus saving extra IO. Examples can be found in
db/blob/db_blob_compaction_test.cc.
Test plan:
make check