Skip to content

Commit 8c3b586

Browse files
committed
fs: improve fsPromises writeFile performance
Increase the write chunk size in fsPromises writeFile to improve performance.
1 parent 49342fe commit 8c3b586

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lib/internal/fs/promises.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const kIoMaxLength = 2 ** 31 - 1;
77
// Note: This is different from kReadFileBufferLength used for non-promisified
88
// fs.readFile.
99
const kReadFileMaxChunkSize = 2 ** 14;
10-
const kWriteFileMaxChunkSize = 2 ** 14;
10+
const kWriteFileMaxChunkSize = 512 * 1024;
1111

1212
const {
1313
ArrayPrototypePush,

test/parallel/test-fs-promises-file-handle-writeFile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ async function validateWriteFile() {
3030
async function doWriteAndCancel() {
3131
const filePathForHandle = path.resolve(tmpDir, 'dogs-running.txt');
3232
const fileHandle = await open(filePathForHandle, 'w+');
33-
const buffer = Buffer.from('dogs running'.repeat(10000), 'utf8');
33+
const buffer = Buffer.from('dogs running'.repeat(512*1024), 'utf8');
3434
const controller = new AbortController();
3535
const { signal } = controller;
3636
process.nextTick(() => controller.abort());

0 commit comments

Comments
 (0)