3 ms·
> i'm curious if allocating a memory ballast would have helped discord in this case? No. Twitch's ballast is because > At steady state, our application was tr
by masklinn 6y ago
> i'm curious if allocating a memory ballast would have helped discord in this case?
No. Twitch's ballast is because
> At steady state, our application was triggering ~8–10 garbage collection (GC) cycles a second (400–600 per minute).
Go's GC triggers a collection every time the heap size doubles (until that has no return on investment and it just grows the heap). By creating a very large heap up-front they'd give themselves breathing room to avoid being just on the edge of (but remaining below) a resize, leading to continuous collections keeping them below.
But Discord had the opposite issue: a large cache means a large heap size, in a steady state that would be extremely stable (since the heap size is a function of cache size, once the cache is full the only changes are replacing old keys for news). As a result, the only GC would be the mandatory periodic run, which would have to go through the entire (very large) heap, causing STW latency spikes every 2mn.