Add benchmark suite and fix core rendering hot-path inefficiencies - #183
Closed
berendkleinhaneveld wants to merge 1 commit into
Closed
Add benchmark suite and fix core rendering hot-path inefficiencies#183berendkleinhaneveld wants to merge 1 commit into
berendkleinhaneveld wants to merge 1 commit into
Conversation
Establishes a pytest-benchmark suite (mirroring ../observ's setup) plus a GitHub Actions workflow that compares PR vs master and fails on >5% mean regression, so future performance changes have numbers to prove themselves against. Uses that suite to verify three fixes: weak.py's arity check no longer builds a full inspect.Signature per callback, ComponentFragment.mount() reuses the existing first() DFS instead of a hand-rolled BFS, and Fragment._component_parent() is now cached instead of walking the parent chain on every attribute update (with an explicit invalidation hook for the one place a mounted fragment gets silently reparented: dynamic <component :is="..."> tag switches). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Collaborator
Author
|
Superseding this with a split series so each change is proven independently by CI:
The sound fixes from this branch are carried over essentially verbatim. Keeping this branch around as reference until the series lands. |
This was referenced Jul 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
pytest-benchmarksuite (bench/) covering mount cost, nested-component mount, attribute-update-at-depth, and keyed/unkeyedv-forreconciliation, mirroring the siblingobservrepo's setup..github/workflows/benchmark.yml: on PRs, runs the suite against master and against the PR branch, failing the job if mean time regresses >5%.weak.py: the arity check no longer builds a fullinspect.Signatureper callback, just reads__code__.co_argcount. ~25-33% faster mounting of elements with dynamic binds.ComponentFragment.mount(): replaces a hand-rolled BFS/dequewith the already-existingfirst()DFS helper. Added a regression test for the wrapped-root case.Fragment._component_parent(): now cached instead of walking the parent chain on every attribute update. Flattensupdate_at_depthbenchmark scaling from ~5/7.2/15.5µs (depths 10/50/200) to a flat ~4.3µs. Includes an explicit cache-invalidation hook for the one place a mounted fragment is silently reparented (<component :is="...">tag switches), with a regression test (test_dynamic_component_tag_switch_updates_correct_owner) that fails without the invalidation and passes with it.Test plan
uv run pytest tests -q— 266 passed, 14 skipped (up from 264/14 baseline; two new regression tests added)uv run ruff check ./uv run ruff format --check .— cleanuv run pytest bench --benchmark-only— all 36 benchmark cases pass_component_parentcache-invalidation regression test fails when the invalidation hook is removed, and passes when restoredbenchmark.ymlworkflow runs successfully in CI on this PR🤖 Generated with Claude Code