Optimizing performance of FromArrayToRef

In vector functions like Vector3.FromArrayToRef and Quaternion.FromArrayToRef, values are assigned to properites like x, y, z, w, which are internally setter functions which sets things like _x and _isDirty, so in FromArrayToRef where all these setters called, the _isDirty is set multiple times, which is possibly optimizable.

It should be possible to directly set internal properites like _x, _y, _z, and _w in FromArrayToRef and set _isDirty to true to be compatible with existing code depending on _isDirty, which should result in better performance.

Playground link for benchmark, using workers to create isolated environment for benchmarking, which may not be accurate:

benckmark results

Firefox 107 win64:

vector3MemoryRead 25.666666666666668 
vector3FromArrayToRef 92.66666666666667
Vector3.FromArrayToRef 90.33333333333333
vector3FromArrayToRefOptimized 69.33333333333333
quaternionMemoryRead 16.666666666666668
quaternionFromArrayToRef 98.33333333333333
Quaternion.FromArrayToRef 100.33333333333333
quaternionFromArrayToRefOptimized 76.33333333333333

图片

Chrome 108 win64:

vector3MemoryRead 19.466666664928198
vector3FromArrayToRef 49.533333333830036
Vector3.FromArrayToRef 56.09999999900659
vector3FromArrayToRefOptimized 44.39999999975165
quaternionMemoryRead 17.899999998509884
quaternionFromArrayToRef 44.83333333209157
Quaternion.FromArrayToRef 52.46666666741172
quaternionFromArrayToRefOptimized 43.966666666169964

图片

Also note that devtools may have side effects on benchmark results.

Referring Babylon.js source:

Vector3.FromArrayToRef:

Vector3#set x:

Quaternion.FromArrayToRef:

Quaternion#set x:

Also note in Matrix.FromArrayToRef, the internal prop result._m is used instead of getter and setter.

I’m not a JS expert. What do you think @Evgeni_Popov @sebavan ?

cc @RaananW, who is more an expert than me at JS/TS!

I think setting the internal properties directly instead of using the setters can be interesting, even if it heavily depends on the browser. For eg, on my computer, with Chrome vector3FromArrayToRef is faster than vector3FromArrayToRefOptimized (same thing for the quaternion):

image

(I multipled the number of iterations by 10 in the PG)

In Firefox, it’s the other way around (which seems more logical):

image

1 Like

This is a great suggestion :slight_smile:

your method can be implemented in js because of, well, the way javascript is defining “private” variables (pre es2022). Setting directly will save the dirty = true part and will probably optimize the entire process.

We will need to make the underscore variables public hidden instead of private, but I don’t see a reason not to do that.

It is a quick change that can be made so I don’t see a reason to delay implementing it. I just want to note that we are talking about an operation that is very fast already. you can see that with the numbers we all paste here - you display the average of a 3 million operations running in parallel, and we are talking about 300ms on average :slight_smile:

TL;dr - great optimization. Using an internal public variable will improve setting the entire object in a single call. just need to remember to set dirty in the right place.

Oh, and a side note - the playground is compiled to es5, so it is using defineProperty instead of actual class getter/setters. some browsers might optimize one way over the other. From a quick test on chrome it seems like they perform roughly the same though.

3 Likes

To correctly make a microbenchmark in browsers seems hard, result affected by many hidden conditions, weird things happen with devtools.

Open the page and wait for complete:
图片

Refresh the same page with devtools open:
图片

Close the devtools and refresh again:
图片

Env: Chrome win64 on another computer

The playground of the modified benchmark:

Also, the same setters are used in many methods, in Vector3 for example, there are functions like Vector3.addInPlaceFromFloats, Vector3.subtractInPlace, Vector3.negateInPlace, Vector3.scaleInPlace, Vector3.applyRotationQuaternionToRef, Vector3.multiplyInPlace, Vector3.copyFromFloats, Vector3.setAll, Vector3.PitchYawRollToMoveBetweenPointsToRef, Vector3.TransformCoordinatesFromFloatsToRef, Vector3.TransformNormalFromFloatsToRef, Vector3.Hermite1stDerivativeToRef, Vector3.LerpToRef could also benefit from optimizations like this.

