Skip to content

Reduce collector overhead - #165

Open
mattcosta7 wants to merge 1 commit into
v1.3/04-native-attributionfrom
v1.3/05-collector-overhead
Open

Reduce collector overhead#165
mattcosta7 wants to merge 1 commit into
v1.3/04-native-attributionfrom
v1.3/05-collector-overhead

Conversation

@mattcosta7

Copy link
Copy Markdown
Member

Summary

  • scope style mutation and layer-promotion work to the active story root
  • coalesce pointer sampling into one cancellable RAF pipeline and scan layer candidates in bounded idle chunks
  • remove global forced-reflow prototype patches in favor of native LoAF forced-style/layout evidence
  • add opt-in internal callback, aggregation, serialization, scan, and pending-work telemetry plus a read-only benchmark comparator
  • preserve deprecated metric aliases while clarifying their native replacement semantics
  • escape generated attribution selectors so inspect actions remain valid for special-character DOM identifiers

Benchmark

Compared with the tracked baseline from #161:

  • visible lifecycle mean: -62.1%
  • visible React commit mean: -19.2%
  • visible raw DOM mean: +7.8% in the final one-shot run (+0.7% in the preceding run), so this remains noisy/inconclusive
  • telemetry probe processed all 60 layer candidates and reported zero current RAF, idle-scan, and DOM-count work after cleanup

The tracked baseline was not modified.

Validation

  • 921 browser tests across Chromium, Firefox, and WebKit
  • npm run tsc
  • npm run lint
  • npm run build
  • attw
  • publint
  • full stacked adversarial review using the requested three-persona workflow; its concrete selector-integrity finding was fixed and regression-tested

Stacked on #164. Keep this PR in draft while the v1.3 stack is reviewed.

@mattcosta7
mattcosta7 marked this pull request as ready for review August 3, 2026 16:34
@mattcosta7
mattcosta7 requested a review from a team as a code owner August 3, 2026 16:34
Copilot AI review requested due to automatic review settings August 3, 2026 16:34
@mattcosta7 mattcosta7 self-assigned this Aug 3, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Reduces collector overhead by scoping DOM work, coalescing asynchronous sampling, and replacing prototype instrumentation with native LoAF evidence.

Changes:

  • Scopes mutation and layer scans to the story root.
  • Adds cancellable RAF/idle pipelines and opt-in telemetry.
  • Adds native forced-layout metrics and benchmark comparison tooling.
Show a summary per file
File Description
.changeset/reduce-collector-overhead.md Records the minor release.
README.md Documents metrics, telemetry, and benchmarking.
performance-panel.tsx Displays native forced-layout LoAF counts.
package.json Adds the benchmark comparator command.
core/preview-core.ts Integrates optional telemetry.
core/performance-types.ts Adds the native LoAF metric and alias semantics.
core/overhead-telemetry.ts Implements overhead telemetry.
core/__tests__/overhead-telemetry.browser.test.ts Tests telemetry aggregation.
collectors/README.md Updates collector documentation.
collectors/attribution.ts Escapes generated selectors.
collectors/collector-manager.ts Scopes collectors and aggregates native metrics.
collectors/element-timing-collector.ts Instruments callback overhead.
collectors/forced-reflow-collector.ts Removes prototype instrumentation.
collectors/frame-timing-collector.ts Tracks RAF callback and pending work.
collectors/input-collector.ts Coalesces pointer RAF sampling.
collectors/layout-shift-collector.ts Instruments observer callbacks.
collectors/long-animation-frame-collector.ts Counts forced-layout LoAFs.
collectors/main-thread-collector.ts Instruments long-task processing.
collectors/paint-collector.ts Adds scoped, chunked layer scans.
collectors/react-profiler-collector.ts Instruments profiler callbacks.
collectors/style-mutation-collector.ts Scopes mutation observation.
collectors/__tests__/attribution.browser.test.ts Tests selector escaping.
collectors/__tests__/collector-manager.browser.test.ts Tests scoping, aliases, and telemetry.
collectors/__tests__/forced-reflow-collector.browser.test.ts Removes obsolete instrumentation tests.
collectors/__tests__/input-collector.browser.test.ts Tests RAF coalescing and cancellation.
collectors/__tests__/long-animation-frame-collector.browser.test.ts Tests forced-layout counts.
collectors/__tests__/paint-collector.browser.test.ts Tests scoped chunked scans.
collectors/__tests__/style-mutation-collector.browser.test.ts Tests scoped mutation collection.
__tests__/performance-decorator-universal.browser.test.ts Tests serialization telemetry.
__benchmarks__/overhead.browser.bench.tsx Adds the telemetry probe.
__benchmarks__/compare-results.ts Adds read-only benchmark comparison.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 31/31 changed files
  • Comments generated: 1
  • Review effort level: Balanced

],
"scripts": {
"benchmark": "vitest bench --config vitest.benchmark.config.ts --outputJson benchmark-results.json",
"benchmark:compare": "node __benchmarks__/compare-results.ts benchmark-results.json",
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