Skip to content

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

Bun 32 min read Deep dive mediumAdept

Behind The Scenes of Bun Install

Bun's package manager installs dependencies roughly 7× faster than npm, 4× faster than pnpm and 17× faster than yarn because it treats installation as a systems programming problem: the bottleneck on modern NVMe hardware is system call and thread-coordination overhead, not I/O wait. strace benchmarks show bun making ~166k syscalls versus ~1M for npm and ~4M for yarn, with almost no futex contention, because its Zig code calls the kernel directly instead of going through Node's libuv thread pool. Further gains come from async DNS prefetching via Apple's getaddrinfo_async_start on macOS, binary manifest caching with interned strings instead of re-parsing JSON, optimized tarball extraction, OS-native file copying and spreading work across CPU cores.

Related posts

  • Bun v0.5

    Bun mediumAdept

    Bun v0.5 adds npm workspaces support (installing the Remix monorepo in about 500ms, claimed 28x faster than npm), a Bun.dns lookup API backed by c-ares, node:readline, and socket support via node:net and node:tls that lets database drivers like Postgres.js, mysql2 and node-redis run for the first time. Performance changes include 10x faster Buffer instantiation by removing Object.setPrototypeOf from construction and 50x faster crypto.createHash by switching from pure JS to BoringSSL. Module resolution now ignores the package.json browser field and honors the node export condition, and the release adds HTTPS_PROXY support, custom WebSocket handshake headers, more Jest-compatible test APIs, and many bun install fixes.

  • Bun v1.1.3

    Bun mediumAdept

    Bun v1.1.3 makes bun install up to 50% faster on Windows (about 1.6x in a hyperfine benchmark on a Next/SvelteKit project) by parallelizing some file copying and hardlinking. It also fixes five bugs: a rare install deadlock when many packages finish extracting at once, spurious "Install failed" errors with nested node_modules, missing non-zero exit codes on some filesystem-permission errors, cmd.exe console mode not being reset on exit, and a crash when loading unreadable modules. Windows builds still use ReleaseSafe mode, and the team plans to switch to ReleaseFast once bug reports decline.

  • Bun v0.3.0

    Bun mediumAdept

    Bun v0.3.0 focuses on stability and Node.js/Web API compatibility, cutting memory use 3-5x under load by scheduling garbage collection in coordination with the event loop and speeding up TextEncoder.encodeInto() 3x via simdutf. New Node.js APIs include node:child_process, process stdio streams, Error.captureStackTrace and fs streams, alongside automatic npm package installs on import when no node_modules exists. Other additions are a native Next.js-style FileSystemRouter, console as an AsyncIterable for reading stdin, threadsafe bun:ffi callbacks, new bun:test matchers with a faster toEqual(), and a long list of fetch, spawn and crash fixes.

  • Bun v1.2.16

    Bun mediumAdept

    Bun v1.2.16 fixes 73 issues and adds 119 passing Node.js tests. Headline changes are serving files directly through Bun.serve routes, an install.linkWorkspacePackages bunfig option that installs workspace dependencies from the registry (useful in CI), bun outdated support for catalog dependencies, and Bun.hash.rapidhash. Node.js compatibility improves through a node:net rework, vm.SyntheticModule, an llhttp-backed HTTPParser binding and AbortController handling in timers/promises. The release also fixes memory leaks in N-API handle scopes and unread Bun.spawn stdio, plus assorted TLS, HTTP/2, CSS parser and Windows bugs.

  • Bun v1.1.11

    Bun mediumAdept

    Bun v1.1.11 fixes 36 bugs, makes `bun update` write changes to package.json (preserving semver ranges unless `--latest`), and fixes incorrect peer dependency hoisting in `bun install` that broke packages like ajv and expo. Timers were reimplemented: `setTimeout` throughput is 5x faster on Linux (648 ms vs 3454 ms for 2M calls, beating Node.js 22's 1182 ms), callbacks now receive a `Timeout` object as `this`, `setInterval` reschedules from callback start like Node, and returned promises are no longer awaited. Other fixes include a macOS kqueue bug that assumed events were either readable or writable but not both, UDP hangs, Windows build and DNS issues, several fuzzing-found crashes, and a breaking change making `bun test` exit 1 on uncaught errors between tests.

The quest for software engineering knowledge.

Look:
Layout: