-
-
Notifications
You must be signed in to change notification settings - Fork 161
docs(changelog): record the packed-loop throw fast path shipped in v0.5.1519 #9255
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| ### Performance | ||
|
|
||
| - **A `throw` inside a counted loop no longer forces the loop off its fast | ||
| path.** `for (let i = 0; i < arr.length; i++) { if (bad) throw new Error(…); | ||
| sum += arr[i]; }` is the ordinary shape of a validating loop, and the throw | ||
| — even one that never fires — used to cost the whole packed-array | ||
| specialization. Measured on a quiet machine over a 512-element `number[]`: | ||
|
|
||
| | loop body | before | after | node | | ||
| |---|---|---|---| | ||
| | `throw new Error("bad")` | 7.99 ns/op | **0.95** | 7.70 | | ||
| | `throw new Error("bad " + i)` | 7.99 | **0.95** | 7.75 | | ||
| | `throw new Error()` | 7.99 | **0.95** | 7.75 | | ||
| | `throw "bad " + i` | 7.99 | **0.95** | 7.74 | | ||
| | `throw <pre-built value>` | 7.99 | **0.95** | 1.11 | | ||
|
|
||
| An 8.1× improvement on the constructing forms, which are the common ones. | ||
| Perry now runs every shape in that benchmark faster than node, including | ||
| the loop with no `throw` in it at all (0.95 against 1.11). | ||
|
Comment on lines
+15
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Add the no- Line 19 reports a no- 🤖 Prompt for AI Agents |
||
|
|
||
| The specialization keeps a loop's accumulators in registers, so admitting a | ||
| `throw` required writing them back on the unwind edge — an exception leaves | ||
| through a landing pad rather than the loop's exit block, and a `catch` can | ||
| read anything the loop wrote. Operands are admitted only when evaluating | ||
| them cannot itself unwind: throwing a value coerces nothing, but building an | ||
| `Error` message or concatenating a string can dispatch to a user `toString` | ||
| or `valueOf`, and those can throw before the writeback runs. | ||
|
|
||
| These landed in **v0.5.1519** (#9235, with #9230 and #9215). This fragment | ||
| was written after that release was cut, so it appears here rather than in | ||
| the notes for the release that carries the change. | ||
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.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: PerryTS/perry
Length of output: 13664
🏁 Script executed:
Repository: PerryTS/perry
Length of output: 50369
Reconcile the reported improvement with the table.
The displayed values
7.99 ns/opand0.95 ns/opcalculate to approximately8.4×, not8.1×. Update the sentence or include the unrounded measurements and calculation for8.1×.🤖 Prompt for AI Agents