Repository navigation
perf: InternalValue access seam in wave 2's files, plain string alternatives (0140 P0b) - #460
Merged
Merged
Conversation
…natives (0140 P0b) expression_evaluator.*, statements.cpp, python_format and serialize_filters go through AsMap, AsStringView and Kind(); GetStringView and NarrowStringView are removed. GetData() is replaced by detail::InternalValueAccess, used only by internal_value.* and value_visitors.h. TargetString/TargetStringView stop being variant alternatives: values hold std::string, std::wstring, std::string_view or std::wstring_view directly, and ApplyUnwrapped unwraps only host values. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015qGBQQVdqpanbWPSsaMQrL
…tor (clang-tidy) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015qGBQQVdqpanbWPSsaMQrL
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015qGBQQVdqpanbWPSsaMQrL
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: the evaluator and statements reached into
InternalValue's variant directly (GetData(),GetIf<MapAdapter>,holds_alternative), and strings were stored as nested variants (TargetString,TargetStringView), so everyApplychecked three wrappers before visiting.After: code outside internal_value.* and value_visitors.h reads values only through the P0a seam (
AsMap,AsStringView,Kind(),GetIffor callables/pairs), and a value holdsstd::string,std::wstring,std::string_vieworstd::wstring_viewitself. Rendering output is unchanged; Render instructions drop 0..3.5%.This is step P0b of docs/design/0140-internal-value-plan.md: after it, P2's 32 B layout has call sites only in internal_value.* and value_visitors.h.
How.
GetIf<MapAdapter>→AsMap(0154'sx.namefast path included),GetStringView→AsStringView<char>,IsImmutableScalarandInlineScalar::HoldsuseKind()(+ newIsStringView).NarrowStringView(python_format, serialize_filters callers) andGetStringView(markup.h) removed.GetData()replaced bydetail::InternalValueAccess, used only in internal_value.* and value_visitors.h; unusedGet<T>removed.InternalValueDataalternatives:TargetString/TargetStringView→ the four plain string types;InternalValuehas constructors fromTargetString/TargetStringViewthat unpack;ApplyUnwrappedunwraps only host values.Deviation from the plan. The plan expected 72 → 64 B here. It stays 72 B because
ListAdapteris also 40 B (accessor, two flags andm_fieldNamesfrom #401). P2 moves lists behind the object pointer, so no interim packing was done; recorded in docs/tasks/0140.Instruction counts (local,
bench/count.pyvs 1ca9c15). Render: many_tags -3.50%, for_loop_vars -2.90%, strings -2.35%, for_filter_if -2.07%, macros -1.94%, html_autoescape -1.71%, expressions -1.50%, filters -1.40%, dict_ops -1.12%, large_static -0.94% (21,403, already under P2's 21,472 gate), chat_qwen -0.06%, chat_llama -0.19%, inheritance -0.32% (all three P2 gates back at or under base), for_range +0.16%, rest within ±0.6%. Load: within ±0.9% (expressions +0.84%, filters -0.84%).Checks. Full test suite, parity corpus (incl. wide) and fuzz regressions; ASan+UBSan (clang-18) clean; 205 templates rendered byte-identically to the base;
scripts/preflight.sh --perfall PASS.Agent roles. Main session implemented; verifier 1 round (ready, no blocking findings). Red CI pushes: none yet.
🤖 Generated with Claude Code
https://claude.ai/code/session_015qGBQQVdqpanbWPSsaMQrL
Generated by Claude Code