Performance issues in Buffer.writeUInt* functions? #44645
Labels
buffer
Issues and PRs related to the buffer subsystem.
performance
Issues and PRs related to the performance of Node.js.
I recently wrote some convenience functions for writing unsigned integers into uint8Arrays, buffers, or other array-like objects. Out of curiosity, I wanted to check how much slower these functions were compared to the
writeUint*
functions available in Node.js' buffers. Strangely, it seems that the convenience functions were significantly faster (1.5-4 times depending on the type/size of the uint). The code posted here is a plug-and-play benchmark script for the uint32 case. While, the convenience functions improve over time, probably due to TurboFan optimizations kicking in, the performance of Node.js' buffer functions seems to degrade (see output of benchmark script).Version
v14.15.0
Platform
Linux X 4.15.0-117-generic #118~16.04.1-Ubuntu SMP Sat Sep 5 23:35:06 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
What steps will reproduce the bug?
What is the expected behavior?
buffer.writeUInt* functions should at least be as fast as pure JavaScript implementations
What do you see instead?
buffer.writeUInt* functions' performance is lower and degrades over time compared to the submitted pure JavaScript implementations
The text was updated successfully, but these errors were encountered: