When generating moderately large values there is some LazySeq churn that could be avoided. For example, the following snippet allocates over 15GB (measured with async-profiler):
(core/let [g (vector (not-empty string-alphanumeric) 1000 5000)]
(time
(dotimes [seed 50]
(dorun (generate g 100 seed)))))
The pattern of generating multiple (increasingly larger) values is common with quick-check (via deftest et al).
Many generators are built on top of choose
, and there is an opportunity to reduce churn by special casing shrink-int
for longs (which should be the common case compared to big ints).
I have a patch that decreases total allocations of the repro above by ~15% and speed up the run time by ~25% (measured on jdk 25, with -Xmx512m -XX:+UseSerialGC
to decrease variance). Happy to share it.