---
title: "Improving Firefox responsiveness on macOS"
description: "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."
url: "https://swe.quest/articles/improving-firefox-responsiveness-on-macos-b8cb4da3ea0ad313"
canonical: "https://hacks.mozilla.org/2022/10/improving-firefox-responsiveness-on-macos/"
source: "Mozilla Hacks"
published: "2022-10-10"
difficulty: "hard"
kind: "Case study"
reading_minutes: 6
tags: ["concurrency","memory-management","performance","operating-systems","c-cpp"]
---

# Improving Firefox responsiveness on macOS

A post on [Mozilla Hacks](https://swe.quest/sources/mozilla-hacks.md), published 2022-10-10, 6 min read, Case study. Original: [https://hacks.mozilla.org/2022/10/improving-firefox-responsiveness-on-macos/](https://hacks.mozilla.org/2022/10/improving-firefox-responsiveness-on-macos/)

## Summary

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.

Written by swe.quest, not by the author.

**Difficulty:** Hard: written for specialists in the field

## Topics

- [Concurrency](https://swe.quest/tags/concurrency.md) (Compilers & runtimes)
- [Memory management](https://swe.quest/tags/memory-management.md) (Compilers & runtimes)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [Operating systems](https://swe.quest/tags/operating-systems.md) (Infrastructure)
- [C & C++](https://swe.quest/tags/c-cpp.md) (Languages)

## Prerequisites

- mutexes and spinlocks
- context switching
- memory allocators ([easy posts on Memory management](https://swe.quest/tags/memory-management.md?difficulty=easy))
- fork() semantics

## Keywords

Firefox, jemalloc, macOS, OSSpinLock, os\_unfair\_lock, os\_unfair\_lock\_with\_options, pthread\_atfork

## Related posts

- [Bun 1.4](https://swe.quest/articles/bun-1-4-fea28913dacb5d89.md): Bun · 2026-08-20 · Medium · 217 min read · Runtimes & VMs, JavaScript, Performance engineering, Memory management, Rust
  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.
- [Improving Firefox stability with this one weird trick](https://swe.quest/articles/improving-firefox-stability-with-this-one-weird-trick-6dcdeb9550eeb654.md): Mozilla Hacks · 2022-11-22 · Medium · 4 min read · Memory management, Operating systems, Browsers, Resilience
  Out-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.
- [Bun v0.1.12](https://swe.quest/articles/bun-v0-1-12-78431d37239a7e49.md): Bun · 2022-09-18 · Medium · 4 min read · JavaScript, Runtimes & VMs, Performance engineering, Concurrency, Debugging
  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.
- [Improved Process Isolation in Firefox 100](https://swe.quest/articles/improved-process-isolation-in-firefox-100-c5bc38aed6bfa0ee.md): Mozilla Hacks · 2022-05-12 · Hard · 9 min read · Sandboxing & isolation, Browsers, Security, Operating systems
  Firefox 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.
- [Eliminating Data Races in Firefox – A Technical Report](https://swe.quest/articles/eliminating-data-races-in-firefox-a-technical-report-5763b33d1a4f6f94.md): Mozilla Hacks · 2021-04-06 · Hard · 11 min read · Concurrency, C & C++, Rust, Debugging, Static analysis
  Mozilla 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.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
