We've stumbled upon a case where performance is left on the table in io.CopyBuffer when copying from an archive/zip.checksumReader to an *os.File:
var dst *os.File // ...
var src *zip.checksumReader // ...
var buf [32 * 1024]byte
io.CopyBuffer(dst, src, buf[:])
In this case, profiles [1] show that buf is unused, and io.CopyBuffer ends up allocating in a child call. The allocations take up 8% of cycles in an exemplar of a fast compilation step (which uses an auxiliary Go binary featuring zip files) at our company.
We can work around this problem now that we've discovered it using the struct hack mentioned in #16474, but this leaves performance on the table for others that copy from zip files to real files.
[1]:

We've stumbled upon a case where performance is left on the table in
io.CopyBufferwhen copying from anarchive/zip.checksumReaderto an*os.File:In this case, profiles [1] show that
bufis unused, andio.CopyBufferends up allocating in a child call. The allocations take up 8% of cycles in an exemplar of a fast compilation step (which uses an auxiliary Go binary featuring zip files) at our company.We can work around this problem now that we've discovered it using the struct hack mentioned in #16474, but this leaves performance on the table for others that copy from zip files to real files.
[1]: