The current SpiderMonkey GC scheduling system gives 30ms per turn to a mark-and-sweep slicing GC, runs a stop-the-world GC shrink every 500 turns and an emergency shrink at 75% full. This patch implements a dynamic time budget for slice calculated as follows:
After the simulation turn the amount of time taken since the beginning is compared to the amount of time the turn is supposed to simulate for: usually this is 200ms. Any extra time, minus 10 ms for network or other overhead ( which may not be needed), is compared with a minimum slice time created by taking 20ms and adding 50% for each 10% the JS context is full, past 50%(back-pressure). So if the JS context is 70% full then the minimum time budget for slice is 20ms * (1 +(0.2*5)) = 40ms.
Further improvement is probably possible by adjusting constants and/or the back-pressure formula.
The emergency shrink at 75% and the 500 turn shrink are removed.
The following performance charts are made from 3 replays with 5 runs averaged together per trend line.