buffer: improve Buffer.equals performance#50621
Merged
nodejs-github-bot merged 1 commit intonodejs:mainfrom Nov 10, 2023
Merged
buffer: improve Buffer.equals performance#50621nodejs-github-bot merged 1 commit intonodejs:mainfrom
Buffer.equals performance#50621nodejs-github-bot merged 1 commit intonodejs:mainfrom
Conversation
Collaborator
aduh95 approved these changes Nov 8, 2023
lib/buffer.js Outdated
| return true; | ||
| | ||
| if (this.byteLength !== otherBuffer.byteLength) | ||
| const len = this.byteLength; |
Contributor
There was a problem hiding this comment.
Could you try with TypedArrayPrototypeGetByteLength from primordials? I'd be curious to see if that would improve perf further or not.
Contributor Author
There was a problem hiding this comment.
Good suggestion. I have tried TypedArrayPrototypeGetByteLength. As you can see in the updated benchmark result, it improved a lot.
2aaa6d3 to 16e579f Compare aduh95 reviewed Nov 8, 2023
Contributor
| Benchmark CI: https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/1470/ Results |
16e579f to d61cb9c Compare anonrig approved these changes Nov 8, 2023
20 tasks
debadree25 approved these changes Nov 9, 2023
Collaborator
RaisinTen approved these changes Nov 9, 2023
Collaborator
18 tasks
Collaborator
Collaborator
| Landed in 89c66ae |
27 tasks
18 tasks
This was referenced Nov 13, 2023
Septa2112 added a commit to Septa2112/node that referenced this pull request Dec 4, 2023
Improve performance of areSimilarFloatArrays by using primordial. Refs: nodejs#50621
Merged
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.
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