rushstack
rushstack copied to clipboard
[node-core-library] Investigate having FileSystem.readFile and other sync APIs use a single static Buffer for performance
Summary
I recently significantly improved some NodeJS compression work by pre-allocating two Buffers, one for read and one for compressed output data, then using readSync and writeSync directly into the existing Buffer instances. I also found similar gains from using fs.promises.FileHandle and reading into a set of preallocated Buffer instances when performing bulk uploads.
Since the FileSystem.readSync call also decodes the string, the original buffer is immediately freed and therefore all such calls in the process can reuse the same buffer and reduce GC.
| Question | Answer |
|---|---|
| Package name: | @rushstack/node-core-library |
| Package version? | * |
| Operating system? | * |
| Would you consider contributing a PR? | Yes |
Node.js version (node -v)? |
18.19.1 |