Repository navigation
runtime: literal-aware concat, inline operand checks, pointer push gate (string-build -21%) - #13450
Merged
Merged
Conversation
…te (string-build -21%) A: ToPrimitive and Symbol checks on + operands run behind one inline test of the live bits (plain number, heap string, inline string skip), and a literal or provably non-pointer operand carries none. B: js_string_concat_parts takes literal operands as rodata address + lengths; two-digit integer formatter written straight into the result; js_string_concat_lit_value_box for a literal prefix + number, consulting the concat memo exactly where the header-flag test admits it today. C: the pointer-push gate admits a heap string: one header test, refcount read, demote only for an unshared string; write barrier unchanged.
|
Caution Review failedThe pull request is closed. Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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
String slice 3 for
30-string-build/24-map-set: three generic operation fixes on the"lit" + n + "lit"build and the pointer push.+operand sit behind one inline test of the value's bits (plain number, heap string and inline string are primitive and never a Symbol). A literal, a proven runtime string or a value that is non-pointer by construction carries no check at all. Evaluation order is unchanged (head pair converted, then the Symbol checks, then each later part).js_string_concat_parts: a literal operand is{address of its text in the program image, byte_len | utf16_len << 32}(the text is the image-resident string object the binary already carries, nothing new is emitted); value operands are{bits, -1}. Exact-u32numbers are formatted straight into the result (digit count sizes the allocation, a two-digit-at-a-time formatter writes at the copy position), small pieces copy without libc memcpy, surrogate canonicalization runs only when a piece carries a lone surrogate. Same single collection point asjs_string_concat_chain(no-collect allocation, else root the heap parts)."lit" + numberusesjs_string_concat_lit_value_box, which returns whatjs_string_concat_value_boxreturns and consults the concat memo exactly where today's header-flag admission does (image-resident literals fail that test today, so executables never consult it; library outputs, whose literals are created at run time, still do; codegen passes that fact inmetabit 63).POINTER_TAG; it now also admits a heap string. One header test (SIDE|ALL_POINTERS, raw-f64 and element-shape bits clear) plus one refcount read skip the layout note, the numeric note and the demote (the demote still runs for an unshared string). The write barrier is unchanged.Also:
scripts/gc_root_dominance_check.pylists the two new collecting entries;runtime_abi.tsvregenerated; a pre-existing duplicatebyte_endfield instmt/indexed_owner_loop_tests.rs(main'scargo test -p perry-codegen --libdid not compile) is fixed.Result (qb9, x86-64-v3, KEEP_SYMBOLS, merged with origin/main d38e538)
n5 instructions (medians): 30: -21.5%, 24: -12.1%, 31: -0.4%. Node parity 22/22. GC_LOG schedule and stdout byte-identical to main on 30, 24 and 31 (minus pause time); n5 max RSS 30: ~239.1 MiB both arms, 24: ~28.2 MiB both.
.text+273 bytes on 30, +2.9 KB on 24 (size).Per-op (30, 4M calls):
js_string_concat_chain535 Ir/call + ToPrimitive 65 + Symbol 24 = 624 ->js_string_concat_parts314 Ir/call (digits inlined). The design predicted 125; the floor (-21.3%) is what landed. The remaining cost is the allocation fast path (~70 Ir inline), the per-part classify loop, and the digit pairs.Tests
lit_value_boxvsvalue_boxincl. memo eligible/ineligible, exhaustive digit formatter 0..10^7 + 200k random u32), JSON 171.cat.*arms; admitted push arm has no note calls, refcount-gated demote, slow arm identical; the admission branch must conjoin the header proof), integration 23.test_gap_jst5_concat_parts(Symbol operand throws and in which order, valueOf/toString/Symbol.toPrimitive across 3+ parts, -0/NaN/Infinity/large/negative ints, surrogate pairs and lone surrogates across pieces, empty operands, 15..3M byte results) andtest_gap_jst5_push_gate(holey, shrunk/grown, popped/sorted/spliced, frozen/sealed/non-extensible, non-writable length, prototype setter, subclass, Proxy, unique accumulator pushed then appended, GC pressure between pushes). A string/concat/template/sso/surrogate/primitive gap subset (86 files): 80 pass, the same 6 fail on main and head (message-wording differences, not a regression).the_admission_branch_is_conditioned_on_the_header_proof.cargo xwin build -p perry-runtime-static+ sidecars onperry_runtime.libpass.Startup (exact callgrind Ir, n3 per arm, deterministic, ASLR off, symmetric control)
Both arms: x86-64-v3, KEEP_SYMBOLS, same paths/env, Node stdout parity. Raw counts, then the accepted symmetric address-independent-key control (the JMS landing-009 measurement-only patch applied identically to main and head: constant hashes for canonical_keys by_addr/edges, shapes indices/families/by_facts, path registry, perex_cache; seed/nonce/maps normalization of the JMS fixtures; the fn_metadata part is not needed since main no longer keys names by address). Controlled head <= main on every witness.
The one raw positive (commander --help +1,509) is the address-keyed layout artifact in canonical_keys/hashbrown probes (call counts of every changed function equal; executed concat work is lower); under the control it is -633. The product fix (stable identity for canonical-key/shape tables) is a separate lane.