Skip to content

Deferred performance experiments and architectural optimisation backlog #144

Open

Description

@JuroOravec

Track deferred performance experiments that do not have a dedicated issue. This is a backlog, not a commitment to implement every idea or a claim that the prototypes are production-ready. Split an item into its own issue when active implementation needs a separate design.

Experiments owned here

  • Incremental server updates. Revisit during a dedicated server-event request/response performance pass. Compare complete Render, the existing Data action with application-owned browser updates, and component/marked-region or changed-row updates. Do not assume a new protocol is needed. Measure request/response bytes, state reconstruction, callbacks, rendering/serialization and browser response application through the layout-inclusive endpoint at 140 and 1,400 outputs. Check revision ordering, overlapping/stale responses, Events security, target lifetime, local state, cleanup and out-of-band targets. Preserve the component/marker targeting contract.

  • Vue islands and on-demand activation/assets. Test a workload with substantial inactive or offscreen content. The current board needs all row controls ready and already shares assets; its limited per-row island fixture was slower. Generalize the mocked HTML-to-Vue promotion/demotion proof, including server-rendered insertions, parent/child scope, callbacks, cancellation, disposal and readiness. The old Alpine backlog Alpine/Citry deferred interoperability backlog #37 is not the current design.

  • Teleport controls into server-rendered HTML. Establish compiler support and matching SSR/hydration anchors before a real-page experiment. Synthetic fixture timings do not establish a product gain. Check target lifetime, updates, scope, local state and cleanup; compare total server-plus-browser time.

  • Native Rust rendering architecture. Explore native ownership of render scheduling, selected structure and output encoding, keeping user callbacks and opaque Python values in Python. Avoid rebuilding the same graph in both languages or crossing PyO3 per field. Map extension mutations, slots, caching, errors and planned APIs before implementation; measure a bounded equivalent-output proof rather than extrapolating from Rust template engines. Existing analysis: docs/design/rust_rendering.md in the Vue performance work. Hypothesis (2026-09-28): moving the server rendering work to Rust could cut Citry's server time to roughly one third, using Django templates vs Django Rusty Templates as a ballpark for what a Rust engine saves over a Python one. On the project-board benchmark, Citry's server prepare is about 158 ms at 1,400 outputs (first load), while the fastest server-rendered stacks finish the whole request-to-layout in about 270–315 ms (Nuxt, Rusty, Jinja). If the hypothesis holds, Citry would be close to or comparable with them, which would make it the first Python SSR framework that combines template-engine speed with full SSR, hydration and end-to-end typing. First step: a bounded equivalent-output proof on the board's row template (Python callbacks and opaque values stay in Python) that measures the real server saving instead of extrapolating.

    • Projection (maintainer note, 2026-09-28): if a Rust migration saved about 65% of server time, as Rusty Templates does over Django templates, Citry's board request-to-layout would be roughly 73/63 ms at 140 outputs (first/second load; possibly 66/63) and 265/252 ms at 1,400 (possibly 245/232), which would make it the fastest Python frontend framework on this benchmark.
    • Caveats to state with any such claim: Citry is not a templating engine, so for HTML that never reaches a browser, Jinja or Django templates stay faster (with weaker DX and fewer features). A REST API with Vue or React is still the fastest combination overall, though Citry and Nuxt pull ahead at larger page sizes. SSR frameworks such as Nuxt and Next are in the same speed range; Citry is the closest Python equivalent to Nuxt.
  • Combine repeated browser startup validation and registry construction. Identify checks that can run once or while building required maps. Preserve graph/identity invariants, asset policy/integrity and rejection before irreversible update effects. Do not simply disable validation in production. Measure startup and failure behavior separately from the already implemented early script downloads.

  • Optimized Vue subtrees across structural server updates, if new evidence warrants it. The real-page native compiler-hint trial was flat; do not repeat it unchanged. A future design could isolate replaceable boundaries while retaining compiler optimizations below them, but must demonstrate slot/directive/remount/state and callback correctness before claiming a benefit.

  • Check lightweight component declarations once. Done in the Vue performance work: admission is computed once per class with explicit invalidation keys (extension set, cache revision, i18n registry generation, abc.get_cache_token(), template identity).

  • Lazy hydration of below-the-fold components. Vue 3.5 core provides hydrateOnVisible, hydrateOnIdle, hydrateOnInteraction and hydrateOnMediaQuery for components defined with defineAsyncComponent({ loader, hydrate }); Nuxt exposes them as hydrate-on-* props on lazy components. Citry registers component definitions directly, so it does not get this automatically: the runtime would need to wrap selected definitions as async components with a hydration strategy, while the server still writes their HTML. Design how an author opts a call or component in, how Events, onServerRender and server Render updates behave for a component that has not hydrated yet, and measure ready and layout on a page with substantial offscreen content.

  • Adopt non-interactive subtrees without hydrating them element by element. Subtrees with no Vue bindings could be adopted as one fixed block (the mechanism that now hydrates <c-raw>/Markup blocks by node count), decided once per compiled template rather than by parsing each row. Earlier related attempts: the private four-region split with count-only adoption, and the removed automatic Vue-free grouping, which lost because it parsed every row in Python and changed whitespace. Caching static elements the way Vue 3.5's compiler does was measured and rejected. Vize 0.420.0 writes module-level _hoisted_N constants instead of that per-instance cache, so Citry had to rewrite its output, and Vize has no pass that turns a large static subtree into one HTML string. The cached build was flat to about 1% slower on the board (ready at 1,400 rows, first load: 335.4 ms default vs 339.7 ms cached; warm server render 107.4 vs 107.6 ms; first paint 296 vs 280 ms, within noise), and elements whose contents the browser builds stayed empty when they sat inside a cached element. It sped up local re-renders (26.75 to 16.7 ms for 50 updates) only on a synthetic page with static sections under v-show wrappers. Details are in the decision ledger of docs/design/performance_architecture_experiments.md. Measure first paint (FCP/LCP) and ready separately. Measured 2026-09-28 (Nuxt-style server-only regions, benchmark-only): per-row regions saved only 1.5% at 1,400 rows; element checks are cheap and the remaining hydration cost looks per component instance. Whole phase groups as regions were 32–34% faster but disable interactive rows inside them. Not built; lazy hydration and fewer instances per row look like the better routes.

  • First-request warm-up. A fresh server process spends about 45–65 ms extra on its first page (template and Vue compilation, class creation, lazily imported render modules). Offer an explicit warm-up (for example an engine method that compiles registered templates and loads the render modules at startup, or a documented render-once at boot) and decide whether frameworks' build-time compilation makes it fair to use in the benchmark.

