Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Mozilla Hacks 11 min read Case study hardMaster

Eliminating Data Races in Firefox – A Technical Report

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. 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.

Assumes: C/C++ memory modelatomics and memory orderingmultithreaded programmingcompiler sanitizers

Related posts

  • A Year of Rust in ClickHouse

    ClickHouse mediumAdept

    ClickHouse added Rust to its C++ codebase as an option for new components rather than a rewrite, starting with BLAKE3, then skim for clickhouse-client history, PRQL as a switchable query dialect, and Databricks' delta-kernel-rs replacing a sketchy C++ Delta Lake implementation. The integration needed hermetic builds with vendored crates and careful C++/Rust wrappers. Panics had to be kept from crashing a multi-tenant server, and MSan required instrumenting Rust with a pinned nightly toolchain. Further friction came from cross-compilation, static OpenSSL linking, enormous Rust symbol names, library conventions for memory accounting and connection pools that don't compose with ClickHouse's, and missing build caching, while CI fuzzing caught crashes in the Rust libraries just as it does in C libraries.

  • 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.

  • Enabling the parallel frontend on nightly

    Rust Blog mediumAdept

    Rust nightly now runs the compiler frontend (type checking, borrow checking) in parallel by default since nightly-2026-11-14, to surface bugs ahead of stabilization. In single-crate benchmarks with 8 threads, mean wall time dropped about 44% for check and 28% for opt builds, with some crates like nalgebra, cargo and diesel checking nearly 3x faster. Gains shrink when Cargo and LLVM already saturate the cores: an end-to-end cargo check of the whole crate graph improved only about 15%, and incremental rebuilds improved 3-5%. Nightly defaults to 2 frontend threads to limit memory growth; use -Zunstable-options --jobs-frontend=N to tune it or set N=1 to opt out, and expect nondeterministic diagnostic order and possible reproducibility bugs.

  • More Than 2x Faster Hashing in ClickHouse Using Rust

    ClickHouse mediumAdept

    ClickHouse added optional Rust library support to its C++/CMake build using Corrosion-rs, with BLAKE3 as the first library, exposed to C++ through a Rust shim function using C-compatible FFI types and a header file. BLAKE3 hashes more than 2x faster than SHA224/SHA256 and slightly faster than MD5, while staying secure and resistant to length extension. Perf flamegraphs show the shim's type conversion costs about 1.15% of query time. Integration hurdles included MemorySanitizer false positives on Rust memory, fixed with __msan_unpoison and explicit byte conversion, plus cross-platform linking, with aarch64-darwin still unsupported. The integration also had to stay optional, statically linked, cross-compilable and compatible with sanitizers.

  • How to use Rust in ClickHouse: avoiding a full rewrite

    ClickHouse mediumAdept

    ClickHouse, a 1.5M-line C++ analytic database, is adopting Rust incrementally rather than rewriting. It started with Corrosion to wire Rust into CMake and a BLAKE3 hash function, then took on a client history-navigation feature, the PRQL query language, and Databricks' delta-kernel-rs for Delta Lake support. The integration problems were mostly practical: hermetic reproducible builds with vendored crates, buggy FFI wrappers caught quickly by existing CI and fuzzing, library panics that crash the server, compiling Rust with sanitizers (now easier with an MSan toolchain), duplicated cross-compilation setup, and transitive dependencies linking system OpenSSL.

The quest for software engineering knowledge.

Look:
Layout: