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

Eliminate some allocations/copies around the blob cache #10647

Closed
wants to merge 6 commits into from

Conversation

ltamasi
Copy link
Contributor

@ltamasi ltamasi commented Sep 8, 2022

Summary:
Historically, BlobFileReader has returned the blob(s) read from the file
in the PinnableSlice provided by the client. This interface was
preserved when caching was implemented for blobs, which meant that
the blob data was copied multiple times when caching was in use: first,
into the client-provided PinnableSlice (by BlobFileReader::SaveValue),
and then, into the object stored in the cache (by BlobSource::PutBlobIntoCache).
The patch eliminates these copies and the related allocations by changing
BlobFileReader so it returns its results in the form of heap-allocated BlobContents
objects that can be directly inserted into the cache. The allocations backing
these BlobContents objects are made using the blob cache's allocator if the
blobs are to be inserted into the cache (i.e. if a cache is configured and the
fill_cache read option is set). Note: this PR focuses on the common case when
blobs are compressed; some further small optimizations are possible for uncompressed
blobs.

Test Plan:
make check

@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

@ltamasi has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@ltamasi has imported this pull request. If you are a Meta 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.

@ltamasi
Copy link
Contributor Author

ltamasi commented Sep 8, 2022

Thanks a lot for the review @riversand963 !

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