Skip to content

perf(vom): avoid repeated sibling scans for duplicate action labels - #271

Merged
iuyo5678 merged 1 commit into
Tencent:mainfrom
lyingbug:perf/vom-sibling-context-cache
Sep 18, 2026
Merged

iuyo5678 merged 1 commit into
Tencent:mainfrom
lyingbug:perf/vom-sibling-context-cache

Conversation

@lyingbug

Copy link
Copy Markdown
Contributor

Problem

When a page contains many repeated action buttons in the same container, collectSameContainerContext scans the preceding siblings again for every button. A flat list of Record N labels and Open buttons therefore performs quadratic context work, even though each handle retains at most three candidate labels.

Change

Cache sibling-prefix progress for each parent during one render, keyed by context scope, target name, and incoming labels. Reuse the prefix when later handles request compatible context, and restart if traversal asks for an earlier prefix. Limit retained variants to 64 per parent. This preserves the existing label selection and frame-scope rules.

Add work-count regressions at 100, 600, and 2,000 actions, assert every resulting handle context, and run the VOM suite in CI. This PR is independent of the downstream browser, gateway, and session patches.

Measured effect

Local Node 20.20.0 measurements against 75e2c64, using the same flat-list fixture as the regression: three warm-up renders per implementation, then nine alternating timed renders; values below are medians. The complete render outputs matched.

Repeated buttons Before After Label reads before → after
100 2.96 ms 0.43 ms 5,450 → 500
600 95.25 ms 2.94 ms 182,700 → 3,000
2,000 1,041.31 ms 8.70 ms 2,009,000 → 10,000

These are synthetic renderer measurements, not end-to-end browser timings. The largest benefit is for repeated actions sharing sibling context; unrelated page shapes need not see the same speedup. CI asserts work counts rather than machine-dependent timings.

Validation

  • All three new regression cases fail their work-count assertion on the original renderer and pass with the change.
  • VOM: 55 tests passed.
  • Extension: 1,741 tests passed, 97 skipped by configuration.
  • Localization: 52 tests passed.
  • pnpm lint passed, including plugin type checking and 240 plugin tests.
  • Extension TypeScript compilation and production build passed.
  • One-off differential check: complete outputs matched the original renderer across 1,500 seeded generated trees with nested containers, frame scopes, and varied repeated action names.
  • git diff --check passed. Live-browser tests were not run.

@lyingbug
lyingbug marked this pull request as ready for review September 17, 2026 09:38
@iuyo5678
iuyo5678 merged commit fa0439d into Tencent:main Sep 18, 2026
11 checks passed
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