Improving Firefox responsiveness on macOS
Firefox 103 on macOS became much more responsive under load after its customized jemalloc allocator stopped using the deprecated OSSpinLock, which spins and yields in user space and can nearly live-lock on busy systems. The public os_unfair_lock replacement sleeps immediately on contention and regressed some benchmarks by up to 30%. The fix uses the undocumented os_unfair_lock_with_options() with OS_UNFAIR_LOCK_ADAPTIVE_SPIN and OS_UNFAIR_LOCK_DATA_SYNCHRONIZATION to get kernel-space adaptive spinning, which matches OSSpinLock on idle machines, is far better under load and uses less power. Pre-10.15 systems fall back to os_unfair_lock with manual x86-64 pause-instruction spinning, and fork() safety requires pthread_atfork handlers because the lock stores mach thread IDs.
Related posts
- Bun 1.4
Bun mediumAdept
Bun 1.4 adds 1,517 newly passing Node.js test-suite tests, fixes over 2,900 issues, and rewrites Bun from Zig to Rust. JavaScriptCore now uses an extended mimalloc instead of libpas, adding a scavenger thread, partial page clearing and better lazy zeroing. Together with GC timer tuning, segmented-array Strong roots and fewer futex calls, this cuts idle CPU 5x, HTTP server peak memory 13–48%, and Linux startup time in half. New APIs include Bun.Image, Bun.WebView, Bun.markdown, Bun.cron and Bun.Terminal, plus Markdown CPU, heap and bundle profiles and a cross-platform memoryPressure event built on kqueue, PSI and Windows resource notifications.
- Improving Firefox stability with this one weird trick
Mozilla Hacks mediumAdeptOut-of-memory crashes on Windows are often caused by exhaustion of commit space rather than physical RAM, since Windows forbids overcommit and graphics drivers commit memory for texture backing that is rarely used. Firefox 105 stops crashing immediately on a failed allocation and instead stalls briefly and retries, giving Windows time to grow the swap file or letting a memory-hungry content or GPU process die and free memory. The change cut out-of-memory browser crashes per usage hour by more than 70%, at the cost of brief jank and a small rise in tab crashes that Mozilla is now working to reduce.
- Bun v0.1.12
Bun mediumAdept
Bun v0.1.12 fixes stability problems in `bun install` that caused crashes or hangs roughly once per 80,000 cold package installs on Linux. Four bugs were behind them: a threadpool deadlock, an HTTP client suspend/resume bug, an empty-JSON crash, and DNS failure crashes. The fixes were a lock-free MPSC queue, eventfd/machport readiness notification instead of a futex, and an HTTP client rewrite on uSockets and getaddrinfo. `fetch()` now reaches 155,000 req/s on Linux x64, which is 24x Node v18.9 and 4.5x Deno. The release also adds `read` helpers to `bun:ffi`, with a breaking change to a 52-bit integer pointer representation via a WebKit DOMJIT change, picks up 2x faster `String.prototype.replace` from WebKit, and moves `crypto.getRandomValues` to BoringSSL.
- Improved Process Isolation in Firefox 100
Mozilla Hacks hardMasterFirefox 100 enables Win32k Lockdown on Windows, using PROCESS_MITIGATION_SYSTEM_CALL_DISABLE_POLICY to block web content processes from calling the historically exploitable win32k.sys kernel APIs. Getting there meant moving every graphics and widget operation out of the content process. Painting moved to WebRender in the GPU process, Canvas 2D is recorded and replayed over IPC, and WebGL gained a validating child/parent API. Form controls are now drawn by Firefox itself instead of as native widgets, complex-script line breaking is forwarded over IPC with caching, and a fix stops injected third-party DLLs from breaking COM. Skipping those DLLs also made opening new tabs about 15% faster, and equivalent lockdowns of WindowServer on macOS and X11 on Linux sped process startup by 30-70% on Mac.
- Eliminating Data Races in Firefox – A Technical Report
Mozilla Hacks hardMasterMozilla deployed ThreadSanitizer across Firefox's C/C++ and Rust code, using a compiled-in suppression list to gate new races in CI while legacy ones were triaged toward a "no data races" policy. So-called benign races are easily misclassified, yet fixing them proved cheap: most fixes were atomics conversions, suppressions or code removal. Notable finds include lost writes from adjacent bitfields (fixed with a MOZ_ATOMIC_BITFIELDS macro), a PreferencesWriter race likely corrupting prefs.js, and fragile late-validated racy reads. Rust needed -Zbuild-std hacks for instrumentation but surfaced only two pure-Rust races, in parking_lot and a WebRender shim, both in unsafe low-level code.