Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[node-core-library] Investigate having FileSystem.readFile and other sync APIs use a single static Buffer for performance #5128

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

Open
dmichon-msft opened this issue Feb 25, 2025 · 0 comments

Comments

@dmichon-msft
Copy link
Contributor

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
@github-project-automation github-project-automation bot moved this to Needs triage in Bug Triage Feb 25, 2025
@iclanton iclanton moved this from Needs triage to General Discussions in Bug Triage Mar 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: General Discussions
Development

No branches or pull requests

1 participant