-
Notifications
You must be signed in to change notification settings - Fork 6
feat(client): stream parallel downloads to pipes #386
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
Open
alecthomas
wants to merge
3
commits into
main
Choose a base branch
from
aat/parallel-get-stream
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,075
−113
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| // Package punchholelayout captures the memory layout of the macOS SDK's | ||
| // fpunchhole_t via cgo, so tests can verify that the hand-defined Go mirror | ||
| // in package client stays identical to the C struct. | ||
| package punchholelayout | ||
|
|
||
| // Layout describes the size and field layout of a punch-hole argument struct, | ||
| // in bytes. | ||
| type Layout struct { | ||
| Size uintptr | ||
| FlagsOffset uintptr | ||
| FlagsSize uintptr | ||
| ReservedOffset uintptr | ||
| ReservedSize uintptr | ||
| OffsetOffset uintptr | ||
| OffsetSize uintptr | ||
| LengthOffset uintptr | ||
| LengthSize uintptr | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| //go:build darwin && cgo | ||
|
|
||
| package punchholelayout | ||
|
|
||
| /* | ||
| #include <sys/fcntl.h> | ||
| */ | ||
| import "C" | ||
|
|
||
| import "unsafe" | ||
|
|
||
| // SDKLayout returns the layout of struct fpunchhole_t as compiled from the | ||
| // SDK's <sys/fcntl.h>. | ||
| func SDKLayout() (Layout, bool) { | ||
| var v C.fpunchhole_t | ||
| return Layout{ | ||
| Size: unsafe.Sizeof(v), | ||
| FlagsOffset: unsafe.Offsetof(v.fp_flags), | ||
| FlagsSize: unsafe.Sizeof(v.fp_flags), | ||
| ReservedOffset: unsafe.Offsetof(v.reserved), | ||
| ReservedSize: unsafe.Sizeof(v.reserved), | ||
| OffsetOffset: unsafe.Offsetof(v.fp_offset), | ||
| OffsetSize: unsafe.Sizeof(v.fp_offset), | ||
| LengthOffset: unsafe.Offsetof(v.fp_length), | ||
| LengthSize: unsafe.Sizeof(v.fp_length), | ||
| }, true | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| //go:build !darwin || !cgo | ||
|
|
||
| package punchholelayout | ||
|
|
||
| // SDKLayout reports false: without cgo on darwin there is no SDK struct to | ||
| // compare against. | ||
| func SDKLayout() (Layout, bool) { | ||
| return Layout{}, false | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| //go:build darwin | ||
|
|
||
| package client | ||
|
|
||
| import ( | ||
| "os" | ||
| "runtime" | ||
| "unsafe" | ||
|
|
||
| "github.com/alecthomas/errors" | ||
| "golang.org/x/sys/unix" | ||
| ) | ||
|
|
||
| // fpunchhole mirrors struct fpunchhole_t from <sys/fcntl.h>. x/sys/unix | ||
| // defines F_PUNCHHOLE for darwin but neither the argument struct nor a | ||
| // wrapper, so we pass the pointer through FcntlInt the same way | ||
| // unix.FcntlFstore does for F_PREALLOCATE. | ||
| type fpunchhole struct { | ||
| flags uint32 // fp_flags: no flags are currently defined | ||
| reserved uint32 | ||
| offset int64 | ||
| length int64 | ||
| } | ||
|
|
||
| // punchHole deallocates the byte range [off, off+length) of f, leaving a hole | ||
| // that reads as zeros without changing the file size. off and length must be | ||
| // multiples of the filesystem block size. Requires APFS. | ||
| func punchHole(f *os.File, off, length int64) error { | ||
| arg := fpunchhole{offset: off, length: length} | ||
| //nolint:gosec // pointers fit in int on darwin; the same pattern unix.FcntlFstore uses | ||
| _, err := unix.FcntlInt(f.Fd(), unix.F_PUNCHHOLE, int(uintptr(unsafe.Pointer(&arg)))) | ||
| runtime.KeepAlive(&arg) | ||
| return errors.Wrap(err, "punch hole") | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 newly added helper comment is in a top-level test file, and
/workspace/cachew/AGENTS.md:21says, “NEVER add comments to top-level tests.” Leaving this and the other new top-level test comments in this commit violates the repo’s documented review rules, so please remove the comment rather than documenting test helpers here.Useful? React with 👍 / 👎.