JAB-033: mmap/Buf objects must tell the collector what they pin — GC never feels a leaked mapping

Now
DONE
Now
OPEN
Sev
HIGH
Ask
gritzko
Env
webkitgtk-4.1 JSC C API, Linux vm.max_map_count=65530
Rev
///jab#8335085b
Rep
///jab
See
BRO-046

A jab mapping is a Uint8Array over foreign pages, and the collector is told NOTHING about them: 62749 live RO maps of a 183-byte file survived two hours in one process without a single collection (BRO-046). JSC lets an object declare that it pins a native resource; jab's map/Buf objects must do it, so a program that maps in a loop gets collected instead of dying at vm.max_map_count. The unit that matters is the MAPPING COUNT, not the byte size — 62749 VMAs is fatal while the 250 MB they carry is nothing.

Input

Context

Found while diagnosing BRO-046: an idle be todo pager leaked 19.2 RO ULOG mappings/sec and wedged at 65531 VMAs, 92% of its CPU in a kernel mmap that could no longer succeed.

Goals

A JS program that maps in a loop and drops the handles must be collected before it exhausts VMAs or fds — the collector must know a mapping is expensive.

Constraints

jab/ is read-only reference for everything else in the fleet; this ticket is the exception that edits it, and only the binding layer.

WIP

Design decisions

TODOs

Blockers and bummers

Outcome