mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
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:
committed by
Antoine du Hamel
parent
c2a792f14a
commit
e1ce7f1194
@@ -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,
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user