diff options
| author | Will Hawkins <[email protected]> | 2021-12-18 01:15:50 -0500 |
|---|---|---|
| committer | Will Hawkins <[email protected]> | 2021-12-18 01:15:50 -0500 |
| commit | c6574f4232efe259f225d443df5db442fa240052 (patch) | |
| tree | 0c7c30e7d78199c4658c4b9488ab4d3044b07dc9 | |
| parent | 1ee83b005be490ff693be99b4e6359efec642fcd (diff) | |
Performance (Try 3): Experiment with preallocating buffers.
| -rw-r--r-- | lbc/lbc.go | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -4,6 +4,7 @@ import ( "context" "fmt" "io" + "io/ioutil" "net/http" "sync/atomic" ) @@ -90,8 +91,9 @@ func (lbd *LoadBearingConnectionDownload) doDownload(ctx context.Context) { lbd.valid = false return } + buff := make([]byte, 500*1024*1024) cr := &countingReader{n: &lbd.downloaded, ctx: ctx, readable: get.Body} - _, _ = io.ReadAll(cr) + _, _ = io.CopyBuffer(ioutil.Discard, cr, buff) lbd.valid = false get.Body.Close() if lbd.debug { |
