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

fetch size according to RegisteredSealProof #5167

Closed
wants to merge 1 commit into from

Conversation

acautman
Copy link

@acautman acautman commented Dec 10, 2020

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

@acautman acautman changed the title write size according to RegisteredSealProof fetch size according to RegisteredSealProof Dec 10, 2020
Copy link
Contributor

@magik6k magik6k left a 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)
Copy link
Contributor

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}

Copy link
Contributor

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)
Copy link
Contributor

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

Suggested change
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

@magik6k
Copy link
Contributor

magik6k commented Dec 10, 2020

(applied suggestions in #5177)

@magik6k magik6k closed this Dec 10, 2020
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