Skip to content

perf(plugin): clock the build only when it is being measured - #10558

Merged
IWANABETHATGUY merged 1 commit into
mainfrom
feat/plugin-timings-clock-only-when-measured
Jul 31, 2026
Merged

IWANABETHATGUY merged 1 commit into
mainfrom
feat/plugin-timings-clock-only-when-measured

Conversation

@IWANABETHATGUY

@IWANABETHATGUY IWANABETHATGUY commented Jul 31, 2026 •

Copy link
Copy Markdown
Member

Sits on #10509.

What

BuildTimings took an Instant on every build, whether or not anyone would read it.

Before #10520 the two clocks lived on the hook timing collector, which only existed when timing was on — so the Option<Instant> it handed back was the gate. Giving the clocks their own type dropped that, and bundle.rs went to a bare std::time::Instant::now() in three places.

The gate goes back, this time owned by the type that needs it:

  • BuildTimings::new(measured) — decided once, where the driver is built.
  • start() returns Option<Instant>: None when the build is not being measured.
  • record_total / record_link_stage take what start() gave and do nothing with None.

The call sites read as they did before the split.

What decides it

options.plugin_timings. The JavaScript side registers that callback only when measureTimings && checks.pluginTimings !== false, so its presence is already how this side knows a report is coming. The two halves cannot disagree about whether a build is measured, because a report needs both of them.

Tests

Two added: a build that is not measured hands back no instant and stores nothing; a measured one does start a clock. The existing gate tests are unchanged.

Not in scope

The threshold and the ratio, and what any measured build reports. If this PR changes what a build with checks.pluginTimings on reports, it is wrong.

@IWANABETHATGUY
IWANABETHATGUY force-pushed the feat/plugin-timings-clock-only-when-measured branch from 0846e82 to bbc555a Compare July 31, 2026 03:54
Base automatically changed from feat/plugin-timings-option-callbacks to main July 31, 2026 04:05
`BuildTimings` took an `Instant` on every build, whether or not anyone
would read it. Before the split in #10520 the clocks lived on the hook
timing collector, which only existed when timing was on, so the `Option`
it handed back was the gate. Giving them their own type dropped that,
and `bundle.rs` went to a bare `Instant::now()`.

Put the gate back where the type can own it. `BuildTimings::new` takes
whether the build is measured; `start()` hands back an instant only then,
and `record_total` / `record_link_stage` take what it gave and do nothing
with `None`. The call sites read the same as they did before.

What decides it is `options.plugin_timings` — the JavaScript side
registers that callback only when `checks.pluginTimings` leaves
measurement on, so its presence is already how this side knows a report
is coming. The two halves cannot disagree, because a report needs both.

Claude-Session: https://claude.ai/code/session_01S3RQeYwhJmEu4eLYkanvm1
@IWANABETHATGUY
IWANABETHATGUY force-pushed the feat/plugin-timings-clock-only-when-measured branch from bbc555a to 88522a4 Compare July 31, 2026 04:09
@netlify

netlify Bot commented Jul 31, 2026

Copy link
Copy Markdown

✅ Deploy Preview for rolldown-rs canceled.

Name Link
🔨 Latest commit 88522a4
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/6a6c2007b6835a0008cf7d8b

@IWANABETHATGUY
IWANABETHATGUY marked this pull request as ready for review July 31, 2026 04:09
@shulaoda

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 88522a418e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@codspeed

codspeed Bot commented Jul 31, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 7 untouched benchmarks
⏩ 10 skipped benchmarks1


Comparing feat/plugin-timings-clock-only-when-measured (88522a4) with main (84d18c3)

Open in CodSpeed

Footnotes

  1. 10 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@IWANABETHATGUY
IWANABETHATGUY merged commit 78d6f14 into main Jul 31, 2026
36 checks passed
@IWANABETHATGUY
IWANABETHATGUY deleted the feat/plugin-timings-clock-only-when-measured branch July 31, 2026 04:25
@rolldown-guard rolldown-guard Bot mentioned this pull request Aug 3, 2026
shulaoda added a commit that referenced this pull request Aug 3, 2026
## [1.2.2] - 2026-08-03

### 🚀 Features

- code-splitting: support inlining of shared deps in dynamic entries (#10526) by @nicolo-ribaudo
- plugin: time the user callbacks configured on the options (#10509) by @IWANABETHATGUY

### 🐛 Bug Fixes

- dev: force `cleanDir` off in dev mode (#10579) by @shulaoda
- dev: keep `?rolldown-lazy` proxy ids out of user `resolveId` hooks (#10580) by @btea
- initialize re-exported wrapped ESM modules at the entry chunk (#10567) by @hyfdev
- link: resolve circular star reexports as null (#10445) by @Nic-Polumeyv
- transform: transformer gate skips newer syntax that oxc can lower (#10564) by @sekyungk
- code-splitting: materialize consumer-local barrel routing when the order-wrap plan is empty (#10544) by @hyfdev
- plugin: measure plugin hooks in JavaScript, report them from Rust (#10508) by @IWANABETHATGUY
- plugin: include external dynamic imports in chunk metadata (#10557) by @hyfdev
- plugin: report plugin timings after closeBundle has run (#10521) by @IWANABETHATGUY
- browser: avoid using node builtin modules (#10542) by @sapphi-red

### 🚜 Refactor

- plugin: give the build's own clocks their own type (#10520) by @shulaoda

### 📚 Documentation

- correct stale `buildStart` comment in `ScanStageCache::merge` (#10577) by @shulaoda
- update outdated pluginutils references (#10574) by @dogledogle

### ⚡ Performance

- external: drop the runtime import from chunks that never wrap (#10517) by @IWANABETHATGUY
- plugin: clock the build only when it is being measured (#10558) by @IWANABETHATGUY

### 🧪 Testing

- vite-tests: drop the dead `@rolldown/pluginutils` pnpm override (#10575) by @IWANABETHATGUY
- transform: group the transform-target fixtures and say why each exists (#10569) by @IWANABETHATGUY
- dev: fix hmr-hot-update-hook-vite fixture on Windows (#10565) by @h-a-n-a
- dev: match Vite's renamed full-reload log (#10547) by @shulaoda

### ⚙️ Miscellaneous Tasks

- deps: update napi (#10576) by @renovate[bot]
- deps: bump `@napi-rs/wasm-runtime` to 1.2.2 (#10570) by @shulaoda
- deps: update npm packages (#10583) by @renovate[bot]
- deps: update dependency rolldown-plugin-dts to ^0.28.0 (#10588) by @renovate[bot]
- deps: update taiki-e/install-action action to v2.85.5 (#10587) by @renovate[bot]
- deps: update codspeedhq/action action to v5 (#10584) by @renovate[bot]
- deps: update github actions (#10582) by @renovate[bot]
- deps: update rust crates (#10581) by @renovate[bot]
- deps: update dependency vite-plus to v0.2.7 (#10568) by @renovate[bot]
- deps: update dependency rolldown-plugin-dts to v0.27.14 (#10531) by @renovate[bot]
- deps: update pnpm to v11.17.0 (#10571) by @renovate[bot]
- deps: update @napi-rs/wasm-runtime to 1.2.1 (#10545) by @sapphi-red

### ❤️ New Contributors

* @sekyungk made their first contribution in [#10564](#10564)
* @nicolo-ribaudo made their first contribution in [#10526](#10526)

Co-authored-by: shulaoda <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants