Repository navigation
Description
Problem
During the 0.7.0 work we measured many internal limits and speeds by hand: how deep a template can nest before a stack runs out, how citry check and the formatter scale with nesting depth, how the editor's search scales, how many stack frames a slot chain costs. Each measurement was run once, for one pull request, and then dropped. Nothing tells us later if one of them gets worse again. A slowdown that grows with the square of depth, or a stack limit that shrinks, only shows up when a user hits it.
Proposal
Run these measurements once a week and keep their results, so a regression shows up as a change between weeks instead of a user report.
- Run them in one place, ideally as a step in an existing weekly job such as
py--tests-cross-browser.ymlorpy--alt-interpreters.yml, not as a new workflow. - Use release builds, because CI's ordinary test jobs already build release extensions (
uv syncbuilds the release profile). - For each measurement, record the numbers (a JSON artifact, or a file committed to
benchmarks/results/) and fail, or open a tracking issue, when a value crosses its threshold. - Prefer ratios over absolute times where the measurement is about growth (time when the depth doubles), because ratios survive runner noise much better than raw seconds.
Measurements to start from
Each pointer is where the measurement or its script came from.
Growth with nesting depth (time per depth doubling)
citry checkon four deep templates (<c-if><div #c-ignore>,<c-if>,<div>, a<c-if>…<c-elif>chain) at 128/256/512 levels. Plan limit: at most 2.5x per doubling.citry checkslows down with roughly the cube of template nesting depth #384, PR perf: share a parsed template's lists instead of copying them on each read #527; plan in the PR.- The Vue compile that
citry checkruns once per component (_rust.vue._compile_vue), which grew about 3x per doubling. citry check's Vue compile grows faster than template depth #501. - The editor's per-expression template search (
template_python_queries), which grew with the square of depth. The editor's per-expression template search grows with the square of nesting depth #497. - The formatter on
<div c-for>chains at 50/100/200/400 levels (it took 42 s at 400 before the fix). The template formatter slows down sharply when elements with Python expressions are nested deeply #421, PRs perf: measure formatter columns in the text each pass will produce #432 and fix: measure a start tag with the text that stays on its line #462. - The parse costs that grew with the square of template length. perf: remove four parse costs that grew with the square of template length #323.
Stack depth and frame budgets
- The parser and compiler nesting limits (512 elements, 256 logic levels) and the tests that sit at them:
crates/citry_template_formatter/tests/deep_elements.rs,crates/citry_template_parser/tests/deep_nesting.rs,packages/py/citry/tests/_frame_budget.py,test_frame_budget_rust.py. 50 nested<c-if>blocks fail with "too many nested parentheses", and about 1,000 crash the process #272 series, C2 (feat: limit templates to 512 nested tags and 256 logic levels #470). - Stack guards on every Rust entry point, checked on a 512 KiB thread. fix: start each deep Rust entry point with a stack guard #428.
- The native render path's depth limits (release 64/64, debug 8/16) and the crash depth they protect (about 140 nested loops on a 128 KiB release thread). The native render path overflows a small thread's stack on a template with 100 nested loops #422, PR fix(native-render): leave templates nested past a depth limit to Python #499.
- Forwarded slot chains: frames per link (10 before, flat after) and the longest chain that renders. Follow-up to #272: forwarded slot chains and simple='vue' components still use Python frames per level #299, PR fix: render a fill passed on through components in the running body loop #522;
benchmarks/slot_renders.py. - Deep
simple='vue'templates: frames at 256 levels (266 before, about 19 after). Follow-up to #272: forwarded slot chains and simple='vue' components still use Python frames per level #299 PR B. - Deep
js_data()copies and_json_plain's direct-call depth. fix: copy deeply nested js_data() on any Python #412, fix: write deep data for the browser with a bounded number of frames #391. - Vue server rendering depth (elements the server writes before the browser takes over). fix: compile and server-render deep Vue templates on any thread #400.
Ordinary speed (the "no slower than 2%" gates)
benchmarks/compare.py --size lg, native render on and off. Used as the gate for fix: start each deep Rust entry point with a stack guard #428, Follow-up to #272: forwarded slot chains and simple='vue' components still use Python frames per level #299 and the E-series.benchmarks/i18n.py. Used for fix: start each deep Rust entry point with a stack guard #428.benchmarks/slot_renders.py: 300 filled slots, fallback and chain variants. perf: render nested slot fallbacks without a Python call per level #397, fix: render a fill passed on through components in the running body loop #522.citry checkand parse plus compile over all Citry UI templates.citry checkslows down with roughly the cube of template nesting depth #384, PR perf: share a parsed template's lists instead of copying them on each read #527.
Idle behaviour
- The idle-loop guard over the Citry UI quality scenarios (
packages/py/citry_ui/citry_ui/quality/tests/e2e/test_idle_scenarios_e2e.py) already runs weekly. fix: stop Citry UI menus and pickers from looping while idle #483. It is listed so the results can be collected alongside the others.
Open questions
- Where results are kept, and for how long (artifacts expire; a committed file grows).
- Thresholds: a fixed number per measurement, or a change against the previous week.
- Noise: GitHub runners vary, so the gates that compare two builds should alternate them in one job, as the local gates did, rather than compare against last week's absolute times.
Activity