1Jajen1/propCheck

Improve shrinking long sequences

Closed this issue · 2 comments

Shrinking always terminates if implemented correctly, but in the meantime due to missing lazyness very large lists will be generated and sometimes even retained in memory. The worst offender here is shrinkList, it would be much better if it operated on the Sequence data-type and only forced loading the entire thing if it's needed (when the list cannot be cut down to smaller sizes anymore, or that cutting had no effect). This is not an easy task because the implicit strictness of everything in kotlin makes for some fun situations (for example m(): Sequence is not lazy in generation, but sequenceOf(Unit).flatMap(m) is) It is quite tricky to find all of those situations, but it needs to be done to get shrinking back to a performant level on large sequences.

On second thought: Changing shrinkList to Sequence might not help as much (since we need the lists size, hence the full list) but something that definitly helps is lazy creation of smaller lists (currently the result is built up non-lazy for chunked lists).

Fixed by #16 albeit in an ugly way