Skip to content

Add dispatch totals to detector performance - #3234

Draft
GuiltyDolphin wants to merge 1 commit into
gd-c-web-detection-frame-read-cachefrom
gd-c-web-detection-dispatch-totals
Draft

GuiltyDolphin wants to merge 1 commit into
gd-c-web-detection-frame-read-cachefrom
gd-c-web-detection-dispatch-totals

Conversation

@GuiltyDolphin

Copy link
Copy Markdown
Member

Asana Task/Github Issue: https://app.asana.com/1/137249556945/task/1220788961551324

Description

Builds on #3215.

detectorPerf times each detector run on its own, but one call from the browser into web detection (an auto timer, or the breakage report's run) runs several detectors back to back in one task. This adds up the runs in each of those calls as a dispatch total, so we can see how long web detection held the main thread at once:

  • runDetectors increments a dispatch ID, and timeDetector passes it to record with each run
  • record adds the run to its dispatch's total and to its detector's share. A run with a new ID starts a new dispatch, so there's no begin or end call to leave open
  • getStats adds worstDispatch: the frame's dispatch with the largest total, with each detector's share by full detector ID. It's left out when no run had a dispatch ID
  • a dispatch whose total goes past the single-run severe cutoff fires detectorPerf_severe once with kind: dispatch, attributed to the detector with the largest share at that point (a tie goes to the one that ran first). It uses the same per-frame dedup and cap as the other severe kinds

There are no new periodic events or settings, so EventHub config doesn't change. Native pixel definitions that list the kind values of detectorPerf_severe need dispatch added.

Event triggers add more entry points (arrivals, sync listeners, resumed waits), and each of those PRs wires its own into the dispatch ID.

Testing Steps

  • unit tests cover adding runs within a dispatch, per-detector shares, keeping the worst dispatch, runs without a dispatch ID, the severe crossing with the default and configured cutoffs, and the ID passing through timeDetector and runDetectors
  • the detectorPerf integration test for severe crossings now also expects kind: dispatch events, since it sets the single-run cutoff to 0.0001 ms. Note that "breakage reports carry exact per-detector timing stats" fails now and then when tests run in parallel, when an auto run happens between its two reports

Checklist

Please tick all that apply:

  • I have tested this change locally
  • I have tested this change locally in all supported browsers
  • This change will be visible to users
  • I have added automated tests that cover this change
  • I have ensured the change is gated by config
  • This change was covered by a ship review
  • This change was covered by a tech design
  • Any dependent config has been merged

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Build Branch

Branch pr-releases/gd-c-web-detection-dispatch-totals
Commit fa910a07a7
Updated November 30, 2026 at 12:58:10 PM UTC

Static preview entry points

QR codes (mobile preview)
Entry point QR code
Docs QR for docs preview
Static pages QR for static pages preview
Integration pages QR for integration pages preview

Integration commands

npm (Android / Extension):

npm i github:duckduckgo/content-scope-scripts#pr-releases/gd-c-web-detection-dispatch-totals

Swift Package Manager (Apple):

.package(url: "https://github.com/duckduckgo/content-scope-scripts.git", branch: "pr-releases/gd-c-web-detection-dispatch-totals")

git submodule (Windows):

git -C submodules/content-scope-scripts fetch origin pr-releases/gd-c-web-detection-dispatch-totals
git -C submodules/content-scope-scripts checkout origin/pr-releases/gd-c-web-detection-dispatch-totals
Pin to exact commit

npm (Android / Extension):

npm i github:duckduckgo/content-scope-scripts#fa910a07a7cea6caf092add2d008cd5c99c4058e

Swift Package Manager (Apple):

.package(url: "https://github.com/duckduckgo/content-scope-scripts.git", revision: "fa910a07a7cea6caf092add2d008cd5c99c4058e")

git submodule (Windows):

git -C submodules/content-scope-scripts fetch origin pr-releases/gd-c-web-detection-dispatch-totals
git -C submodules/content-scope-scripts checkout fa910a07a7cea6caf092add2d008cd5c99c4058e

@github-actions github-actions Bot added the semver-minor New feature — triggers minor version bump label Nov 23, 2026
@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

[Beta] Generated file diff

Time updated: Mon, 30 Nov 2026 12:58:58 GMT

Android
    - android/adsjsContentScope.js
  • android/contentScope.js

File has changed

Apple
    - apple/contentScopeIsolated.js

File has changed

Chrome-mv3
    - chrome-mv3/inject.js

File has changed

Firefox
    - firefox/inject.js

File has changed

Integration
    - integration/contentScope.js

File has changed

Windows
    - windows/contentScope.js

File has changed

@GuiltyDolphin
GuiltyDolphin force-pushed the gd-c-web-detection-dispatch-totals branch 2 times, most recently from 0737474 to 0a22cc8 Compare November 25, 2026 13:28
@GuiltyDolphin
GuiltyDolphin force-pushed the gd-c-web-detection-dispatch-totals branch from 0a22cc8 to 5f3fd48 Compare November 25, 2026 17:46
@GuiltyDolphin
GuiltyDolphin force-pushed the gd-c-web-detection-dispatch-totals branch from 5f3fd48 to ac01ac5 Compare November 25, 2026 19:18
@GuiltyDolphin
GuiltyDolphin force-pushed the gd-c-web-detection-dispatch-totals branch from ac01ac5 to c2f8ff0 Compare November 25, 2026 20:50
@GuiltyDolphin
GuiltyDolphin force-pushed the gd-c-web-detection-dispatch-totals branch from c2f8ff0 to 1e12f15 Compare November 25, 2026 21:54
@GuiltyDolphin
GuiltyDolphin force-pushed the gd-c-web-detection-dispatch-totals branch from 1e12f15 to edf9c7c Compare November 25, 2026 22:29
@GuiltyDolphin
GuiltyDolphin force-pushed the gd-c-web-detection-dispatch-totals branch from edf9c7c to 06d9af0 Compare November 30, 2026 10:46
This adds the detector work in each call from the browser into web detection up as a dispatch total. Web detection passes a dispatch ID with each run, breakage reports get the frame's worst dispatch with each detector's share, and a dispatch going past the single-run severe cutoff fires detectorPerf_severe with kind dispatch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@GuiltyDolphin
GuiltyDolphin force-pushed the gd-c-web-detection-dispatch-totals branch from 06d9af0 to 3db8f21 Compare November 30, 2026 12:57

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

semver-minor New feature — triggers minor version bump

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant