-
Notifications
You must be signed in to change notification settings - Fork 254
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
perf(NODE-5910): optimize small byte copies #651
Conversation
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.
Nice improvement on the 3 types.
@nbbeeken I love seeing these general performance improvements 🎉 Good work. I don't have access to the linked Google doc. Could you update the PR with the details from the benchmarks? I'm also curious if we've compared performance in Node 18, 20, and 21. |
Hey @SeanReece thank you! I appreciate the community taking notice! 😄 So first about Node.js versions, I only manually tested on Node.js And sure! I'll take a note to post something similar to what I did for this improvement soon. Since this is already merged, I'll try comparing with and without just this change, so the other improvements we've made will still be included in the versions I'll be comparing. |
Microbenchmarks only get us so far and there's variance in the results to take into account but I think the message is clear on the
|
Description
What is changing?
Is there new documentation needed for these changes?
No.
What is the motivation for this change?
TypedArray.set
can be slower than just running a for loop or manually assigning bytes into the array for copies of 16 bytes or less.benchmarks
Release Highlight
Improve the performance of small byte copies
When serializing ObjectIds, Decimal128, and UUID values we can get better performance by writing the byte-copying logic in Javascript for loops rather than using the TypedArray.set API. ObjectId serialization performance is 1.5x-2x faster.
Double-check the following
npm run check:lint
scripttype(NODE-xxxx)[!]: description
feat(NODE-1234)!: rewriting everything in coffeescript