You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fs: caller-supplied buffer for fs.readFile / fs.readFileSync #63600
fs.readFile* allocates a fresh Buffer on every call. Fine for most code, expensive on hot paths. Multiple Worker threads doing concurrent reads contend hard on the per-process mmap_lock in the kernel — about 17× longer wait per allocation than equivalent child processes (trace in #63597).
The workaround today is openSync + readSync + closeSync with your own buffer. Works, but you lose readFile's ergonomics, especially for the async variants.
Two small additions would close that gap.
{ buffer }
Pass a buffer to fill, get back a subarray view of the actual file bytes:
If the file is bigger than the buffer, throw. Same shape as crypto.randomFillSync(buf) vs crypto.randomBytes(n), or fs.read(fd, buf, ...) at the lower level.
{ getBuffer(size) }
Pass a factory called with the file's size (we already get it from fstat):
Activity
targos commentedon May 27, 2026
mertcanaltin commentedon May 27, 2026
fs: support caller-supplied readFile() buffers
fs: support caller-supplied readFile() buffers
fs: support caller-supplied readFile() buffers
fs: support caller-supplied readFile() buffers