-
Notifications
You must be signed in to change notification settings - Fork 1.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
fetch size according to RegisteredSealProof #5167
Conversation
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.
Thanks for this PR. Just a couple of comments - I like this idea
@@ -123,6 +149,12 @@ func (r *Remote) AcquireSector(ctx context.Context, s storage.SectorRef, existin | |||
} | |||
defer releaseStorage() | |||
|
|||
var iosize uint64 = 0 | |||
ssize, err := GetIoSizeByProofType(s.ProofType) |
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.
I'd do iosize = 32 << 10; if s.ProofType.SectorSize() > 8 << 20 {iosize=1<<20}
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 way we can drop GetIoSizeByProofType from above)
@@ -276,12 +308,57 @@ func (r *Remote) fetch(ctx context.Context, url, outname string) error { | |||
case "application/x-tar": | |||
return tarutil.ExtractTar(resp.Body, outname) | |||
case "application/octet-stream": | |||
return files.WriteTo(files.NewReaderFile(resp.Body), outname) | |||
return WriteWithSize(files.NewReaderFile(resp.Body), outname, iosize) |
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 used the files api to make things simpler. Instead of duplicating the code below, we can just do
return WriteWithSize(files.NewReaderFile(resp.Body), outname, iosize) | |
f, err := os.Create(outname) | |
defer f.Close() | |
if err != nil { | |
return err | |
} | |
_, err = io.CopyBuffer(f, resp.Body, make([]byte, iosize)) | |
if err != nil { | |
return err | |
} | |
return nil |
(applied suggestions in #5177) |
write size according to RegisteredSealProof,default 32K size may result in low performance,when sector size is 512M/32G/64G,increase write size to 1M