Repository navigation
VM: skip eager timezone prewarm under USE(BUN_JSC_ADDITIONS) - #322
Conversation
Upstream 311982@main (bug 313201) added an eager prewarm of the IANA timezone table and the local-zone display-name cache at the end of VM::VM so the cost lands at process start rather than on a later critical path. For Bun that tradeoff is backwards: a short-lived CLI process may never format a date, and on Linux the timeZoneDisplayName warm pulls in ucal_getHostTimeZone -> detectHostTimeZone, which walks /usr/share/zoneinfo when /etc/localtime is a regular file rather than a symlink (Amazon Linux, many container base images). Both underlying caches (intlAvailableTimeZoneEntries and DateCache::m_timeZoneStandardDisplayNameCache) are guarded by std::call_once / per-VM isNull() checks, so first access from Date / Intl pays the cost on demand. Measured on Linux x64, release, hyperfine -N, 400 runs, pinned core: /etc/localtime symlink: 14.6ms -> 8.6ms (1.71x) /etc/localtime regular: 16.3ms -> 8.4ms (1.95x, 443 zoneinfo files) openat syscalls on the regular-file host go 447 -> 31 (414 fewer zoneinfo opens). The block accounts for ~12% of unique function entries in an orderfile trace of 'bun -e console.log(1)'.
|
Warning Review limit reached
Next review available in: 17 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
Comment |
There was a problem hiding this comment.
LGTM — wraps the upstream timezone prewarm in #if !USE(BUN_JSC_ADDITIONS), deferring the cost to first use.
Checked that initializeAvailableTimeZones() → utcTimeZoneID() is std::call_once-guarded and DateCache::timeZoneDisplayName lazily populates on isNull(), so skipping the prewarm is safe.
Confirmed this matches the existing isInMiniMode() path upstream already exercises, and non-Bun builds are byte-identical.
The USE(BUN_JSC_ADDITIONS) guard pattern matches other Bun-specific blocks in this file.
Extended reasoning...
Overview
The PR adds a single #if !USE(BUN_JSC_ADDITIONS) / #endif pair (plus an explanatory comment) around the eager timezone prewarm block at the tail of VM::VM in Source/JavaScriptCore/runtime/VM.cpp. The wrapped block calls initializeAvailableTimeZones() and dateCache.timeZoneDisplayName(false) — both are cache warmers introduced upstream in 311982@main. For Bun builds the block is now compiled out; for all other builds the emitted code is unchanged.
Security risks
None. The change removes an eager cache-population call; no new inputs, no new data flow, no auth/crypto/permissions surface. The skipped calls read timezone data from ICU — deferring them to first use does not change what is read or how.
Level of scrutiny
Low. This is a two-line preprocessor guard following the repo's established USE(BUN_JSC_ADDITIONS) idiom (already used for queueMicrotask, drainMicrotasksForGlobalObject, and the synchronous-module-queue GC visit in this same file). The guarded code is a pure prewarm optimization: the underlying caches are already lazy — initializeAvailableTimeZones() is a thin wrapper over utcTimeZoneID() (LazyNeverDestroyed + std::call_once in IntlObject.cpp), and DateCache::timeZoneDisplayName in JSDateMath.cpp lazily fills on m_timeZoneStandardDisplayNameCache.isNull(). Upstream already skips the entire block when isInMiniMode(), so the lazy path is a supported, exercised configuration.
Other factors
- Non-Bun builds are unaffected (guard is
#if !USE(...)), so there is zero risk to upstream behavior. - The PR description documents test coverage (
intl.test.ts,temporal-global.test.ts,v8-date-parser.test.js, TZ env test) and a concurrent-worker stress test of the lazy paths. - No prior reviewer comments to address; the only timeline entry is a CodeRabbit rate-limit notice.
- The added comment is accurate and helpfully cites the upstream commit and the rationale, easing future merges.
Preview Builds
|
Picks up oven-sh/WebKit#320 (removes the stray <iostream> from the vendored simdutf amalgamation and bans <iostream> at compile time for non-Debug USE_BUN_JSC_ADDITIONS builds) and oven-sh/WebKit#322 (skip the eager timezone prewarm under USE_BUN_JSC_ADDITIONS). With this bump the release build's src/banned-includes/iostream shim no longer trips on the WebKit simdutf header, and no translation unit in the final link carries a reference to std::ios_base_library_init.
The WebKit bump pulls in oven-sh/WebKit#322 (skip the VM timezone prewarm), which makes the spawned child start faster and widens the window where it has already exited before the first stdin.write() flush. When that happens the unawaited write() rejects with EPIPE as an unhandled rejection that surfaces in the next test. Same fix as #35258, which also carries this WebKit commit.
## Problem Every Bun process runs libstdc++'s iostream and locale static initializers before `main`. From the release `bun-profile`: ``` _GLOBAL__sub_I.00090_globals_io.cc _GLOBAL__sub_I_cxx11_locale_inst.cc _GLOBAL__sub_I_cxx11_wlocale_inst.cc _GLOBAL__sub_I_locale_inst.cc _GLOBAL__sub_I_wlocale_inst.cc ``` `std::ios_base::Init`, `std::locale::_S_initialize`, `std::locale::_Impl`, and construction of ctype/numpunct/moneypunct/timepunct/messages for both `char` and `wchar_t`: roughly fifty functions out of libstdc++ that sit ahead of `main` in the `bun run orderfile` trace. Bun never uses C++ iostreams. ## Cause On libstdc++, `<iostream>` (and only `<iostream>`; not `<ostream>`/`<istream>`/`<sstream>`) emits an undefined reference to `_ZSt21ios_base_library_initv` in every TU that includes it. One such reference anywhere in the link pulls `globals_io.o` from libstdc++.a, whose initializer constructs `cin`/`cout`/`cerr`/`clog` and their `wchar_t` siblings, which in turn reference the full locale facet set. There are two sources: 1. **WebKit's vendored simdutf** (`Source/WTF/wtf/simdutf/simdutf_impl.h:9949`, an unused include in the `scalar/base64.h` section). Because `SIMDUTF.h` is included from `src/jsc/bindings/helpers.h`, ~70 Bun TUs carry the reference. Fixed in oven-sh/WebKit#320; upstream simdutf already dropped it in simdutf/simdutf#962. 2. **bun-uws headers**: `AsyncSocket.h`, `HttpRouter.h`, `Loop.h` include it without using it; `App.h`, `HttpContext.h`, `TopicTree.h` write fixed error strings via `std::cerr`. 7 Bun TUs carry the reference via `<bun-uws/src/App.h>`. ## Changes - `scripts/build/deps/webkit.ts`: bump `WEBKIT_VERSION` to `af2e8dc639` (oven-sh/WebKit#320: drop the simdutf `<iostream>` include and ban it at compile time for non-Debug `USE_BUN_JSC_ADDITIONS` builds; also picks up oven-sh/WebKit#321 lazy WebAssembly namespace and oven-sh/WebKit#322 skip eager timezone prewarm). Subsumes the `WEBKIT_VERSION` change in #35258. - `packages/bun-uws`: drop the `<iostream>` include from `AsyncSocket.h`, `HttpContext.h`, `HttpRouter.h`, `Loop.h`, `TopicTree.h`; delete the five `std::cerr << ...` validation messages (Bun validates these inputs before calling into uWS, so the paths are unreachable programmer errors and `std::terminate()` alone is enough). - `src/banned-includes/iostream`: a `#error` shim prepended to the `-I` search path for release builds. Any `#include <iostream>` in a Bun TU (including transitively from a WebKit header) fails the release compile with an explanation pointing here. Debug builds keep the real header for ad-hoc printf debugging; `-DBUN_ALLOW_IOSTREAM` is the opt-out. - `test/internal/source-lints/no-iostream-include.test.ts`: scans `src/`, `packages/bun-uws`, `packages/bun-usockets` for the include so debug CI also catches it. ## Verification With both oven-sh/WebKit#320 and this change applied to a release build: ``` nm build/release/bun-profile | grep ios_base4Init -> empty nm build/release/bun-profile | grep _S_initialize -> empty _GLOBAL__sub_I.00090_globals_io.cc gone bun-profile 547 KB smaller ``` Four `_GLOBAL__sub_I_*locale_inst.cc` stubs remain: these are the libstdc++ facet-id guard-byte initializers (a few dozen `movb $1,(%rax)` each) pulled by `Int128.cpp`'s `std::ostringstream`. `<sstream>` does not emit the static `Init` object and those stubs are near-free. ## Int128.cpp `Source/WTF/wtf/Int128.cpp` includes `<sstream>` and `<ostream>`. Both are load-bearing (`UInt128ToFormattedString`'s `std::ostringstream` and the `operator<<(std::ostream&, ...)` overloads) and neither emits the static `ios_base::Init` object, so they are left alone. <!-- robobun:evidence:begin --> --- **[decide:webkit]** gate passed · iteration 6 · 10 files touched <details><summary>fails on main (without fix)</summary> ```console ASAN without fix: 1 FAILED $ BUN_DEBUG_QUIET_LOGS=1 bun scripts/build.ts --profile=debug --quiet test "--reporter=junit" "--reporter-outfile=/tmp/mechgate.xml" test/internal/source-lints/no-iostream-include.test.ts bun test v1.4.0 (eba02a1) test/internal/source-lints/no-iostream-include.test.ts: 45 | // root going away, which would make the ban below pass vacuously. 46 | expect(scanned).toBeGreaterThan(0); 47 | } 48 | 49 | violations.sort(); 50 | expect(violations).toEqual([]); ^ error: expect(received).toEqual(expected) - [] + [ + "packages/bun-uws/src/AsyncSocket.h", + "packages/bun-uws/src/HttpContext.h", + "packages/bun-uws/src/HttpRouter.h", + "packages/bun-uws/src/Loop.h", + "packages/bun-uws/src/TopicTree.h", + ] - Expected - 1 + Received + 7 at <anonymous> (/workspace/bun/test/internal/source-lints/no-iostream-include.test.ts:50:22) (fail) C++ sources compiled into Bun do not include <iostream> [748.19ms] 0 pass 1 fail 4 expect() calls Ran 1 test across 1 file. [3.00s] error: script "bd" exited with code 1 __F:1:S:0 release without fix: 1 FAILED bun test v1.4.0-canary.1 (507ab81) test/internal/source-lints/no-iostream-include.test.ts: 45 | // root going away, which would make the ban below pass vacuously. 46 | expect(scanned).toBeGreaterThan(0); 47 | } 48 | 49 | violations.sort(); 50 | expect(violations).toEqual([]); ^ error: expect(received).toEqual(expected) - [] + [ + "packages/bun-uws/src/AsyncSocket.h", + "packages/bun-uws/src/HttpContext.h", + "packages/bun-uws/src/HttpRouter.h", + "packages/bun-uws/src/Loop.h", + "packages/bun-uws/src/TopicTree.h", + ] - Expected - 1 + Received + 7 at <anonymous> (/workspace/bun/test/internal/source-lints/no-iostream-include.test.ts:50:22) (fail) C++ sources compiled into Bun do not include <iostream> [59.52ms] 0 pass 1 fail 4 expect() calls Ran 1 test across 1 file. [213.00ms] __F:1:S:0 ``` </details> <details><summary>passes on PR (with fix)</summary> ```console ASAN with fix: all passed $ BUN_DEBUG_QUIET_LOGS=1 bun scripts/build.ts --profile=debug --quiet test "--reporter=junit" "--reporter-outfile=/tmp/mechgate.xml" test/internal/source-lints/no-iostream-include.test.ts bun test v1.4.0 (eba02a1) test/internal/source-lints/no-iostream-include.test.ts: (pass) C++ sources compiled into Bun do not include <iostream> [885.41ms] 1 pass 0 fail 4 expect() calls Ran 1 test across 1 file. [3.41s] __F:0:S:0 release with fix: all passed $ bun scripts/build.ts --profile=release [configured] bun-profile → bun (stripped) in 1174ms (unchanged) ninja: Entering directory `/workspace/bun/build/release' [0/1] reconfigure [0/13] cargo bun_bin → libbun_rust.a (--target x86_64-unknown-linux-gnu) nightly-2026-07-20-x86_64-unknown-linux-gnu unchanged - rustc 1.99.0-nightly (9f36de775 2026-07-19) �[1m�[92m Compiling�[0m bun_core v0.0.0 (/workspace/bun/src/bun_core) �[1m�[92m Compiling�[0m bun_errno v0.0.0 (/workspace/bun/src/errno) �[1m�[92m Compiling�[0m bun_ptr v0.0.0 (/workspace/bun/src/ptr) �[1m�[92m Compiling�[0m bun_boringssl_sys v0.0.0 (/workspace/bun/src/boringssl_sys) �[1m�[92m Compiling�[0m bun_safety v0.0.0 (/workspace/bun/src/safety) �[1m�[92m Compiling�[0m bun_zlib_sys v0.0.0 (/workspace/bun/src/zlib_sys) �[1m�[92m Compiling�[0m bun_cares_sys v0.0.0 (/workspace/bun/src/cares_sys) �[1m�[92m Compiling�[0m bun_zstd v0.0.0 (/workspace/bun/src/zstd) �[1m�[92m Compiling�[0m bun_picohttp v0.0.0 (/workspace/bun/src/picohttp) �[1m�[92m Compiling�[0m bun_output v0.0.0 (/workspace/bun/src/output) �[1m�[92m Compiling�[0m bun_clap v0.0.0 (/workspace/bun/src/clap) �[1m�[92m Compili ... (truncated) ``` </details> <details><summary>diff hotspot</summary> ``` packages/bun-uws/src/App.h | 3 -- packages/bun-uws/src/AsyncSocket.h | 1 - packages/bun-uws/src/HttpContext.h | 3 -- packages/bun-uws/src/HttpRouter.h | 1 - packages/bun-uws/src/Loop.h | 1 - packages/bun-uws/src/TopicTree.h | 5 --- scripts/build/deps/webkit.ts | 7 --- scripts/build/flags.ts | 6 +++ src/banned-includes/iostream | 27 ++++++++++++ .../source-lints/no-iostream-include.test.ts | 51 ++++++++++++++++++++++ 10 files changed, 84 insertions(+), 21 deletions(-) ``` </details> **gate history** · 8 passed · 1 rejected · iteration 6 <details><summary>evidence per changed file</summary> ``` file reads edits tests packages/bun-uws/src/App.h 4 3 0 packages/bun-uws/src/AsyncSocket.h 1 1 0 packages/bun-uws/src/HttpContext.h 2 2 0 packages/bun-uws/src/HttpRouter.h 1 1 0 packages/bun-uws/src/Loop.h 1 1 0 packages/bun-uws/src/TopicTree.h 4 4 0 scripts/build/deps/webkit.ts 2 3 0 scripts/build/flags.ts 1 1 0 src/banned-includes/iostream 0 1 0 test/internal/source-lints/no-iostream-include.test.ts 2 3 0 ``` </details> <!-- robobun:evidence:end --> --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Jarred Sumner <[email protected]>
## Problem Every Bun process runs libstdc++'s iostream and locale static initializers before `main`. From the release `bun-profile`: ``` _GLOBAL__sub_I.00090_globals_io.cc _GLOBAL__sub_I_cxx11_locale_inst.cc _GLOBAL__sub_I_cxx11_wlocale_inst.cc _GLOBAL__sub_I_locale_inst.cc _GLOBAL__sub_I_wlocale_inst.cc ``` `std::ios_base::Init`, `std::locale::_S_initialize`, `std::locale::_Impl`, and construction of ctype/numpunct/moneypunct/timepunct/messages for both `char` and `wchar_t`: roughly fifty functions out of libstdc++ that sit ahead of `main` in the `bun run orderfile` trace. Bun never uses C++ iostreams. ## Cause On libstdc++, `<iostream>` (and only `<iostream>`; not `<ostream>`/`<istream>`/`<sstream>`) emits an undefined reference to `_ZSt21ios_base_library_initv` in every TU that includes it. One such reference anywhere in the link pulls `globals_io.o` from libstdc++.a, whose initializer constructs `cin`/`cout`/`cerr`/`clog` and their `wchar_t` siblings, which in turn reference the full locale facet set. There are two sources: 1. **WebKit's vendored simdutf** (`Source/WTF/wtf/simdutf/simdutf_impl.h:9949`, an unused include in the `scalar/base64.h` section). Because `SIMDUTF.h` is included from `src/jsc/bindings/helpers.h`, ~70 Bun TUs carry the reference. Fixed in oven-sh/WebKit#320; upstream simdutf already dropped it in simdutf/simdutf#962. 2. **bun-uws headers**: `AsyncSocket.h`, `HttpRouter.h`, `Loop.h` include it without using it; `App.h`, `HttpContext.h`, `TopicTree.h` write fixed error strings via `std::cerr`. 7 Bun TUs carry the reference via `<bun-uws/src/App.h>`. ## Changes - `scripts/build/deps/webkit.ts`: bump `WEBKIT_VERSION` to `af2e8dc639` (oven-sh/WebKit#320: drop the simdutf `<iostream>` include and ban it at compile time for non-Debug `USE_BUN_JSC_ADDITIONS` builds; also picks up oven-sh/WebKit#321 lazy WebAssembly namespace and oven-sh/WebKit#322 skip eager timezone prewarm). Subsumes the `WEBKIT_VERSION` change in #35258. - `packages/bun-uws`: drop the `<iostream>` include from `AsyncSocket.h`, `HttpContext.h`, `HttpRouter.h`, `Loop.h`, `TopicTree.h`; delete the five `std::cerr << ...` validation messages (Bun validates these inputs before calling into uWS, so the paths are unreachable programmer errors and `std::terminate()` alone is enough). - `src/banned-includes/iostream`: a `#error` shim prepended to the `-I` search path for release builds. Any `#include <iostream>` in a Bun TU (including transitively from a WebKit header) fails the release compile with an explanation pointing here. Debug builds keep the real header for ad-hoc printf debugging; `-DBUN_ALLOW_IOSTREAM` is the opt-out. - `test/internal/source-lints/no-iostream-include.test.ts`: scans `src/`, `packages/bun-uws`, `packages/bun-usockets` for the include so debug CI also catches it. ## Verification With both oven-sh/WebKit#320 and this change applied to a release build: ``` nm build/release/bun-profile | grep ios_base4Init -> empty nm build/release/bun-profile | grep _S_initialize -> empty _GLOBAL__sub_I.00090_globals_io.cc gone bun-profile 547 KB smaller ``` Four `_GLOBAL__sub_I_*locale_inst.cc` stubs remain: these are the libstdc++ facet-id guard-byte initializers (a few dozen `movb $1,(%rax)` each) pulled by `Int128.cpp`'s `std::ostringstream`. `<sstream>` does not emit the static `Init` object and those stubs are near-free. ## Int128.cpp `Source/WTF/wtf/Int128.cpp` includes `<sstream>` and `<ostream>`. Both are load-bearing (`UInt128ToFormattedString`'s `std::ostringstream` and the `operator<<(std::ostream&, ...)` overloads) and neither emits the static `ios_base::Init` object, so they are left alone. <!-- robobun:evidence:begin --> --- **[decide:webkit]** gate passed · iteration 6 · 10 files touched <details><summary>fails on main (without fix)</summary> ```console ASAN without fix: 1 FAILED $ BUN_DEBUG_QUIET_LOGS=1 bun scripts/build.ts --profile=debug --quiet test "--reporter=junit" "--reporter-outfile=/tmp/mechgate.xml" test/internal/source-lints/no-iostream-include.test.ts bun test v1.4.0 (eba02a1f6) test/internal/source-lints/no-iostream-include.test.ts: 45 | // root going away, which would make the ban below pass vacuously. 46 | expect(scanned).toBeGreaterThan(0); 47 | } 48 | 49 | violations.sort(); 50 | expect(violations).toEqual([]); ^ error: expect(received).toEqual(expected) - [] + [ + "packages/bun-uws/src/AsyncSocket.h", + "packages/bun-uws/src/HttpContext.h", + "packages/bun-uws/src/HttpRouter.h", + "packages/bun-uws/src/Loop.h", + "packages/bun-uws/src/TopicTree.h", + ] - Expected - 1 + Received + 7 at <anonymous> (/workspace/bun/test/internal/source-lints/no-iostream-include.test.ts:50:22) (fail) C++ sources compiled into Bun do not include <iostream> [748.19ms] 0 pass 1 fail 4 expect() calls Ran 1 test across 1 file. [3.00s] error: script "bd" exited with code 1 __F:1:S:0 release without fix: 1 FAILED bun test v1.4.0-canary.1 (507ab8113) test/internal/source-lints/no-iostream-include.test.ts: 45 | // root going away, which would make the ban below pass vacuously. 46 | expect(scanned).toBeGreaterThan(0); 47 | } 48 | 49 | violations.sort(); 50 | expect(violations).toEqual([]); ^ error: expect(received).toEqual(expected) - [] + [ + "packages/bun-uws/src/AsyncSocket.h", + "packages/bun-uws/src/HttpContext.h", + "packages/bun-uws/src/HttpRouter.h", + "packages/bun-uws/src/Loop.h", + "packages/bun-uws/src/TopicTree.h", + ] - Expected - 1 + Received + 7 at <anonymous> (/workspace/bun/test/internal/source-lints/no-iostream-include.test.ts:50:22) (fail) C++ sources compiled into Bun do not include <iostream> [59.52ms] 0 pass 1 fail 4 expect() calls Ran 1 test across 1 file. [213.00ms] __F:1:S:0 ``` </details> <details><summary>passes on PR (with fix)</summary> ```console ASAN with fix: all passed $ BUN_DEBUG_QUIET_LOGS=1 bun scripts/build.ts --profile=debug --quiet test "--reporter=junit" "--reporter-outfile=/tmp/mechgate.xml" test/internal/source-lints/no-iostream-include.test.ts bun test v1.4.0 (eba02a1f6) test/internal/source-lints/no-iostream-include.test.ts: (pass) C++ sources compiled into Bun do not include <iostream> [885.41ms] 1 pass 0 fail 4 expect() calls Ran 1 test across 1 file. [3.41s] __F:0:S:0 release with fix: all passed $ bun scripts/build.ts --profile=release [configured] bun-profile → bun (stripped) in 1174ms (unchanged) ninja: Entering directory `/workspace/bun/build/release' [0/1] reconfigure [0/13] cargo bun_bin → libbun_rust.a (--target x86_64-unknown-linux-gnu) nightly-2026-07-20-x86_64-unknown-linux-gnu unchanged - rustc 1.99.0-nightly (9f36de775 2026-07-19) �[1m�[92m Compiling�[0m bun_core v0.0.0 (/workspace/bun/src/bun_core) �[1m�[92m Compiling�[0m bun_errno v0.0.0 (/workspace/bun/src/errno) �[1m�[92m Compiling�[0m bun_ptr v0.0.0 (/workspace/bun/src/ptr) �[1m�[92m Compiling�[0m bun_boringssl_sys v0.0.0 (/workspace/bun/src/boringssl_sys) �[1m�[92m Compiling�[0m bun_safety v0.0.0 (/workspace/bun/src/safety) �[1m�[92m Compiling�[0m bun_zlib_sys v0.0.0 (/workspace/bun/src/zlib_sys) �[1m�[92m Compiling�[0m bun_cares_sys v0.0.0 (/workspace/bun/src/cares_sys) �[1m�[92m Compiling�[0m bun_zstd v0.0.0 (/workspace/bun/src/zstd) �[1m�[92m Compiling�[0m bun_picohttp v0.0.0 (/workspace/bun/src/picohttp) �[1m�[92m Compiling�[0m bun_output v0.0.0 (/workspace/bun/src/output) �[1m�[92m Compiling�[0m bun_clap v0.0.0 (/workspace/bun/src/clap) �[1m�[92m Compili ... (truncated) ``` </details> <details><summary>diff hotspot</summary> ``` packages/bun-uws/src/App.h | 3 -- packages/bun-uws/src/AsyncSocket.h | 1 - packages/bun-uws/src/HttpContext.h | 3 -- packages/bun-uws/src/HttpRouter.h | 1 - packages/bun-uws/src/Loop.h | 1 - packages/bun-uws/src/TopicTree.h | 5 --- scripts/build/deps/webkit.ts | 7 --- scripts/build/flags.ts | 6 +++ src/banned-includes/iostream | 27 ++++++++++++ .../source-lints/no-iostream-include.test.ts | 51 ++++++++++++++++++++++ 10 files changed, 84 insertions(+), 21 deletions(-) ``` </details> **gate history** · 8 passed · 1 rejected · iteration 6 <details><summary>evidence per changed file</summary> ``` file reads edits tests packages/bun-uws/src/App.h 4 3 0 packages/bun-uws/src/AsyncSocket.h 1 1 0 packages/bun-uws/src/HttpContext.h 2 2 0 packages/bun-uws/src/HttpRouter.h 1 1 0 packages/bun-uws/src/Loop.h 1 1 0 packages/bun-uws/src/TopicTree.h 4 4 0 scripts/build/deps/webkit.ts 2 3 0 scripts/build/flags.ts 1 1 0 src/banned-includes/iostream 0 1 0 test/internal/source-lints/no-iostream-include.test.ts 2 3 0 ``` </details> <!-- robobun:evidence:end --> --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Jarred Sumner <[email protected]>
Upstream 311982@main (bug 313201) added an eager prewarm of the IANA timezone table and the local-zone display-name cache at the end of
VM::VM, so the cost lands at process start rather than on a later critical path. That makes sense for a long-lived browser process; for Bun it is backwards.What the block pulls in
initializeAvailableTimeZones()→intlAvailableTimeZoneEntries(): enumerates every IANA zone viaucal_openTimeZoneIDEnumeration/ucal_openTimeZones, canonicalizes and sorts them, builds the immortal table. ~2.9ms.dateCache.timeZoneDisplayName(false)→timeZoneCache()→retrieveTimeZoneInformation()→ucal_getHostTimeZone→TimeZone::detectHostTimeZone()→ucal_getTimeZoneDisplayName→TimeZoneNamesImpl::initialize→ ICUzone/resource load (Bun: triggers zstd DDict build + decompress). ~2.8ms when/etc/localtimeis a symlink.The second step has a pathological case on Linux: when
/etc/localtimeis a regular file (a copy, not a symlink) and there is no/etc/timezone, ICU'suprv_tznamefalls back tosearchForTZFile, which walks/usr/share/zoneinfo/**comparing file contents. That is the shape on Amazon Linux and many container base images. On a full tzdata install it is ~1700openatcalls.Safety
Both caches are already lazy and safe to fill on first use:
intlAvailableTimeZoneEntries()/utcTimeZoneIDSlow()areLazyNeverDestroyed+std::call_once; stored strings arecreateStaticStringImpl(immortal, thread-safe to share). TheutcTimeZoneID()inline fast-path reads a sentinel and falls into thecall_onceslow path until set.DateCacheis a per-VM by-value member;timeZoneDisplayNameruns under the JSLock, the underlyingretrieveTimeZoneInformationglobal is guarded bytimeZoneCacheLock.This is the same path already taken when
isInMiniMode()is true.Measured
Linux x64, release build,
hyperfine -N, 400 runs, pinned core, warm page cache./etc/localtimebun -e 'console.log(1)'bun -e 'new Date().toString()'bun -e 'console.log(1)'Direct instrumentation of the block (symlink host):
initializeAvailableTimeZones=2.9ms timeZoneDisplayName=2.8ms total=5.7ms.openatsyscalls forbun -e 'console.log(1)'on a regular-file/etc/localtimehost: 447 → 31 (zoneinfo opens 414 → 0).The block accounts for entries 1253–1861 of ~4983 unique function entries (~12%) in the orderfile trace of
bun -e 'console.log(1)'.Verified
intl.test.ts,temporal-global.test.ts,v8-date-parser.test.js,process.env.TZtest all pass.Date.toString()/Intl.supportedValuesOf("timeZone")/Intl.DateTimeFormat().resolvedOptions()produce identical results.This fixes the 1.3.13 → 1.3.14 startup regression (7.3ms → 19.3ms on a regular-file
/etc/localtimehost) that arrived with the most recent upstream merge.