-
-
Notifications
You must be signed in to change notification settings - Fork 407
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 by Bors] - Direct array element access on ByValue
instructions
#2827
Conversation
Test262 conformance changes
|
Codecov Report
@@ Coverage Diff @@
## main #2827 +/- ##
==========================================
+ Coverage 50.92% 50.97% +0.04%
==========================================
Files 419 419
Lines 41780 41837 +57
==========================================
+ Hits 21278 21326 +48
- Misses 20502 20511 +9
... and 1 file with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
74e2830
to
64c6d3a
Compare
Benchmark for b07dddbClick to view benchmark
|
Benchmark for 767f9b5Click to view benchmark
|
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.
Good optimization!!
Benchmark for d708c8cClick to view benchmark
|
Benchmark for acc2314Click to view benchmark
|
To me this looks like it should be faster, but the "Array creation" benchmark seems to be slower in the ci. I checked it locally and also got a pretty consistent +12% on that one. Do you know why that may be @HalidOdat? |
😕 Yes, It's weird since the first benchmark had a EDIT: The problem is that this optimizes for access and set of pre-existing indexed properties, not creating new ones like in the benchmark: (function () {
let testArr = [];
for (let a = 0; a <= 500; a++) {
testArr[a] = "p" + a;
}
return testArr;
})(); Will work on adding a fast path for this :) |
b879fc1
to
8a82406
Compare
Benchmark for 5305637Click to view benchmark
|
8a82406
to
75af983
Compare
Benchmark for cef443fClick to view benchmark
|
Will fix the bug then mark this as ready for review :) |
75af983
to
c8b62c2
Compare
Benchmark for 5aa8053Click to view benchmark
|
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.
Looks very good now
bors r+ |
Most of the time that we have a `ByValue` ( `[ value ]` syntax ) it is for arrays and the value is usually an index. This PR adds a fast path to the instructions (without calling `.borrow()` on the object to check if its an array) For example, this code: ```js let a = [1, 2, 3] for (let i = 0 ; i < 10000000; ++i) { a[i % 3] += a[ (i + 1) % 3 ] } ``` Using `hyperfine`, it ran `1.38` times faster on this PR. ```bash Benchmark 1: ./boa_main test.js Time (mean ± σ): 16.504 s ± 0.192 s [User: 16.440 s, System: 0.020 s] Range (min … max): 16.328 s … 16.938 s 10 runs Benchmark 2: ./boa_direct_array_access test.js Time (mean ± σ): 11.982 s ± 0.038 s [User: 11.939 s, System: 0.013 s] Range (min … max): 11.914 s … 12.035 s 10 runs Summary './boa_direct_array_access test.js' ran 1.38 ± 0.02 times faster than './boa_main test.js' ```
Pull request successfully merged into main. Build succeeded: |
ByValue
instructionsByValue
instructions
Most of the time that we have a
ByValue
([ value ]
syntax ) it is for arrays and the value is usually an index. This PR adds a fast path to the instructions (without calling.borrow()
on the object to check if its an array)For example, this code:
Using
hyperfine
, it ran1.38
times faster on this PR.