fix: reclaim isolate host RSS on oneshot user-worker retirement - #722
fix: reclaim isolate host RSS on oneshot user-worker retirement#722samvallad33 wants to merge 1 commit into
Conversation
Retired workers already leave the pool (activeUserWorkersCount hits 0) while V8/host pages stay resident on the worker thread. Decommit the isolate and purge that thread's allocator after JsRuntime drop.
|
I built both Environment: linux/arm64 (Docker Desktop on macOS, 64 GiB VM), container capped at 3 GiB, Results after 300 retirements (sampled every 25;
Tail slope (retirements 150→300): ~837 KiB/retirement on main vs ~201 KiB/retirement with this PR. All 600 requests across both runs returned 200. Latency cost of the reclaim: 50 sequential requests post-warm-up averaged 93 ms/req (main) vs 97 ms/req (this PR) — within run-to-run noise for a single pass in my setup. Two observations:
Harness (repro function + measurement script) and raw CSVs: https://gist.github.com/da1suk8/53947f7182ab4aa9f4c5799ef4e67bd6 — happy to run other configurations. |
Oneshot retirement already drives
activeUserWorkersCountto 0. Host RSS still grows ~2.5 MiB per isolate.The worker is gone from the pool; the isolate's host pages are not. V8 leaves committed heap on the pinned worker thread, and that thread's allocator never returns those pages (
mi_collect/malloc_trim/malloc_zone_pressure_relief).EdgeRuntime.miCollect()only purges the main worker.This decommits the isolate on termination and drops host allocator pages in
DenoRuntime::dropafterJsRuntimedispose, on the same thread that owned the isolate.test_oneshot_retirement_drops_user_workerchecks the pool count hits 0 after oneshot shutdown. It does not measure RSS.Fixes #719