googleapis / google-api-go-client

Auto-generated Google APIs for Go.
https://pkg.go.dev/google.golang.org/api
BSD 3-Clause "New" or "Revised" License
4.03k stars 1.13k forks source link

gensupport: allow passing in buffer for uploads to reduce allocations #638

Open zimnx opened 4 years ago

zimnx commented 4 years ago

When uploading lots of files using ObjectStorage.Insert(), each file allocates his own buffer. This results in increased CPU usage and high RSS memory.

Graph below shows how many space was allocated during upload of ~30k of 10MB files: Selection_132

User should be able to pass his own buffer and be responsible for allocations or library shouldn't be so wasteful.

Pull request which adds user facing insert option is here: #632, I was asked to an open issue to discuss it. cc. @tritone @codyoss

codyoss commented 4 years ago

@zimnx Thanks!