SIGN IN SIGN UP

SSA: Shrink stack preemptively in shuffler

When shuffling we can check if the stack would require shrinking at some
point in the future and if that is the case, we can try to shrink it
immediately.
We can check if shrinking will be required in the following way:
For each non-junk element we know what is it's minimal count in the
target stack. If the current count of an element is lower then the
minimal count, we have a "deficit" for this element. We will need more
of it so it will require that the stack will grow.
If the total deficit is larger than the space we have available (target
size - current size), we are sure the stack will require shrinking at
some point.
B
blishko committed
d50cddacceeb65518c4768bed9cba69b415a3ed9
Parent: 821d9e0