Skip to content

Accept any user-timing detail and use measure()'s end mark without a start - #8769

Merged
littledivy merged 2 commits into
mainfrom
littledivy/2026-11-21-wpt-user-timing
Nov 21, 2026
Merged

littledivy merged 2 commits into
mainfrom
littledivy/2026-11-21-wpt-user-timing

Conversation

@littledivy

@littledivy littledivy commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

The User Timing spec types detail as any, but workerd took it as an object, so performance.mark('a', { detail: null }), or a number or string detail, threw a TypeError. performance.measure('a', undefined, 'end') also ignored the end mark and measured from 0 to now, because the end mark was only read when the start was a mark name.

In this patch mark(), measure() and the PerformanceMark constructor keep any value as detail, and an undefined detail still reads back as null. measure() also uses the end mark when the start is missing or an options object without start, end or duration. A mark that doesn't exist still falls back to the default time, and options with those fields behave as before, so no call that works today starts throwing.

The measure() change gives a different duration for measures that pass an end mark without a start, and it has no compatibility flag. We accept that risk: the old result ignored an argument the caller passed, and the new one is what the spec and browsers return.

The measure-l3 WPT subtest now passes. The mark-l3 and measure-with-dict subtests that check detail finish from a PerformanceObserver callback, and observe() is a no-op, so they are now disabled instead of expected to fail. New tests in perf-hooks-nodejs-test.js cover both changes.

//src/wpt:user-timing@, //src/wpt:user-timing@all-autogates, //src/workerd/api/node/tests:perf-hooks-nodejs-test@ and //src/workerd/api/node/tests:perf-hooks-nodejs-test@all-compat-flags each passed 100 of 100 runs with --runs_per_test=100.

The User Timing spec types `detail` in `PerformanceMarkOptions` and `PerformanceMeasureOptions` as `any`, but workerd took it as an object, so `performance.mark('a', { detail: null })`, a number or a string threw a TypeError.

In this patch `mark()`, `measure()` and the `PerformanceMark` constructor keep any value as `detail`. An undefined or missing `detail` still reads back as null. The two WPT subtests that check this finish from a PerformanceObserver callback, and `observe()` is a no-op, so they are disabled instead of expected to fail.
@littledivy
littledivy requested review from a team as code owners November 21, 2026 03:34

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superseded by the review of 696b1cc4.

This review, of dae3f7c4

💬 Approved with comments — The change is correct and tested. One WARNING: the measure() end-mark fix changes results for existing Workers, and the commits don't say whether a compatibility flag is needed or the risk is accepted.

Findings: 1 warning (1 is an inline comment on the diff)

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.

🔧 Fix with your agent

Paste the following into your coding agent to investigate and fix these issues.

Fix the following code review issues found in pull request #8769.

Before making changes, review each issue and present a brief summary table:
- For each finding, state whether you agree, disagree, or need clarification
- If you disagree (e.g., the fix would require disproportionate changes
  for minimal ROI, or the finding is factually incorrect), explain why
- If you need to clarify something before deciding, ask those questions
- Then share your plan for which issues to tackle and in what order

## WARNING (1)

### [Code Quality] `measure()` now returns a different duration for existing calls that pass an end mark without a start, and no compatibility flag or accepted-risk note is recorded.
- **File:** src/workerd/api/performance.c++:278

📋 Code Quality: ⚠️ 1 warning

One compatibility note on the measure() end-mark change

Recommendation: 📝 Minor Comments

  • [WARNING] measure() now returns a different duration for existing calls that pass an end mark without a start, and no compatibility flag or accepted-risk note is recorded. (src/workerd/api/performance.c++:278)
View full review

The detail type change and the findMarkTime refactor are correct, and the new tests cover both behaviours.

The measure() change alters what existing Workers observe. Today, performance.measure(name, undefined, endMark) and measure(name, {}, endMark) measure from 0 to now, and with this change they measure from 0 to the end mark. That matches the spec. However, the repository's backward-compatibility rules ask for the decision to be recorded in the commit message: either gate the change behind a compatibility flag or state that the risk is accepted.


