Repository navigation
Cut the fixed cost of a macro call (0147) - #448
Merged
Merged
Conversation
Render/macros -10.7% instructions: per-macro flags computed at Load or when the callable is made, one pass over the keyword arguments, values forwarded into their slots instead of copied then moved, and RenderWorkspace Take/Release inline while the current chunk has room. Corpus cases for the argument checks. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QmXwK3VURSCbAQdyqzfjsy
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QmXwK3VURSCbAQdyqzfjsy
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QmXwK3VURSCbAQdyqzfjsy
rmorozov
marked this pull request as ready for review
October 11, 2026 06:36
rmorozov
added a commit
that referenced
this pull request
Oct 11, 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.
Requested by Ruslan · project thread
Before: besides rendering its body (about 530 instructions on
Render/macros), each macro call spent about 1,340 instructions binding and checking its arguments and taking its slot frame.After: about 540 fewer per call. Instruction counts (
bench/count.py --baseline, Release, against master 2486c22):Allocations are unchanged. Render/macros allocates 32 more bytes per render, because a stored default now carries a flag.
How. All changes are in
src/statements.*andsrc/render_workspace.*.ThrowExtraMacroArgs) keeps the old messages and their order.caller/kwargs/varargsis skipped for a macro that catches none of them.RenderWorkspace::Take/Releaseare inline while the current chunk has room.Not done: passing the evaluated arguments by rvalue.
Callable::StatementCallablein internal_value.h, which 0140 is reworking, and the call sites in expression_evaluator.cpp, which wave 2 owns.user_callable.his untouched.The details are in docs/tasks/0147, which is marked done.
Behaviour change, toward Jinja2. A default that names another argument (
b=a) is now bound as evaluated. It is no longer copied when it is a list or dict, sobis the same list asa, as in Python. The new corpus casestatements.macro_default_refers_arg_mutablepins this. Defaults stored at definition are still copied on every call.Four more corpus cases cover the argument checks:
macro_kwargs_too_many_args,macro_varargs_unknown_kwarg,macro_kwarg_and_kwargsandmacro_kwarg_repeats_positional_kwargs.Process.
verifier. The verifier took 1 round. It ran ASan+UBSan ctest (3/3), compared 56 binding templates across old C++, new C++ and Python 3.1.6, and checked clang-tidy 22 and clang-format on the changed lines.b=achange. That is now documented and tested.🤖 Generated with Claude Code
https://claude.ai/code/session_01QmXwK3VURSCbAQdyqzfjsy
Generated by Claude Code