perf(array): add dense fast path for Array.prototype.splice#5328
Open
tkshsbcue wants to merge 1 commit intoboa-dev:mainfrom
Open
perf(array): add dense fast path for Array.prototype.splice#5328tkshsbcue wants to merge 1 commit intoboa-dev:mainfrom
tkshsbcue wants to merge 1 commit intoboa-dev:mainfrom
Conversation
Partially addresses boa-dev#3407. Operate directly on the underlying ThinVec storage when the array is dense, using ThinVec::splice for removal and replacement in a single pass instead of per-element Get/Set/DeletePropertyOrThrow. Guarded by itemCount <= actualDeleteCount to avoid creating new indices where prototype chain setters could fire, and by a shape check to ensure ArraySpeciesCreate would return a plain Array.
Test262 conformance changes
Tested main commit: |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5328 +/- ##
===========================================
+ Coverage 47.24% 59.79% +12.55%
===========================================
Files 476 590 +114
Lines 46892 63734 +16842
===========================================
+ Hits 22154 38111 +15957
- Misses 24738 25623 +885 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Related to #3407.
Right now
spliceon a dense array still goes through the full generic path — individualGet/Set/DeletePropertyOrThrowper element. Same approach as the existingshiftfast path, this skips all of that and operates on theThinVecdirectly viaThinVec::splice.Handles
DenseI32,DenseF64, andDenseElement. If replacement items don't match the storage type (e.g. string into an i32 array), converts toDenseElementfirst.The fast path only kicks in when:
@@species)itemCount <= actualDeleteCountso no new indices are created beyondlen - 1, avoiding the prototype-chain-setter issue from Optimize array unshift #5076len <= vec.len()(storage matches length)Falls through to the generic path otherwise.
~25% faster on a benchmark doing repeated splices on 500-element dense arrays.