go-hep / hep

hep is the mono repository holding all of go-hep.org/x/hep packages and tools
https://go-hep.org
BSD 3-Clause "New" or "Revised" License
231 stars 36 forks source link

groot/internal/rcompress: better buffer reuse #712

Open sbinet opened 4 years ago

sbinet commented 4 years ago

we should consider introducing a better buffer+reader reuse strategy (e.g. for decompressor that support Reseting their readers)

this would reduce memory allocation and memory pressure. this would then reduce the amount of work needed by the garbage collector.

issues:

bburghgr commented 5 days ago

I stumbled upon this when playing around with some benchmarks that read a file using zlib compression, and a sync.Pool seems to work well enough. I think I can put something together for the various Resetters, if there's an interest.

In my toy benchmark, it reduces memory allocation (in my toy test) by about 60%, with a corresponding reduction in the number of GC cycles. Sadly, it doesn't seem to improve the event rate as much as I'd have hoped. On my machine, a file that needs ~30 seconds to process is sped up to ~28 seconds (wall time). I think I'm actually bottlenecked on something else, I'll open a separate issue describing what that may be.

sbinet commented 2 days ago

yes, if you have a PR that exercizes this, it'd be great. (bonus points if it comes w/ benchstat data from groot-bench)

from your comment, I suspect that's what I tried to achieve with sbinet/pzlib?