Creating many small SharedArrayBuffers can easily exceed MaximumLiveMappedBuffers
Categories
(Core :: JavaScript Engine, task, P3)
Tracking
()
People
(Reporter: jandem, Unassigned)
References
(Blocks 1 open bug)
Details
It looks like all SharedArrayBuffers go through js::MapBufferMemory where we check against MaximumLiveMappedBuffers. This limit (1000 on most platforms) is easily exceeded when creating a large number of small SABs.
Someone reported this on Matrix because they ran into this.
Comment 1•5 years ago
|
||
We have several mechanisms that are supposed to work together to avoid OOMing prematurely - limits + vm checks + last-ditch GC - but this system never worked well, it was bolted on.
Random small SABs should not count against that limit I think; we care mostly about the large (6GB, soon to be 8GB) buffers?
| Reporter | ||
Comment 2•5 years ago
|
||
(In reply to Lars T Hansen [:lth] from comment #1)
Random small SABs should not count against that limit I think; we care mostly about the large (6GB, soon to be 8GB) buffers?
I believe the original limit was to prevent exhausting the relatively small number-of-mappings on Linux, because Wasm used different protection flags for different regions in the allocation (and so the kernel couldn't fuse these mappings). Later on this limit was also used to prevent address space exhaustion. Both of these problems don't apply to small SABs, as far as I can tell (?).
Lars, is there a reason we need to use mmap instead of malloc for plain SABs not allocated for Wasm memory? calloc is what we use for plain ArrayBuffers and it could also be more efficient (both memory usage and performance) when code is doing many small allocations.
| Reporter | ||
Comment 3•5 years ago
|
||
Lars and I discussed this a bit more on Matrix. To summarize, I think there are two pieces to look into:
-
Consider removing the mapped-buffer-limit or only keeping a crude limit for
--fuzzing-safeif it bothers fuzzing. We should look at the history of this code to see what changed when, and for what reason. -
For non-Wasm SharedArrayBuffer consider a mode where we use
callocinstead ofmmap. Lars isn't sure whether page alignment is required for SABs but maybe for asm.js.
Comment 4•5 years ago
|
||
It looks like we still support shared memory for asm.js. We could rip that out. (We could rip asm.js out for that matter.)
Comment 5•5 years ago
|
||
I take that back. It looks like there's vestigial code in AsmJS.cpp for shared memory, but I don't think shared memory's supported any more.
Updated•5 years ago
|
| Reporter | ||
Comment 7•3 years ago
|
||
Patches in bug 1778077 implement 2) from comment 3.
Updated•1 year ago
|
| Reporter | ||
Comment 8•1 year ago
|
||
Let's close this. Bug 1778077 fixed the problem for non-Wasm SABs and we also improved the max-buffer heuristic for Wasm in bug 1773225.
Description
•