-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
Eliminate the copying of blobs when serving reads from the cache #10297
Closed
Closed
Changes from 6 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
c4b8273
Eliminate the copying of blobs when serving reads from the cache
gangliao 10f91dc
Follow the comments
gangliao 6272052
Cleanup
gangliao 3cc692e
Change to static_cast
gangliao 1648db1
Add new TransferTo
gangliao 4514dae
Fix clang-format
gangliao 01c1d8f
Follow the comments
gangliao 008bc9b
Follow the comments
gangliao 558087e
Cleanup
gangliao 4c75c32
Follow the comments
gangliao 3369e7e
Update ReleaseCacheHandle()
gangliao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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'm wondering if there's a better way to do this. We could consider adding a
PinnableSlice::PinSlice
overload that takes aSlice
and aCachableEntry
; however, this would involve exposingCachableEntry
(which is currently an internal/implementation class) in the public API. So we probably wouldn't want to do that.What I'm thinking is using the existing
PinSlice(const Slice& s, CleanupFunction f, void* arg1, void* arg2)
overload (withReleaseCacheHandle
as the fn, and the cache and cache handle as args, like below; note that we're guaranteed to be dealing with a cached value here, so there is no need for an "own value" branch), and then make theCachableEntry
relinquish ownership of the handle by callingblob_entry.TransferTo(nullptr);
. What do you guys think? Bit of a hack I suppose (and we would definitely want to explain what's happening in a comment) but we wouldn't have to add aTransferTo
overload toCachableEntry
for just this specific use case.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.
BTW, since there is no "own value" case here, we could also consider moving from
CachableEntry
toCacheHandleGuard
. We would have to add aTransferTo(Cleanable*)
method toCacheHandleGuard
though b/c it doesn't have one rnThere 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.
Semi-related to this: we could also think about eliminating the copy that happens when we insert a blob into the cache (i.e. the
string::assign
that happens inBlobSource::PutBlobIntoCache
). This would most likely involve a change toBlobFileReader
's interface but that shouldn't be a big deal now that we always read blobs via theBlobSource
layer. But this is definitely for later (could be a separate follow-up task)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've thought about it this way before. But
ReleaseCacheHandle
is private. So we need to expose it, right?Or, we plan to use a lambda function in here...
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.
Sure, we can use a lambda; I think it's cleaner than taking a dependency on
CachableEntry
just for the purposes of reusingReleaseCacheHandle
.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.
SGTM. When I first thought about this, the
ReleaseCacheHandle
being private was my concern. I am fine with either.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.
If so, who will take ownership? Oh I see. That's really similar to eliminate the copying of blobs when serving reads
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.
todo: an additional stretch task for 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.
We could look at e.g. how
BlockContents
orUncompressionDict
are used for inspiration. BTW, as part of this additional task, we could also address this TODO: https://github.com/facebook/rocksdb/blob/main/db/blob/blob_source.cc#L68-L69