Urgent.News

What's breaking now, across thousands of outlets.

Tech

Bun 1.4's Rust rewrite cuts script startup time from 10.5ms to 4.2ms

Bun 1.4 shipped on 20 August as the first stable release built on Bun's new Rust-based core, replacing the Zig runtime layer that shipped everything since 1.0. The release notes claim faster startup, less idle CPU, and lower memory. I installed the last pre-rewrite build and the new one side by side and measured all three, plus what happens when you point a node symlink at the new binary, which…

Bun 1.4, released on August 20th, is the first stable release built on a new Rust-based core, replacing the previous Zig runtime layer. The release notes highlight faster startup times, less idle CPU usage, and lower memory consumption. This report compares Bun 1.3.14 and 1.4.2 in terms of startup time, idle memory usage, idle CPU, and throughput under load.

Startup time:

The benchmark measured the time taken for the "bun --version" command. The difference in median startup time between the two versions was negligible, with 1.3.14 taking 10.54ms and 1.4.2 taking 4.22ms. When a script was run using "bun run hello.js", the median startup time dropped from 10.54ms to 4.22ms, a 60% improvement, surpassing the 50% faster claim by the release notes. The old binary also had a longer tail (up to 18ms) compared to the new one (staying within a 1.4ms band across all runs).

Idle memory usage:

Three warm-up runs and three idle runs were conducted for each version. The average idle memory consumption after 60 seconds dropped from 34.9MB (1.3.14) to 19.0MB (1.4.2), a 46% reduction. The release notes claim a reduction of up to 35%, which the report states was achieved in this workload. However, the report flags the claim of 5x less idle CPU as not backed by the measurements.

Idle CPU:

Idle CPU measurements were taken using utime + stime from /proc/pid/stat before and after a 60-second idle window, three times per version. The average CPU usage for 1.3.14 was 10.67% and 4.33% for 1.4.2, indicating a 2.5x improvement. The report notes that the CPU improvement may be due to a different idle workload rather than a bare Bun.serve with no traffic.

Throughput under load:

The report measured the requests per second under load using autocannon with 50 concurrent connections for 8 seconds. Bun 1.3.14 produced an average of 29,456 requests per second, while Bun 1.4.2 generated 62,310 requests per second, a 2.15x improvement. Additionally, the p50 latency dropped from 1ms in 1.3.14 to sub-millisecond in 1.4.2.

Symlink detection regression:

When invoking Bun as 'node' using a symlink, the report discovered a regression in Bun 1.4.2. The .env file was not loaded correctly, causing the MY_SECRET environment variable to be undefined. In contrast, Bun 1.3.14 loaded the .env file correctly when invoked through a symlink named 'node'. The report suggests that developers using Bun as a drop-in replacement for Node, particularly in container images or CI pipelines, should be aware of this regression and use the --env-file flag if necessary.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

5 Errors I Hit Building DeFi Bots (And How to Fix Them)

Building production bots on free APIs sounds cool in theory. In practice, you hit walls immediately. Here are the 5 real errors I encountered while building two Ethereum monitoring bots, and exactly…

  • WebSockets timeout issue resolved by switching to polling every 15 minutes
  • CoinGecko rate limit avoided by reducing polling frequency or tokens tracked
  • Supabase Row-Level Security issue fixed by disabling RLS or creating policy

More from Saturday 12 September →