-
-
Notifications
You must be signed in to change notification settings - Fork 161
perf(runtime): resolve #8434 string-builder round trips — reconciling #8568 and #8571 #8581
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4fd8d4c
perf(runtime): resolve string builder round trips
0c672b8
docs(changelog): record string builder audit
8f59670
perf: write array join results directly
a29b5f5
chore: document array join direct writes
80fe0f5
fix(runtime): join integration fixes for the direct-write path
abd8c73
chore: record the payload-access debt this branch removes
c35ca7d
docs: add the changelog fragment for this PR
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| **Land both #8434 string-builder wins — #8571's exact-allocation `String.prototype.repeat` and buffered-path WTF-8 finalization, plus #8568's exact-size direct-write `Array.prototype.join` — with two integration fixes neither PR had.** The PRs had reported opposite verdicts on "direct-write join" (1.38x faster vs 6.83x slower) because they measured different algorithms under one label: #8571's rejected candidate paid a per-element handle scope, a `js_jsvalue_to_string` coercion, and a barriered GC scratch-array store for every element, while #8568's computes the exact output size over the dense payload and allocates once. Re-measured interleaved on one host: joins of short strings retire 25.7% fewer instructions (0.68x wall), `repeat` retires 74.3% fewer (0.27x wall), and the rebuilt rejected candidate reproduces at 13.5x — both authors measured honestly. | ||
|
|
||
| Fix 1 (#8568 correctness): the exact-size join assumed `byte_len == utf16_len` for SSO elements, but SSO length counts bytes and `JSON.parse` emits non-ASCII (and WTF-8 lone-surrogate) SSO payloads — the result header recorded a wrong `utf16_len` and could miss lone-surrogate flags. Such elements now take the canonicalizing builder path with their true UTF-16 length (metadata corruption only; `utf16_len <= byte_len` kept the byte-exact allocation safe). Fix 2 (#8568 performance): numeric elements paid a per-element handle scope plus GC string allocation in the builder — 2.7x main's retired instructions on a numbers-only sweep that #8568's strings-only fixture could not see. Number formatting runs no user code, so it needs no rooting: integer-likes format via stack `itoa`, the rest via the shared `js_format_f64` — numbers-join now retires 32.9% fewer instructions than main (0.59x wall), and `[1e21].join()` now matches `String(1e21)`/Node (`"1e+21"`, previously the 22-digit decimal). Verified byte-exact against Node 26.5.1 under `PERRY_GC_SCHEDULE_RATE=1` + `PERRY_GC_FORCE_EVACUATE=1` + `PERRY_GC_VERIFY_EVACUATION=1` + from-space quarantine (300/700/10205 forced collections across the three fixtures), with the 20-row sweep corpus byte-exact and instruction-flat. | ||
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Replace the development narrative with a release-note entry.
These lines describe rejected candidates, benchmark disputes, authors, and test runs. This content will read as PR history when changelog fragments are assembled. State the shipped string-builder improvements and the two behavior fixes in one concise release-note entry.
Based on learnings: changelog fragments must describe final shipped behavior as one coherent release-note entry.
🤖 Prompt for AI Agents
Source: Learnings