Twitch.tv live stream wasm web worker has high memory fluctuations
Categories
(Core :: JavaScript: GC, defect, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox65 | --- | affected |
People
(Reporter: ke5trel, Unassigned)
References
(Blocks 1 open bug)
Details
(Keywords: memory-footprint, Whiteboard: [MemShrink:P2])
Attachments
(3 files)
Viewing a live Twitch stream can see memory fluctuate significantly, averaging 750MB and exceeding 1GB at the peaks while Chromium remains relatively stable at 350MB (see graph). Testing was done on Ubuntu 18.10 with each browser displaying the same Twitch stream simultaneously. about:memory seems to indicate this is due to a wasm web worker with most allocations in class(ArrayBuffer) malloc-heap. https://cvp.twitch.tv/2.6.29/wasmworker.min.js
Comment 2•6 years ago
|
||
From the picture, this smells like memory growth followed by some kind of GC or (more likely) malloc coalescing, though I've not looked at the memory report yet.
Comment 3•6 years ago
|
||
Are the ArrayBuffers the normal kind (with the fluctuations under malloc-heap/elements -- normal) or the special wasm/asm.js kind (with the fluctuations under non-heap/elements/wasm or malloc-heap/elements -- asm.js)? If it's the former, than I would expect the difference we're seeing here relates to worker GC scheduling and is not directly tied to wasm.
The fluctuating ArrayBuffers are the normal kind (malloc-heap/elements/normal).
Comment 5•6 years ago
|
||
Ok, since, last I heard, worker GC scheduling is a known issue with possible plans to work on, I'll tentatively kick this over to the GC component.
Updated•6 years ago
|
Comment 6•6 years ago
|
||
The memory gradually ramping up over 5 minutes then dropping is weird. I wonder what sort of limit we're hitting. This sounds like either an issue with mallocbytes not being updated, so the GC doesn't realize it needs to run, or maybe the memory was GCed, but some communication back to the main thread that is needed to finally release things is being delayed. I guess the latter doesn't sound too likely given how long and how regular the spike then drop is.
Updated•6 years ago
|
Comment 7•6 years ago
|
||
This is probably due to the way we track malloc memory associated with GC things. We don't have size information when we free malloc memory so we just track total allocation size since the last GC. If this hits a threshold we trigger a GC and increase the threshold. I suspect that GC is freeing the memory, but because we keep hitting this threshold we keep increasing it, so GCs become increasingly rare. Ideally we'd have retained size information which we would use to set the threshold appropriately.
Updated•6 years ago
|
Firefox 66 still allocates 1 GiB of memory for 1 Twitch.tv tab.
I think this bug affects other video sites too.
Comment 9•5 years ago
|
||
This doesn't seem to happen in nightly any more, but it didn't always reproduce for me. Can you check whether this is still a problem?
Reporter | ||
Comment 10•5 years ago
|
||
Reporter | ||
Comment 11•5 years ago
|
||
I can no longer reproduce this in latest Nightly on Ubuntu 19.04.
Fixed by Bug 1569560.
Comment 12•5 years ago
|
||
(In reply to Kestrel from comment #11)
\o/
Thanks for confirming.
Description
•