Repository navigation
perf(vapor): add fast path for static class names - #14803
Conversation
Specialize simple class object and empty-string ternary bindings into flag-based setClassName calls, avoiding normalizeClass on the pure Vapor class hot path while preserving static class ordering and falling back for unsafe shapes. Browser bench shows ~2.4x faster stable single-key ternary updates, ~9x faster stable single-key object updates, ~22-36x faster stable multi-key object updates, and ~5-7x faster sparse multi-key churn. Co-authored-by: Copilot <[email protected]>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Comment |
@vue/compiler-core
@vue/compiler-dom
@vue/compiler-sfc
@vue/compiler-ssr
@vue/compiler-vapor
@vue/reactivity
@vue/runtime-core
@vue/runtime-dom
@vue/runtime-vapor
@vue/server-renderer
@vue/shared
vue
@vue/compat
commit: |
Size ReportBundles
Usages
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
vite.config.ts (1)
91-113: ⚡ Quick winGate
bench-browserbehind an env flag or separate config.The comment a few lines below already documents that Vitest initializes all projects even when
--projectfilters them. Registering this browser benchmark project unconditionally means normal unit runs now pay the Playwright/browser-project startup cost. Browser instances are initialized as part of multi-project resolution and are not skipped by project filtering—they even use derived instance names (e.g.,<project> (chromium)) that can bypass filter patterns. Mirror theVAPOR_E2Epattern here to avoid this overhead during typical development workflows.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@vite.config.ts` around lines 91 - 113, Gate the "bench-browser" Vitest project registration behind an environment flag (reuse the existing VAPOR_E2E pattern) so browser/playwright setup is only created when explicitly enabled; specifically modify the object with name 'bench-browser' (the project that sets browser.provider = playwright(...) and benchmark.include = ['packages/runtime-vapor/__tests__/bench/*.bench.ts']) to be conditionally added to the projects array only when process.env.VAPOR_E2E (or a new flag) is truthy, preventing unconditional Playwright/browser initialization during normal runs.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/runtime-vapor/src/dom/prop.ts`:
- Line 53: optimizePropertyLookup() currently predeclares $html, $cls and $sty
but not the new hot-path field $clsFlags introduced by setClassName(), which
forces an extra expando/shape transition; update optimizePropertyLookup() to
seed $clsFlags alongside $html/$cls/$sty so optimized elements allocate that
property in the shape up-front (add the $clsFlags predeclaration in the same
initialization block and any shape / sentinel logic that lists the optimized
props).
---
Nitpick comments:
In `@vite.config.ts`:
- Around line 91-113: Gate the "bench-browser" Vitest project registration
behind an environment flag (reuse the existing VAPOR_E2E pattern) so
browser/playwright setup is only created when explicitly enabled; specifically
modify the object with name 'bench-browser' (the project that sets
browser.provider = playwright(...) and benchmark.include =
['packages/runtime-vapor/__tests__/bench/*.bench.ts']) to be conditionally added
to the projects array only when process.env.VAPOR_E2E (or a new flag) is truthy,
preventing unconditional Playwright/browser initialization during normal runs.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: eb99856b-d1a3-4f00-91f7-0d5b451ca983
⛔ Files ignored due to path filters (3)
packages/compiler-vapor/__tests__/transforms/__snapshots__/transformElement.spec.ts.snapis excluded by!**/*.snappackages/compiler-vapor/__tests__/transforms/__snapshots__/vBind.spec.ts.snapis excluded by!**/*.snappackages/compiler-vapor/__tests__/transforms/__snapshots__/vFor.spec.ts.snapis excluded by!**/*.snap
📒 Files selected for processing (8)
packages/compiler-vapor/__tests__/transforms/vBind.spec.tspackages/compiler-vapor/__tests__/transforms/vFor.spec.tspackages/compiler-vapor/src/generators/prop.tspackages/runtime-vapor/__tests__/bench/setClass.bench.tspackages/runtime-vapor/__tests__/dom/prop.spec.tspackages/runtime-vapor/src/dom/prop.tspackages/runtime-vapor/src/index.tsvite.config.ts
Specialize simple class object and empty-string ternary bindings into flag-based setClassName calls, avoiding normalizeClass on the pure Vapor class hot path while preserving static class ordering and falling back for unsafe shapes.
Browser bench shows ~2.6x faster stable single-key ternary updates, ~9-21x faster stable single-key object updates depending on static base classes, ~30-37x faster stable multi-key object updates, and ~5-8x faster sparse multi-key churn.
Summary by CodeRabbit
:classbindings through optimized code generation and efficient bitmask-based class handling.