-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
Introduce a dedicated class to represent blob values #10571
Conversation
…est.GetBlobsFromSecondaryCache
@ltamasi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
@ltamasi has updated the pull request. You must reimport the pull request before landing. |
@ltamasi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
|
||
std::unique_ptr<BlobContents> BlobContents::Create( | ||
CacheAllocationPtr&& allocation, size_t size) { | ||
return std::unique_ptr<BlobContents>( |
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.
Can we use std::make_unique
?
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.
Unfortunately, make_unique
/ make_shared
don't work when the constructor is private, and making them a friend
isn't an option either because the name of the actual low-level method that would call the constructor is implementation-defined.
Summary:
The patch introduces a new class called
BlobContents
, which representsa single uncompressed blob value. We currently use
std::string
for thispurpose;
BlobContents
is somewhat smaller but the primary reason for adedicated class is that it enables certain improvements and optimizations
like eliding a copy when inserting a blob into the cache, using custom
allocators, or more control over and better accounting of the memory usage
of cached blobs (see #10484).
(We plan to implement these in subsequent PRs.)
Test Plan:
make check