Skip to content

Prototype big blob package#10

Merged
jcarter3 merged 4 commits intomainfrom
big_blob_package
Mar 24, 2026
Merged

Prototype big blob package#10
jcarter3 merged 4 commits intomainfrom
big_blob_package

Conversation

@jcarter3
Copy link
Copy Markdown
Owner

No description provided.

Comment thread ocilarge/download.go Outdated
if err != nil {
return nil, fmt.Errorf("failed to resolve blob: %w", err)
}
var chunkSize int64 = 1024 * 1024 * 100 // 100MB
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

maybe make configurable?

Comment thread ocilarge/download.go Outdated
Comment thread ocilarge/download.go
}, nil
}

type blobReader struct {
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

since i copied this from the client package, maybe worth moving this to a common place?

Comment thread ocilarge/download.go Outdated
var chunkSize int64 = 1024 * 1024 * 100 // 100MB
buf := make([]byte, chunkSize)
pr, pw := io.Pipe()
go func() {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

A goroutine here honestly feels kind of wrong, especially since cancellation then becomes more complicated 🤔

Shouldn't this be wired up directly into the Read method of the returned BlobReader instead? Especially since you've had to define your own BlobReader type anyways. 🤔

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

and because this is an io.Pipe, it'll naturally back up and block when consumers aren't pulling fast enough anyways, which is exactly the behavior you'd have with this as part of the Read method instead (and the "leftover buffer" being explicit on that end instead of implicit in the hung pipe)

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Ohhh good call

Comment thread ocilarge/upload.go Outdated
dgstr.Hash().Write(buf[:n])

for i := 0; i < 3; i++ { // try writing each chunk three times
_, err = bw.Write(buf[:n])
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It's too bad the BlobWriter interface doesn't have a way for you to be explicit about the offset, etc here so that the interfaces could make sure nothing happens out of order 😞 (so you don't have to get all the way to the end of a 100GiB blob before it tells you that something had a hiccup in the middle)

@jcarter3 jcarter3 marked this pull request as ready for review March 24, 2026 20:23
@jcarter3 jcarter3 merged commit 247897d into main Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants