-
-
Notifications
You must be signed in to change notification settings - Fork 161
fix(string): make codePointAt and slice linear on non-ASCII strings — native tsc 658 s -> 7.8 s (#10656, #10685) #10664
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
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
bc0cb30
fix(string): make codePointAt linear on non-ASCII strings (#10656)
d3952e4
fix(string): resolve slice start offsets through the UTF-16 index (#1…
5293235
perf(array): gate registry probes on the GC header in the indexing pa…
e017534
perf(string): give the UTF-16 index no capacity, so it cannot thrash …
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,5 @@ | ||
| `String.prototype.codePointAt` is no longer O(n) per call on strings containing | ||
| non-ASCII characters. It now uses the same lazy UTF-16 index `charCodeAt` and | ||
| bracket indexing were moved to in #10067, so a sequential scan is linear rather | ||
| than quadratic. A natively compiled `tsc` goes from 658 s to 85 s on a two-line | ||
| input (#10656). | ||
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,5 @@ | ||
| `String.prototype.substring` / `slice` / `substr` no longer walk from byte 0 to | ||
| resolve their start offset on strings containing non-ASCII characters. They now | ||
| use the same lazy UTF-16 index the other accessors use, so slicing at increasing | ||
| offsets — every tokenizer's access pattern — is linear rather than quadratic. A | ||
| natively compiled `tsc` goes from 85 s to 7.8 s (#10685). |
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,6 @@ | ||
| The UTF-16 index no longer lives in a fixed four-slot cache that evicted | ||
| round-robin. Interleaving indexed access across more strings than it held | ||
| rebuilt the index from scratch on every access — 1,224x slower from the fifth | ||
| string onward, as a step function. Entries now live until their string dies and | ||
| are reclaimed by the collector's existing prune hook, so the cliff cannot occur | ||
| at any number of strings (#10688). |
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,5 @@ | ||
| Plain-array element reads and writes no longer probe the buffer and typed-array | ||
| registries. A `GC_TYPE_ARRAY` header can never be either, and the iteration | ||
| helpers already gated on that; the indexing path did not. On a `tsc --noEmit` | ||
| of a two-line file this halves `is_registered_buffer` probes, 79.7M to 39.8M | ||
| (#10694). |
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
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
🔎 Supported by static analysis
🏁 Script executed:
Repository: PerryTS/perry
Length of output: 6998
🏁 Script executed:
Repository: PerryTS/perry
Length of output: 4910
🤖 get_repo_knowledge executed:
get_repo_knowledge PerryTS/perry /tmp/coderabbit-repo-knowledge/perryts-perry-d4a878bc/learnings /tmp/coderabbit-repo-knowledge/perryts-perry-d4a878bc/conventionsLength of output: 14596
Correct the release-note sentence.
This fragment becomes user-facing release-note text, so the sentence must be complete. Add a relative clause after “index”: “the same lazy UTF-16 index that
charCodeAtand bracket indexing use.”🤖 Prompt for AI Agents