fs: improve fsPromises writeFile performance

Increase the write chunk size in fsPromises writeFile
to improve performance.

PR-URL: https://github.com/nodejs/node/pull/37610
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
Nitzan Uziely
2021-03-05 14:37:57 +02:00
committed by Antoine du Hamel
parent c2a792f14a
commit e1ce7f1194
2 changed files with 2 additions and 2 deletions

View File

@@ -6,7 +6,7 @@ const kIoMaxLength = 2 ** 31 - 1;
const kReadFileBufferLength = 512 * 1024;
const kReadFileUnknownBufferLength = 64 * 1024;
const kWriteFileMaxChunkSize = 2 ** 14;
const kWriteFileMaxChunkSize = 512 * 1024;
const {
ArrayPrototypePush,

View File

@@ -30,7 +30,7 @@ async function validateWriteFile() {
async function doWriteAndCancel() {
const filePathForHandle = path.resolve(tmpDir, 'dogs-running.txt');
const fileHandle = await open(filePathForHandle, 'w+');
const buffer = Buffer.from('dogs running'.repeat(10000), 'utf8');
const buffer = Buffer.from('dogs running'.repeat(512 * 1024), 'utf8');
const controller = new AbortController();
const { signal } = controller;
process.nextTick(() => controller.abort());