3 ms·
A useful trick for long lived processes where you also care about GC pauses is to run erlang:garbage_collect(pid) If you’ve got real time requirements you c
by crazydoggers 6y ago
A useful trick for long lived processes where you also care about GC pauses is to run
erlang:garbage_collect(pid)
If you’ve got real time requirements you can often minimize GC impact by choosing when in the process lifecycle the GC occurs.
https://erlang.org/doc/man/erlang.html#garbage_collect-1 https://erlang.org/doc/man/erlang.html#garbage_collect-1
- hinkley 6y agoI had a waveform animation that would get jerky periodically due to the GC sawtooth. Given a relatively fixed cost per frame, the GC would tend to come every N frames, which is the sort of pattern the human brain is good at picking up on. This meant the behavior was perceptually 'worst' when you just sat and stared at the screen, doing nothing else. So I just started forcing a GC any time the buffers were full at the end of the previous frame. The next frame could be drawn entirely from buffer, which only took a couple of milliseconds, reducing the potential jitter from a few frames to maybe half a frame. You'd still get random stutters but there was no pattern to it anymore, unless the network was being very badly behaved (which in this case was useful information). Not only did that smooth out the display but it let us increase the max number of things you could display by a little over half.