perf(NODE-5910): optimize small byte copies#651
Conversation
durran
left a comment
There was a problem hiding this comment.
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.setcan 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:lintscripttype(NODE-xxxx)[!]: descriptionfeat(NODE-1234)!: rewriting everything in coffeescript