-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
buffer: improve Buffer.equals
performance
#50621
Conversation
lib/buffer.js
Outdated
@@ -860,11 +860,11 @@ Buffer.prototype.equals = function equals(otherBuffer) { | |||
|
|||
if (this === otherBuffer) | |||
return true; | |||
|
|||
if (this.byteLength !== otherBuffer.byteLength) | |||
const len = this.byteLength; |
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.
Could you try with TypedArrayPrototypeGetByteLength
from primordials? I'd be curious to see if that would improve perf further or not.
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 suggestion. I have tried TypedArrayPrototypeGetByteLength
. As you can see in the updated benchmark result, it improved a lot.
2aaa6d3
to
16e579f
Compare
Benchmark CI: https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/1470/ Results
|
16e579f
to
d61cb9c
Compare
Landed in 89c66ae |
PR-URL: #50621 Refs: #50620 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Debadree Chatterjee <[email protected]> Reviewed-By: Darshan Sen <[email protected]>
PR-URL: #50621 Refs: #50620 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Debadree Chatterjee <[email protected]> Reviewed-By: Darshan Sen <[email protected]>
Improve performance of areSimilarFloatArrays by using primordial. Refs: nodejs#50621
Improve performance of areSimilarFloatArrays by using primordial. Refs: #50621 PR-URL: #51040 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Vinícius Lourenço Claro Cardoso <[email protected]> Reviewed-By: James M Snell <[email protected]>
PR-URL: #50621 Refs: #50620 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Debadree Chatterjee <[email protected]> Reviewed-By: Darshan Sen <[email protected]>
Improve performance of areSimilarFloatArrays by using primordial. Refs: #50621 PR-URL: #51040 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Vinícius Lourenço Claro Cardoso <[email protected]> Reviewed-By: James M Snell <[email protected]>
Improve performance of areSimilarFloatArrays by using primordial. Refs: #50621 PR-URL: #51040 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Vinícius Lourenço Claro Cardoso <[email protected]> Reviewed-By: James M Snell <[email protected]>
improve
Buffer.equals
performance:As mentioned in #50620 , the performance regression of
Buffer.byteLength
might be dueto
ArrayBufferView.byteLength
, reduce the property access ofBuffer.byteLength
helps to reduce regression for
Buffer.equals
Inspired by the comment from @aduh95, using
TypedArrayPrototypeGetByteLength
also improves performance.
Refs: #50620