Skip to content

Commit ba91ef2

Browse files
Linkgorondanielleadams
authored andcommitted
fs: improve fsPromises writeFile performance
Increase the write chunk size in fsPromises writeFile to improve performance. PR-URL: #37610 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Darshan Sen <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
1 parent 2d9b624 commit ba91ef2

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
@@ -6,7 +6,7 @@ const kIoMaxLength = 2 ** 31 - 1;
66

77
const kReadFileBufferLength = 512 * 1024;
88
const kReadFileUnknownBufferLength = 64 * 1024;
9-
const kWriteFileMaxChunkSize = 2 ** 14;
9+
const kWriteFileMaxChunkSize = 512 * 1024;
1010

1111
const {
1212
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)