Collapse ThreadPool::init dead generic and fix cpuid cfg gate#30886
Conversation
|
Updated 5:18 AM PT - May 16th, 2026
❌ @Jarred-Sumner, your commit 7c46dda has 1 failures in 🧪 To try this PR locally: bunx bun-pr 30886That installs a local version of the PR into your bun-30886 --bun |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThis PR specializes two generic or platform-agnostic APIs: ThreadPool's initialization functions are changed to accept ChangesType refinements and platform targeting
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
LGTM — mechanical de-genericization and cfg-gate tightening, both compile-time-only with no runtime behavior change.
Extended reasoning...
Overview
Two unrelated cleanup changes:
src/bundler/ThreadPool.rs: collapsesThreadPool::init<V2>andinit_with_pool<V2>from generic to concrete&BundleV2<'_>, drops the now-stale PORT NOTE that explicitly said to do this once the duplicateBundleV2definition was gone, and rewrites the pointer cast to name the concrete target type.src/perf/hw_timer.rs: narrows the#[cfg]gate onCpuidResult/cpuid()fromtarget_arch = "x86_64"to additionally exclude macOS/FreeBSD, matching the gate on their only call site insideread_frequency().
Verification
- Confirmed only one
struct BundleV2definition exists (bundle_v2.rs:75). Thebv2_implmodule still exists but only as a method-body container, not a second struct definition — which is what the PORT NOTE actually depended on. - The sole external call site (
bundle_v2.rs:2934) passes&mut *thiswherethis: &mut BundleV2, so de-genericization type-checks with no caller changes. - The
from_ref::<V2>(v2).cast()→from_ref(v2).cast::<BundleV2<'static>>()rewrite is semantically identical: same source pointer, same target type (the field is*const BundleV2<'static>), just the turbofish moved from inference-at-source to explicit-at-cast. - In
hw_timer.rs, the only references tocpuid/CpuidResultare inside the#[cfg(not(any(target_os = "macos", target_os = "freebsd")))]arm ofread_frequency(), so the new gate exactly mirrors callers and only removes dead code on x86_64 Darwin/FreeBSD.
Security risks
None. No new logic, no new unsafe, no I/O or auth surface. Both changes are type/cfg-level and produce identical or strictly-subset codegen.
Level of scrutiny
Low. This is the kind of stale-port-scaffolding cleanup the codebase's own PORT NOTE asked for, plus a dead-code-warning fix. PR description reports clean cargo check --workspace and rust:check-all across 10 targets.
Other factors
No bugs from the bug-hunting system, no outstanding reviewer comments, no prior reviews.
…onsistent docs - bundler/ThreadPool.rs: take main's post-#30886 version and drop the stranded empty-backtick parenthetical at the MimallocArena PORT NOTE - runtime/ffi/host_fns.rs: drop stranded empty-backtick parenthetical - css/rules/mod.rs: align vendor_prefix_to_css doc with the rewrite at :347-351 (canonical impl is in css_parser.rs, not lib.rs) - js_parser/parser.rs: delete dead ConvertESMExportsForHmr / ImportScanner stub modules (zero callers; real types live in lower/ and scan/) - runtime/api/html_rewriter.rs, runtime/node/node_zlib_binding.rs: fix //; and //. stranded by the R-2 tag strip
…onsistent docs - bundler/ThreadPool.rs: take main's post-#30886 version and drop the stranded empty-backtick parenthetical at the MimallocArena PORT NOTE - runtime/ffi/host_fns.rs: drop stranded empty-backtick parenthetical - css/rules/mod.rs: align vendor_prefix_to_css doc with the rewrite at :347-351 (canonical impl is in css_parser.rs, not lib.rs) - js_parser/parser.rs: delete dead ConvertESMExportsForHmr / ImportScanner stub modules (zero callers; real types live in lower/ and scan/) - runtime/api/html_rewriter.rs, runtime/node/node_zlib_binding.rs: fix //; and //. stranded by the R-2 tag strip
ThreadPool::init dead generic.
bundler::ThreadPool::init(and its helperinit_with_pool) were generic overV2because, during the phased Zig→Rust port,bundle_v2.rscarried twoBundleV2definitions — the canonical one plus abv2_impldraft module — and both needed to callinit. The PORT NOTE on the function explicitly said it should collapse to&BundleV2<'_>oncebv2_implwas dropped. That module is gone (grep -rn "struct BundleV2" src/bundler/finds exactly one definition,bundle_v2.rs:75), so this collapses the generic, names the concrete type, and drops the now-stale PORT NOTE. The body was already storing a type-erased raw pointer, so the monomorphised code is identical.cpuid cfg-gate mismatch.
perf/hw_timer.rsdefinesstruct CpuidResultandfn cpuid()under#[cfg(target_arch = "x86_64")], but their only callers live inside a#[cfg(not(any(target_os = "macos", target_os = "freebsd")))]block (macOS/FreeBSD read the boot-time TSC frequency fromsysctlinstead of probing CPUID). Onx86_64-apple-darwinandx86_64-unknown-freebsdthe helpers were therefore compiled with no callers, producingnever constructed/never usedwarnings. The cfg gates now mirror the callers' conditions.Verified with
cargo check --workspace --keep-going(clean),bun run rust:check-all(10/10 targets), andcargo fmt -p bun_bundler -p bun_perf --check. Confirmed the dead-code warnings onx86_64-apple-darwinare present without this change and gone with it. File set is disjoint from #30879.