-
-
Notifications
You must be signed in to change notification settings - Fork 34.1k
buffer: improve Buffer.equals performance
#50621
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
Conversation
lib/buffer.js
Outdated
| 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 |
Improve performance of areSimilarFloatArrays by using primordial. Refs: nodejs#50621
improve
Buffer.equalsperformance:As mentioned in #50620 , the performance regression of
Buffer.byteLengthmight be dueto
ArrayBufferView.byteLength, reduce the property access ofBuffer.byteLengthhelps to reduce regression for
Buffer.equalsInspired by the comment from @aduh95, using
TypedArrayPrototypeGetByteLengthalso improves performance.
Refs: #50620