Skip to content

Commit

Permalink
fs: improve fsPromises writeFile performance
Browse files Browse the repository at this point in the history
Increase the write chunk size in fsPromises writeFile
to improve performance.
  • Loading branch information
Linkgoron committed Mar 5, 2021
1 parent 49342fe commit 0876cf3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/internal/fs/promises.js
Expand Up @@ -7,7 +7,7 @@ const kIoMaxLength = 2 ** 31 - 1;
// Note: This is different from kReadFileBufferLength used for non-promisified
// fs.readFile.
const kReadFileMaxChunkSize = 2 ** 14;
const kWriteFileMaxChunkSize = 2 ** 14;
const kWriteFileMaxChunkSize = 512 * 1024;

const {
ArrayPrototypePush,
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-fs-promises-file-handle-writeFile.js
Expand Up @@ -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());
Expand Down

0 comments on commit 0876cf3

Please sign in to comment.