On Mon, Jan 25, 2021 at 8:52 AM Alex Crane <[email protected]> wrote: > > I have recently been using the x/image/riff library to inspect some large > RIFF files - typically I am interested in all chunks except the data chunk. I > have found with large files the performance is quite poor. Looking into the > code it does a `got, z.err = io.Copy(ioutil.Discard, z.chunkReader)` to get > the Reader into the right place if the previous chunk data has not been fully > read/drained. For an *os.File, this can understandably be very slow if the > chunk data is large. I have found if I do a type assertion for io.ReadSeeker > on the underlying Reader and Seek instead, in that case the performance is > dramatically improved (a 99% improvement in CPU time in a benchmark with a > 128MB file). There can also be an optimisation to recognise when a chunk is > the last chunk and therefore not need to drain it (can be significant for > many media RIFF types which tend to put the large data chunk last) before > returning io.EOF, but with the Seek optimisation this is less significant. > > I can attach the diff. It's rather small. Is this something that is worth > contribution? I'd rather not maintain a branch, though this would be my first > contribution, so require some setup I'd rather not do if this isn't > considered worth contributing.
Sounds like a reasonable patch to me. Please don't send a diff. Please use a GitHub pull request or a Gerrit change as described at https://golang.org/doc/contribute.html. Thanks. Ian -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAOyqgcU9_MgGohgutZv159%2BsxzE%2Bk5vUUq9JruW75ocAu6v5SQ%40mail.gmail.com.
