-
Notifications
You must be signed in to change notification settings - Fork 166
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
Refine blob cache related code #309
Conversation
Signed-off-by: Connor1996 <[email protected]>
Signed-off-by: Connor1996 <[email protected]>
@@ -725,10 +724,6 @@ Status TitanDBImpl::GetImpl(const ReadOptions& options, | |||
options.snapshot->GetSequenceNumber(), | |||
s.ToString().c_str()); | |||
} | |||
if (s.ok()) { | |||
value->Reset(); | |||
value->PinSelf(record.value); |
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.
Here introduces one memory copy
} else { | ||
buffer->PinSlice(blob, OwnedSlice::CleanupFunc, blob.release(), nullptr); | ||
value->PinSlice(record->value, OwnedSlice::CleanupFunc, blob.release(), |
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.
So the new logic will return the value only and the old code returns the whole kv value pair?
If that, should the caller of Get() be aware of this change?
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.
This does not feel right. BlobRecord::DecodeFrom()
assumes the buffer contains both key and value. While, I guess this PR wants to optimize the cache utilization by storing value only. In addition to changing the PR description and func comment, we also need to change the decoding logic of BlobRecord
accordingly.
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.
So the new logic will return the value only and the old code returns the whole kv value pair?
Old code reads the kv value pair by record
field. New logic still can read the kv value pair by record
field. The record
is just a slice refering to the pinnable slice underlying buffer. The value pinnable slice holds the underlying buffer, while as a slice I let it only read out value from it instead of the whole buffer.
Should the caller of Get() be aware of this change?
Previously, caller wouldn't use the buffer slice directly as they don't know the content. Key and value are read by record
field. So no need to change and I just change the naming buffer
to value
We also need to change the decoding logic of BlobRecord accordingly.
No need. When calling BlobRecord::DecodeFrom()
, the buffer doesn't contain both key and value.
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.
LGTM
Signed-off-by: Connor1996 <[email protected]>
This PR does:
Get