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

pkg/blobserver/diskpacked implement StreamBlobs TODO #1401

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tgulacsi
Copy link
Contributor

Optimize walking blobs for not reading them.
Second part of #1395

@googlebot googlebot added the cla: yes Author has submitted the Google CLA. label Jul 31, 2021
@aviau aviau assigned aviau and unassigned aviau Aug 2, 2021
@aviau aviau self-requested a review August 2, 2021 02:34
@aviau
Copy link
Member

aviau commented Aug 5, 2021

@tgulacsi Can you rebase?

I intend to review this soon, by the way, hoping for this weekend.

Your renewed activity in perkeep is motivating for me, I'd love to keep collaborating on stuff with you :)

Implement the TODO that raised a concert about a lot of garbage created
by reading all the blobs, always.

This now reads only when the blob.ReadFull is called.
data := make([]byte, size)
if _, err := io.ReadFull(r, data); err != nil {
return err
var br *blob.Blob
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually use the short br for blobrefs, but this is a blob.

{
fn := fd.Name()
size, offset := size, offset
if _, err = io.CopyN(ioutil.Discard, r, int64(size)); err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this cause us to read the full blob? Can we just not read it?

fhc.m[fn] = fh
return fh, nil
}
func (fhc *fileHandleCache) Put(fh *fileRefCount) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may just be unfamiliar with the naming for similar datastructures, but what does "put" mean here?

I see that it decreases the refcount and possibly remove the file handle from the cache.

Looking at the code it seems that the maximum number of file handles isn't really enforced?

What if they all have a refcount of 1? What is going to stop us from caching an unlimited of file handles if the user does not read a single blob?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Author has submitted the Google CLA.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants