Repository navigation
Conversation
1 task
This comment was marked as resolved.
This comment was marked as resolved.
1 task
Member
|
Can these changes be detached from the changes in #32023 for easier review? If not review must wait until merge and rebase. |
Contributor
Author
The changes aren't fully orthogonal, so splitting them into standalone PRs would require some rework. I'll rebase each PR as soon as its prerequisite is merged. |
Neroued
force-pushed
the
perf/jinja-scopes
branch
3 times, most recently
from
November 12, 2026 13:40
56df0cc to
d5390c1
Compare
Assisted-by: GPT-6 Astra
Neroued
force-pushed
the
perf/jinja-scopes
branch
from
November 14, 2026 13:28
d5390c1 to
a810363
Compare
Neroued
marked this pull request as ready for review
November 14, 2026 13:37
Collaborator
|
I verified with fable 5.2, the verdict is: the gain is too tiny compared to the complexity it adds. So unless @CISC says otherwise, I'd recommend closing this for now |
Member
Agreed. |
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.
Overview
Second part of the rendering optimizations discussed in #32002, following the Value/lookup change #32023.
Replaces variable-map copies on ordinary scope entry with parent lookup and reusable frames. Caller captures retain detached binding snapshots, owned by the callable and released when it is no longer needed. Render teardown clears remaining cycles; captured contexts stay safe to destroy after the root context ends.
Preserves upstream call-site macro lookup and caller snapshots, including their execution metadata. Executing a captured caller after its root render has ended reports an error.
Additional information
Jinja tests passed on x86 and DGX Spark. New tests cover prompt release of caller captures, saved callers, snapshot metadata, exception cleanup, and teardown. The combined stack also passes the relevant ASan/UBSan checks.
Before: values branch. After: this change. Median of five renders after warmup, in milliseconds; templates compiled once. Timing includes JSON-to-Value conversion, execution, output gathering and context destruction.
The early-exit microbenchmark does not improve at this stage: it still uses eager loop setup. The separate loop change addresses that cost.
The benchmark harness remains in the independent reference branch. This PR contains implementation changes and correctness tests only.
Requirements