Maintainer review of the benchmark report

  • Go over Server-action latency: what each action means and how it is defined, and why Citry shows an "unclassified" block for the filter action at 1,400 outputs.
  • Go over the size graphs: whether responses are compressed in the benchmark, and whether the other frameworks compress theirs.
  • Go over the remaining graphs (memory, DOM size, the rest).
  • Landing page comparison section: an interactive graph comparing Citry with the other frameworks across scenarios, based on these benchmark results but with more striking styling. This is where the claim from the Rust item would go once confirmed: the first Python SSR framework combining template-engine speed with full SSR and end-to-end typing.

Work with dedicated owners

Productionizing simple = "vue", partial SSR, initial HTML adoption and safe direct bindings is the current Vue implementation work, not deferred by this issue. Shared compile-time whitespace handling is part of that work; its final performance comparison follows productionization.

For every experiment record the control, complete output/behavior checks, server and browser costs, result, and acceptance/rejection. Keep rejected attempts distinct from untested ideas. The local decision record is docs/design/performance_architecture_experiments.md.

Robustness items moved from #21

These came from the closed #21 backlog. They are robustness fixes rather than
performance experiments; the first is the same kind of problem as #299.

  • A chain of <c-component> wrappers adds Python frames per level, because _render_value renders each target in place (about 200 levels hit the recursion limit). Return a DeferredComponent from the wrapper instead, as Follow-up to #272: forwarded slot chains and simple='vue' components still use Python frames per level #299 does for forwarded slots.
  • An error in one attribute underlines the whole start tag. Underline the attribute that failed (each attribute already records its position).
  • A child component's error shows the component path but not the line of the parent's tag. Store the tag position on DeferredComponent and add "included at line N".
  • Two fills with the same name in one <c-if> or <c-for> branch fail only at render time. Report them when the template is parsed.
  • <c-component is="Card"> with a literal is skips the parse-time Kwargs and slot check that <c-card> gets. Apply Card's rules when is is a literal.
  • When on_component_rendered replaces a component's output, the dependencies its discarded children added stay on the page.
  • A component rendered later from inside a fill reports an error path without the slot frame (Card(slot:body)).
  • Calling reset_template() or reset_files() on a parent class leaves subclasses with their cached copies. Clear them too.
  • citry watch watches only settings.dirs by default. Also watch asset folders next to each component's Python file.
  • Only the Django integration can restart the server on reload. Add a request_restart callback for standalone citry watch.

Activity

  1. changed the title [-]Evaluate incremental rendering during a dedicated server-event performance pass[/-] [+]Deferred performance experiments and architectural optimisation backlog[/+] on Sep 24, 2026
  2. added
    next-sprint
    on Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    next-sprint

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions