I'm using nippy extensively in a project. A huge source of garbage is coming from functions like write-vec (I'm serializing a lot of small vectors). The issue seems to be -run! and -run-kv!, which are implemented as macros.
Because the function expression is inlined within the function passed to reduce, this allocates a new closure on each iteration of reduce / reduce-kv.
Suggestion (easy): Make -run! / -run-kv! functions instead of macros (or bind the passed in function to a variable in the macros), which will eliminate the allocation on for each element (in favor of a single closure allocated per vector/map/etc).
If you'll accept a pull request, I'd be happy to write something up.
I'm using nippy extensively in a project. A huge source of garbage is coming from functions like write-vec (I'm serializing a lot of small vectors). The issue seems to be -run! and -run-kv!, which are implemented as macros.
Because the function expression is inlined within the function passed to reduce, this allocates a new closure on each iteration of reduce / reduce-kv.
Suggestion (easy): Make -run! / -run-kv! functions instead of macros (or bind the passed in function to a variable in the macros), which will eliminate the allocation on for each element (in favor of a single closure allocated per vector/map/etc).
If you'll accept a pull request, I'd be happy to write something up.
Thanks!