2 Likes

From past experience, it can be difficult to compare timings of very short duration, especially using an interpreter which can have it’s own ideas about short loop optimizations. See you are doing warm ups, and multiple run averaging.

Using dynamic execution, which most interpreted languages have, eval(), with say 1000 in-lined calls & a before / after timestamp might be a better way to go.


Don’t have a problem with this. It is simple enough to change. The only thing I can call every frame is Vector3.LerpToRef, even multple times. Do not think this is going to “move the needle” though.

1 Like

Benchmarking with jit is complicated, here are results using d8:

d8 --jitless vector3FromArrayToRefOptimizedNoWarmUp.js
>..\d8 --jitless vector3FromArrayToRefOptimizedNoWarmUp.js
Warning: disabling flag --expose_wasm due to conflicting flags
1
2
start bench
11417.422999999995
d8 --jitless vector3FromArrayToRefNoWarmUp.js
>..\d8 --jitless vector3FromArrayToRefNoWarmUp.js
Warning: disabling flag --expose_wasm due to conflicting flags
1
2
start bench
18580.589
d8 --trace-deopt --trace-opt-verbose vector3FromArrayToRefOptimized.js
>..\d8 --trace-deopt --trace-opt-verbose vector3FromArrayToRefOptimized.js
[not yet optimizing d, not enough ticks: 1/3 and ICs changed]
[marking 0x00e000a200fd <JSFunction e.o (sfi = 000000E000788A49)> for optimization to TURBOFAN, ConcurrencyMode::kConcurrent, reason: small function]
[compiling method 0x00e000a200fd <JSFunction e.o (sfi = 000000E000788A49)> (target TURBOFAN), mode: ConcurrencyMode::kConcurrent]
[completed compiling 0x00e000a200fd <JSFunction e.o (sfi = 000000E000788A49)> (target TURBOFAN) - took 0.067, 3.097, 0.286 ms]
[completed optimizing 0x00e000a200fd <JSFunction e.o (sfi = 000000E000788A49)> (target TURBOFAN)]
[not yet optimizing d, not enough ticks: 2/3 and  too large for small function optimization: 103/81]
[not yet optimizing G, not enough ticks: 1/4 and ICs changed]
[resetting ticks for 0x00e000786771 <SharedFunctionInfo G> from 1 due to IC change: Monomorphic]
[not yet optimizing , not enough ticks: 1/4 and ICs changed]
[not yet optimizing , not enough ticks: 2/4 and  too large for small function optimization: 229/81]
[not yet optimizing , not enough ticks: 3/4 and  too large for small function optimization: 229/81]
[marking 0x00e00025a215 <JSFunction (sfi = 000000E000259E55)> for optimization to TURBOFAN, ConcurrencyMode::kConcurrent, reason: hot and stable]
[compiling method 0x00e00025a215 <JSFunction (sfi = 000000E000259E55)> (target TURBOFAN) OSR, mode: ConcurrencyMode::kConcurrent]
[completed compiling 0x00e00025a215 <JSFunction (sfi = 000000E000259E55)> (target TURBOFAN) OSR - took 0.042, 2.844, 0.060 ms]
[completed optimizing 0x00e00025a215 <JSFunction (sfi = 000000E000259E55)> (target TURBOFAN) OSR]
[bailout (kind: deopt-eager, reason: Insufficient type feedback for generic named access): begin. deoptimizing 0x00e00025a215 <JSFunction (sfi = 000000E000259E55)>, 0x7ff900004141 <InstructionStream TURBOFAN>, opt id 1, node id 66, bytecode offset 86, deopt exit 8, FP to SP delta 128, caller SP 0x0000005fea98, pc 0x7ff900004431]
[resetting ticks for 0x00e000259e55 <SharedFunctionInfo> from 5 due to IC change: Monomorphic]
1
[not yet optimizing benchmarkVector3, not enough ticks: 1/4 and ICs changed]
[marking 0x00e00025a295 <JSFunction vector3FromArrayToRefOptimized (sfi = 000000E000259EED)> for optimization to TURBOFAN, ConcurrencyMode::kConcurrent, reason: small function]
[compiling method 0x00e00025a295 <JSFunction vector3FromArrayToRefOptimized (sfi = 000000E000259EED)> (target TURBOFAN), mode: ConcurrencyMode::kConcurrent]
[completed compiling 0x00e00025a295 <JSFunction vector3FromArrayToRefOptimized (sfi = 000000E000259EED)> (target TURBOFAN) - took 0.040, 1.982, 0.057 ms]
[completed optimizing 0x00e00025a295 <JSFunction vector3FromArrayToRefOptimized (sfi = 000000E000259EED)> (target TURBOFAN)]
[not yet optimizing benchmarkVector3, not enough ticks: 2/4 and  too large for small function optimization: 188/81]
[not yet optimizing benchmarkVector3, not enough ticks: 3/4 and  too large for small function optimization: 188/81]
[marking 0x00e00025a2c9 <JSFunction benchmarkVector3 (sfi = 000000E000259F25)> for optimization to TURBOFAN, ConcurrencyMode::kConcurrent, reason: hot and stable]
[compiling method 0x00e00025a2c9 <JSFunction benchmarkVector3 (sfi = 000000E000259F25)> (target TURBOFAN) OSR, mode: ConcurrencyMode::kConcurrent]
[not marking function benchmarkVector3 (BASELINE) for optimization: already queued]
[not marking function benchmarkVector3 (BASELINE) for optimization: already queued]
[completed compiling 0x00e00025a2c9 <JSFunction benchmarkVector3 (sfi = 000000E000259F25)> (target TURBOFAN) OSR - took 0.058, 5.121, 0.089 ms]
[completed optimizing 0x00e00025a2c9 <JSFunction benchmarkVector3 (sfi = 000000E000259F25)> (target TURBOFAN) OSR]
[bailout (kind: deopt-eager, reason: Insufficient type feedback for unary operation): begin. deoptimizing 0x00e00025a2c9 <JSFunction benchmarkVector3 (sfi = 000000E000259F25)>, 0x7ff900004781 <InstructionStream TURBOFAN>, opt id 3, node id 114, bytecode offset 70, deopt exit 22, FP to SP delta 232, caller SP 0x0000005fea30, pc 0x7ff900004e3f]
[compiling method 0x00e00025a2c9 <JSFunction benchmarkVector3 (sfi = 000000E000259F25)> (target TURBOFAN) OSR, mode: ConcurrencyMode::kConcurrent]
[not marking function benchmarkVector3 (BASELINE) for optimization: already queued]
[not marking function benchmarkVector3 (BASELINE) for optimization: already queued]
[not marking function benchmarkVector3 (BASELINE) for optimization: already queued]
[not marking function benchmarkVector3 (BASELINE) for optimization: already queued]
[not marking function benchmarkVector3 (BASELINE) for optimization: already queued]
[completed compiling 0x00e00025a2c9 <JSFunction benchmarkVector3 (sfi = 000000E000259F25)> (target TURBOFAN) OSR - took 0.026, 11.756, 0.137 ms]
[completed optimizing 0x00e00025a2c9 <JSFunction benchmarkVector3 (sfi = 000000E000259F25)> (target TURBOFAN) OSR]
[bailout (kind: deopt-eager, reason: Insufficient type feedback for generic named access): begin. deoptimizing 0x00e00025a2c9 <JSFunction benchmarkVector3 (sfi = 000000E000259F25)>, 0x7ff900004ec1 <InstructionStream TURBOFAN>, opt id 4, node id 278, bytecode offset 81, deopt exit 44, FP to SP delta 232, caller SP 0x0000005fea30, pc 0x7ff900005c24]
[resetting ticks for 0x00e000259f25 <SharedFunctionInfo benchmarkVector3> from 8 due to IC change: Monomorphic]
[compiling method 0x00e00025a2c9 <JSFunction benchmarkVector3 (sfi = 000000E000259F25)> (target TURBOFAN) OSR, mode: ConcurrencyMode::kConcurrent]
[not marking function benchmarkVector3 (BASELINE) for optimization: already queued]
[not marking function benchmarkVector3 (BASELINE) for optimization: already queued]
[completed compiling 0x00e00025a2c9 <JSFunction benchmarkVector3 (sfi = 000000E000259F25)> (target TURBOFAN) OSR - took 0.027, 7.836, 0.090 ms]
[completed optimizing 0x00e00025a2c9 <JSFunction benchmarkVector3 (sfi = 000000E000259F25)> (target TURBOFAN) OSR]
[bailout (kind: deopt-eager, reason: Insufficient type feedback for unary operation): begin. deoptimizing 0x00e00025a2c9 <JSFunction benchmarkVector3 (sfi = 000000E000259F25)>, 0x7ff900005d01 <InstructionStream TURBOFAN>, opt id 5, node id 115, bytecode offset 161, deopt exit 22, FP to SP delta 232, caller SP 0x0000005fea30, pc 0x7ff9000063bf]
[compiling method 0x00e00025a2c9 <JSFunction benchmarkVector3 (sfi = 000000E000259F25)> (target TURBOFAN) OSR, mode: ConcurrencyMode::kConcurrent]
[not marking function benchmarkVector3 (BASELINE) for optimization: already queued]
[not marking function benchmarkVector3 (BASELINE) for optimization: already queued]
[not marking function benchmarkVector3 (BASELINE) for optimization: already queued]
[not marking function benchmarkVector3 (BASELINE) for optimization: already queued]
[not marking function benchmarkVector3 (BASELINE) for optimization: already queued]
[not marking function benchmarkVector3 (BASELINE) for optimization: already queued]
[completed compiling 0x00e00025a2c9 <JSFunction benchmarkVector3 (sfi = 000000E000259F25)> (target TURBOFAN) OSR - took 0.027, 10.782, 0.158 ms]
[completed optimizing 0x00e00025a2c9 <JSFunction benchmarkVector3 (sfi = 000000E000259F25)> (target TURBOFAN) OSR]
[bailout (kind: deopt-eager, reason: Insufficient type feedback for call): begin. deoptimizing 0x00e00025a2c9 <JSFunction benchmarkVector3 (sfi = 000000E000259F25)>, 0x7ff900006441 <InstructionStream TURBOFAN>, opt id 6, node id 285, bytecode offset 177, deopt exit 44, FP to SP delta 232, caller SP 0x0000005fea30, pc 0x7ff9000071a5]
2
[compiling method 0x00e00025a2c9 <JSFunction benchmarkVector3 (sfi = 000000E000259F25)> (target TURBOFAN), mode: ConcurrencyMode::kConcurrent]
[completed compiling 0x00e00025a2c9 <JSFunction benchmarkVector3 (sfi = 000000E000259F25)> (target TURBOFAN) - took 0.033, 14.043, 0.155 ms]
[completed optimizing 0x00e00025a2c9 <JSFunction benchmarkVector3 (sfi = 000000E000259F25)> (target TURBOFAN)]
[bailout (kind: deopt-eager, reason: Insufficient type feedback for generic named access): begin. deoptimizing 0x00e00025a2c9 <JSFunction benchmarkVector3 (sfi = 000000E000259F25)>, 0x7ff900004ec1 <InstructionStream TURBOFAN>, opt id 4, node id 278, bytecode offset 81, deopt exit 44, FP to SP delta 232, caller SP 0x0000005fea30, pc 0x7ff900005c24]
[bailout (kind: deopt-eager, reason: Insufficient type feedback for call): begin. deoptimizing 0x00e00025a2c9 <JSFunction benchmarkVector3 (sfi = 000000E000259F25)>, 0x7ff900006441 <InstructionStream TURBOFAN>, opt id 6, node id 285, bytecode offset 177, deopt exit 44, FP to SP delta 232, caller SP 0x0000005fea30, pc 0x7ff9000071a5]
start bench
39.6880000000001
d8 --trace-deopt --trace-opt-verbose vector3FromArrayToRef.js
>..\d8 --trace-deopt --trace-opt-verbose vector3FromArrayToRef.js
[not yet optimizing d, not enough ticks: 1/3 and ICs changed]
[marking 0x006100a200fd <JSFunction e.o (sfi = 0000006100788A49)> for optimization to TURBOFAN, ConcurrencyMode::kConcurrent, reason: small function]
[compiling method 0x006100a200fd <JSFunction e.o (sfi = 0000006100788A49)> (target TURBOFAN), mode: ConcurrencyMode::kConcurrent]
[completed compiling 0x006100a200fd <JSFunction e.o (sfi = 0000006100788A49)> (target TURBOFAN) - took 0.075, 2.282, 0.299 ms]
[completed optimizing 0x006100a200fd <JSFunction e.o (sfi = 0000006100788A49)> (target TURBOFAN)]
[not yet optimizing d, not enough ticks: 2/3 and  too large for small function optimization: 103/81]
[not yet optimizing G, not enough ticks: 1/4 and ICs changed]
[resetting ticks for 0x006100786771 <SharedFunctionInfo G> from 1 due to IC change: Monomorphic]
[not yet optimizing , not enough ticks: 1/4 and ICs changed]
[not yet optimizing , not enough ticks: 2/4 and  too large for small function optimization: 229/81]
[not yet optimizing , not enough ticks: 3/4 and  too large for small function optimization: 229/81]
[marking 0x00610025a211 <JSFunction (sfi = 0000006100259E4D)> for optimization to TURBOFAN, ConcurrencyMode::kConcurrent, reason: hot and stable]
[compiling method 0x00610025a211 <JSFunction (sfi = 0000006100259E4D)> (target TURBOFAN) OSR, mode: ConcurrencyMode::kConcurrent]
[completed compiling 0x00610025a211 <JSFunction (sfi = 0000006100259E4D)> (target TURBOFAN) OSR - took 0.031, 3.083, 0.055 ms]
[completed optimizing 0x00610025a211 <JSFunction (sfi = 0000006100259E4D)> (target TURBOFAN) OSR]
[bailout (kind: deopt-eager, reason: Insufficient type feedback for generic named access): begin. deoptimizing 0x00610025a211 <JSFunction (sfi = 0000006100259E4D)>, 0x7ff900004141 <InstructionStream TURBOFAN>, opt id 1, node id 66, bytecode offset 86, deopt exit 8, FP to SP delta 128, caller SP 0x0000005fea98, pc 0x7ff900004431]
[resetting ticks for 0x006100259e4d <SharedFunctionInfo> from 5 due to IC change: Monomorphic]
1
[not yet optimizing benchmarkVector3, not enough ticks: 1/4 and ICs changed]
[marking 0x00610025a291 <JSFunction vector3FromArrayToRef (sfi = 0000006100259EE5)> for optimization to TURBOFAN, ConcurrencyMode::kConcurrent, reason: small function]
[compiling method 0x00610025a291 <JSFunction vector3FromArrayToRef (sfi = 0000006100259EE5)> (target TURBOFAN), mode: ConcurrencyMode::kConcurrent]
[completed compiling 0x00610025a291 <JSFunction vector3FromArrayToRef (sfi = 0000006100259EE5)> (target TURBOFAN) - took 0.043, 2.905, 0.080 ms]
[completed optimizing 0x00610025a291 <JSFunction vector3FromArrayToRef (sfi = 0000006100259EE5)> (target TURBOFAN)]
[not yet optimizing benchmarkVector3, not enough ticks: 2/4 and  too large for small function optimization: 188/81]
[not yet optimizing benchmarkVector3, not enough ticks: 3/4 and  too large for small function optimization: 188/81]
[marking 0x00610025a2c5 <JSFunction benchmarkVector3 (sfi = 0000006100259F1D)> for optimization to TURBOFAN, ConcurrencyMode::kConcurrent, reason: hot and stable]
[compiling method 0x00610025a2c5 <JSFunction benchmarkVector3 (sfi = 0000006100259F1D)> (target TURBOFAN) OSR, mode: ConcurrencyMode::kConcurrent]
[not marking function benchmarkVector3 (BASELINE) for optimization: already queued]
[not marking function benchmarkVector3 (BASELINE) for optimization: already queued]
[not marking function benchmarkVector3 (BASELINE) for optimization: already queued]
[completed compiling 0x00610025a2c5 <JSFunction benchmarkVector3 (sfi = 0000006100259F1D)> (target TURBOFAN) OSR - took 0.028, 6.685, 0.104 ms]
[completed optimizing 0x00610025a2c5 <JSFunction benchmarkVector3 (sfi = 0000006100259F1D)> (target TURBOFAN) OSR]
[bailout (kind: deopt-eager, reason: Insufficient type feedback for unary operation): begin. deoptimizing 0x00610025a2c5 <JSFunction benchmarkVector3 (sfi = 0000006100259F1D)>, 0x7ff900004781 <InstructionStream TURBOFAN>, opt id 3, node id 114, bytecode offset 70, deopt exit 22, FP to SP delta 232, caller SP 0x0000005fea30, pc 0x7ff900004e38]
[compiling method 0x00610025a2c5 <JSFunction benchmarkVector3 (sfi = 0000006100259F1D)> (target TURBOFAN) OSR, mode: ConcurrencyMode::kConcurrent]
[not marking function benchmarkVector3 (BASELINE) for optimization: already queued]
[not marking function benchmarkVector3 (BASELINE) for optimization: already queued]
[not marking function benchmarkVector3 (BASELINE) for optimization: already queued]
[not marking function benchmarkVector3 (BASELINE) for optimization: already queued]
[not marking function benchmarkVector3 (BASELINE) for optimization: already queued]
[not marking function benchmarkVector3 (BASELINE) for optimization: already queued]
[not marking function benchmarkVector3 (BASELINE) for optimization: already queued]
[completed compiling 0x00610025a2c5 <JSFunction benchmarkVector3 (sfi = 0000006100259F1D)> (target TURBOFAN) OSR - took 0.031, 12.668, 0.134 ms]
[completed optimizing 0x00610025a2c5 <JSFunction benchmarkVector3 (sfi = 0000006100259F1D)> (target TURBOFAN) OSR]
[bailout (kind: deopt-eager, reason: Insufficient type feedback for generic named access): begin. deoptimizing 0x00610025a2c5 <JSFunction benchmarkVector3 (sfi = 0000006100259F1D)>, 0x7ff900004ec1 <InstructionStream TURBOFAN>, opt id 4, node id 278, bytecode offset 81, deopt exit 44, FP to SP delta 232, caller SP 0x0000005fea30, pc 0x7ff900005c25]
[resetting ticks for 0x006100259f1d <SharedFunctionInfo benchmarkVector3> from 10 due to IC change: Monomorphic]
[compiling method 0x00610025a2c5 <JSFunction benchmarkVector3 (sfi = 0000006100259F1D)> (target TURBOFAN) OSR, mode: ConcurrencyMode::kConcurrent]
[not marking function benchmarkVector3 (BASELINE) for optimization: already queued]
[not marking function benchmarkVector3 (BASELINE) for optimization: already queued]
[not marking function benchmarkVector3 (BASELINE) for optimization: already queued]
[completed compiling 0x00610025a2c5 <JSFunction benchmarkVector3 (sfi = 0000006100259F1D)> (target TURBOFAN) OSR - took 0.026, 5.795, 0.093 ms]
[completed optimizing 0x00610025a2c5 <JSFunction benchmarkVector3 (sfi = 0000006100259F1D)> (target TURBOFAN) OSR]
[bailout (kind: deopt-eager, reason: Insufficient type feedback for unary operation): begin. deoptimizing 0x00610025a2c5 <JSFunction benchmarkVector3 (sfi = 0000006100259F1D)>, 0x7ff900005d01 <InstructionStream TURBOFAN>, opt id 5, node id 115, bytecode offset 161, deopt exit 22, FP to SP delta 232, caller SP 0x0000005fea30, pc 0x7ff9000063b8]
[compiling method 0x00610025a2c5 <JSFunction benchmarkVector3 (sfi = 0000006100259F1D)> (target TURBOFAN) OSR, mode: ConcurrencyMode::kConcurrent]
[not marking function benchmarkVector3 (BASELINE) for optimization: already queued]
[not marking function benchmarkVector3 (BASELINE) for optimization: already queued]
[not marking function benchmarkVector3 (BASELINE) for optimization: already queued]
[not marking function benchmarkVector3 (BASELINE) for optimization: already queued]
[not marking function benchmarkVector3 (BASELINE) for optimization: already queued]
[not marking function benchmarkVector3 (BASELINE) for optimization: already queued]
[not marking function benchmarkVector3 (BASELINE) for optimization: already queued]
[completed compiling 0x00610025a2c5 <JSFunction benchmarkVector3 (sfi = 0000006100259F1D)> (target TURBOFAN) OSR - took 0.028, 11.859, 0.138 ms]
[completed optimizing 0x00610025a2c5 <JSFunction benchmarkVector3 (sfi = 0000006100259F1D)> (target TURBOFAN) OSR]
[bailout (kind: deopt-eager, reason: Insufficient type feedback for call): begin. deoptimizing 0x00610025a2c5 <JSFunction benchmarkVector3 (sfi = 0000006100259F1D)>, 0x7ff900006441 <InstructionStream TURBOFAN>, opt id 6, node id 285, bytecode offset 177, deopt exit 44, FP to SP delta 232, caller SP 0x0000005fea30, pc 0x7ff9000071ab]
2
[compiling method 0x00610025a2c5 <JSFunction benchmarkVector3 (sfi = 0000006100259F1D)> (target TURBOFAN), mode: ConcurrencyMode::kConcurrent]
[completed compiling 0x00610025a2c5 <JSFunction benchmarkVector3 (sfi = 0000006100259F1D)> (target TURBOFAN) - took 0.028, 9.595, 0.134 ms]
[completed optimizing 0x00610025a2c5 <JSFunction benchmarkVector3 (sfi = 0000006100259F1D)> (target TURBOFAN)]
[bailout (kind: deopt-eager, reason: Insufficient type feedback for generic named access): begin. deoptimizing 0x00610025a2c5 <JSFunction benchmarkVector3 (sfi = 0000006100259F1D)>, 0x7ff900004ec1 <InstructionStream TURBOFAN>, opt id 4, node id 278, bytecode offset 81, deopt exit 44, FP to SP delta 232, caller SP 0x0000005fea30, pc 0x7ff900005c25]
[bailout (kind: deopt-eager, reason: Insufficient type feedback for call): begin. deoptimizing 0x00610025a2c5 <JSFunction benchmarkVector3 (sfi = 0000006100259F1D)>, 0x7ff900006441 <InstructionStream TURBOFAN>, opt id 6, node id 285, bytecode offset 177, deopt exit 44, FP to SP delta 232, caller SP 0x0000005fea30, pc 0x7ff9000071ab]
start bench
50.815000000000055

Code for this:
js.zip (892.5 KB)

In jitless mode, warmup is disabled since it would take a long time.

The version of v8: v8-win64-dbg-11.1.237.zip

Little bit off topic, but where did u get that windows d8 build? id like to have a place i can consistently get an up to date copy for windows

Also, if i remember correctly, the math classes added the private values behind getters in v4? so maybe there is some usable stuff in v3 to compare against. This also may be of interest, its a small bench for threejs math, gl-matrix, and a partially complete simd wasm version of gl-matrix. GitHub - deepkolos/simd-wasm-matrix: 一个有 simd 加速和自动 GC 的 matrix 数学库 . could be interesting to see how babylon compares.

1 Like

PR here:

3 Likes