Repository navigation
perf: read simple="vue" rows and hash call-run ids in Rust (native render, level A) - #265
Merged
Merged
Conversation
This was referenced Oct 23, 2026
Merged
Merged
…nder level A) Work in progress: the Rust crate citry_native_render, the citry_core._rust.native_render submodule, the decision module citry/_vue/native_render.py, the Python integration, and the tests that compare both render paths. Docs follow. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…and tests Development pages write every row's HTML for the id check, so their rows stay on the Python path. Adds docs/design/native_render.md, the crate's AGENTS.md, the user-facing performance and compatibility notes, both-path runs of the simple='vue' test files, and the remaining level A tests. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Lists every page whose body the serializer keeps (they rebuild each row in Python), renames the hand-back to a rebuild, defines the design doc's terms, and adds coverage tests for the plan guards. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Rust receives the JavaScript int limit from Python instead of copying it, the run-id methods turn panics into RuntimeError, the occurrence writer reports an id with no UTF-8 form as ValueError, and the record's native fields leave equality. The smoke script now runs a row through the reader and the occurrence writer on every wheel; the order tests prove the Rust case read rows; a ComponentLike registration after render is tested; the fixture generator follows nested c-bind paths and the fixtures shrink to about 220 KB. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
JuroOravec
force-pushed
the
perf/native-render-rows
branch
from
October 23, 2026 09:44
c6d8698 to
48b4e3f
Compare
This was referenced Oct 23, 2026
Closed
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.
What this changes
On standard CPython, Citry now does part of each
simple = "vue"row's work in Rust:c-forover a component (ordinary components too), from the same text Python hashes.Output bytes and the order of user callbacks and hooks stay the same on both paths. The callback and hook order tests from b5e9783 (
test_call_run_order.py) now run on both.When the Rust path runs
citry/_vue/native_render.pydecides once, at import. The Rust path runs on CPython with the GIL, outside Pyodide, whencitry_core._rust.native_renderhas every name. PyPy, Pyodide and free-threaded builds take the Python path with no warning. CPython with a missing or stale module takes it with oneRuntimeWarning.CITRY_NATIVE_RENDER=0turns the Rust path off; it is the only new user-facing name.Two cases the maintainer asked to call out:
Citry(mode="development")page checks every element id it writes, so the serializer needs every row's HTML. This includes rows in child components, which the plan had assumed stay on the Rust path. The row read therefore skips Rust for aCitryinstance in development mode, so development pages evaluate every row in Python as before; only the call-run ids still come from Rust, which costs no extra work.<html>document, any CSP setting or nonce, a JavaScript or script-integrity policy,deps_positionother than"smart", a customon_serialize, and a few rarer body contents; seedocs/design/native_render.mdsection 3), plus Events updates and pages with a custom tag callback. These still read rows in Rust, then rebuild every row in Python. The measurement below times two such pages; neither is slower thanmain.Measured
Release wheels of
origin/main(736071308) against this branch, Python 3.12, 5 alternating fresh-process pairs of 11 renders of the benchmark board; mean per process, garbage-collection pauses included.mainThe plan's bar for this level was at least 20% at 1,400 rows and no slowdown at 140 rows. The strict CSP page is about 8.5 times slower than the hydrated page on
maintoo; that cost is in the CSP path and is outside this PR.Notable implementation choices
_PreparedResult(native_rows), not throughcontext.extra, so fix(deps): run on_dependencies() once per instance on interactive pages #260'sSERIALIZATION_NOTE_KEYSis unaffected._prepare_initial_resultnow always returns a_PreparedResult. The five tests that stub it are updated.transform_componentand the shorter per-row path for Rust rows (register_native_member) share one start,start_occurrence, so every row is checked against the registry exactly as before. Only the component tag lookup runs once per class per assembly; the precompile path accepts only the built-in tag callback._manifest_json), instead of replacing a placeholder string, so no user value can collide with a placeholder._RowPlandefines__traverse__, so a dropped template's plan is collected (a test proves it)._NativeRowholds only Rust data and strings, so the collector does not track it.c-bindlayout cache size and the JavaScript int limit arrive with the plan. The fixed text of the manifest format and the value rules are locked by fixtures generated from Python.scripts/vue_render_parity/collect.py) writes the manifest with the Rust rows' data. Otherwise it would have recorded pages without their rows' data.Tests
tests/_render_paths.pyaddsrender_both. It runs a case on both paths in one process, compares bytes or errors, and checks how many rows Rust read and how many rows Python rebuilt, so a case cannot pass because both runs used Python.tests/conftest.pyadds therender_pathandpython_render_pathfixtures and the--python-render-pathoption.tests/test_native_render_rows.py(79 cases, about 4 s on one worker; the one 1,400-row case is markedqualification) covers:ComponentLikeregistrations (before and after the render), each in its own interpreter;python_render_path: three tests intest_simple_vue_row_caches.py(18 ids) look inside the Python evaluator's own caches, so they run on the Python path explicitly.test_simple_vue_mode.py,test_simple_vue_row_html.pyandtest_simple_vue_child_calls.pyrun on both paths (about 4 s more). The order tests also check that their Rust case really read rows.crates/citry_native_render/tests/checks fixtures thatscripts/native_render_fixtures.pywrites from Python (--checkmode, run by a test). The fixtures total about 220 KB; the sdist leaves the crate'stests/out.--python-render-path. Its check name does not change.Cross-binding list
New crate
crates/citry_native_render;crates/citry_core_py/src/native_render/;lib.rsregisters the submodule with#[pymodule(gil_used = true)];_rust.pyi(class native_render);scripts/validators/bindings.pyaccepts#[pymodule(...)]with options;scripts/smoke_citry_core.pyruns a row through the reader, the occurrence writer and the run ids on every wheel;scripts/verify_citry_core_distribution.pyrequires the new crate's manifest;Cargo.lock. No grammar, AST, compiler orLangImplchange. No changelog entry and no version bump (the release PR owns them).Stacked on #263
This PR is based on #263 (the callback-order tests). Merge #263 first.
Not in this PR
The later levels of the plan (one Rust object per loop in serialize, one render task per loop, the loop walk in Rust, and Rust JSON for ordinary leaf data).
🤖 Generated with Claude Code