✅ All other checks passed

🔒 Security: ✅ LGTM

No security issues. detail is only stored and handed back through getHandle(js), and it is traced for GC.


📖 AGENTS.md: ✅ LGTM

No AGENTS.md updates needed.


⚡ Performance: ✅ LGTM

No performance issues. findMarkTime avoids allocating the filtered arrays that getEntriesByName built.


📝 Documentation: ✅ LGTM

No documentation issues.


Reviewed commit: dae3f7c4

Comment thread src/workerd/api/performance.c++ Resolved
`performance.measure('a', undefined, 'end')` ignored the end mark and measured from 0 to now, because the end mark was only read when the start was a mark name.

In this patch the end mark is also used when the start is missing or an options object without `start`, `end` or `duration`. A mark that does not exist still falls back to the default time, and an options object with those fields keeps today's behaviour.

This changes the duration of measures that pass an end mark without a start, without a compatibility flag. We accept the risk: the old result ignored an argument the caller passed, the new one is what the spec and browsers return, and no call that works today starts throwing.
@littledivy
littledivy force-pushed the littledivy/2026-11-21-wpt-user-timing branch from dae3f7c to 696b1cc Compare November 21, 2026 03:41

@clanky-the-clanker clanky-the-clanker Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💬 Approved with comments — The change is correct and tested. One WARNING: the measure() end-mark fix changes results for existing Workers, and the commits don't say whether a compatibility flag is needed or the risk is accepted.

Findings: 1 warning

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.

🔧 Fix with your agent

Paste the following into your coding agent to investigate and fix these issues.

Fix the following code review issues found in pull request #8769.

Before making changes, review each issue and present a brief summary table:
- For each finding, state whether you agree, disagree, or need clarification
- If you disagree (e.g., the fix would require disproportionate changes
  for minimal ROI, or the finding is factually incorrect), explain why
- If you need to clarify something before deciding, ask those questions
- Then share your plan for which issues to tackle and in what order

## WARNING (1)

### [Code Quality] `measure()` now returns a different duration for existing calls that pass an end mark without a start, and no compatibility flag or accepted-risk note is recorded.
- **File:** src/workerd/api/performance.c++:278

📋 Code Quality: ⚠️ 1 warning

One compatibility note on the measure() end-mark change

Recommendation: 📝 Minor Comments

  • [WARNING] measure() now returns a different duration for existing calls that pass an end mark without a start, and no compatibility flag or accepted-risk note is recorded. (src/workerd/api/performance.c++:278)
View full review

The detail type change and the findMarkTime refactor are correct, and the new tests cover both behaviours.

The measure() change alters what existing Workers observe. Today, performance.measure(name, undefined, endMark) and measure(name, {}, endMark) measure from 0 to now, and with this change they measure from 0 to the end mark. That matches the spec. However, the repository's backward-compatibility rules ask for the decision to be recorded in the commit message: either gate the change behind a compatibility flag or state that the risk is accepted.


✅ All other checks passed

🔒 Security: ✅ LGTM

No security issues. detail is only stored and handed back through getHandle(js), and it is traced for GC.


📖 AGENTS.md: ✅ LGTM

No AGENTS.md updates needed.


⚡ Performance: ✅ LGTM

No performance issues. findMarkTime avoids allocating the filtered arrays that getEntriesByName built.


📝 Documentation: ✅ LGTM

No documentation issues.


Reviewed commit: 696b1cc4 — same changes as dae3f7c4, so this is that commit's review (no new review was run; line numbers are as of dae3f7c4)

@littledivy
littledivy merged commit 8b8d4e5 into main Nov 21, 2026
24 checks passed
@littledivy
littledivy deleted the littledivy/2026-11-21-wpt-user-timing branch November 21, 2026 04:06
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