Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixup! fs: improve readFile performance
  • Loading branch information
BridgeAR committed Apr 4, 2019
commit b64266e5732891c9518f2f31421f70e245fa71e0
6 changes: 3 additions & 3 deletions lib/internal/fs/read_file_context.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ const { Buffer } = require('buffer');

const { FSReqCallback, close, read } = internalBinding('fs');

const kReadFileUnknownBufferLength = 8 * 1024;
const kReadFileBufferLength = 256 * 1024;
const kReadFileUnknownBufferLength = 16 * 1024;
const kReadFileBufferLength = 512 * 1024;

function readFileAfterRead(err, bytesRead) {
const context = this.context;
Expand Down Expand Up @@ -73,9 +73,9 @@ class ReadFileContext {

if (this.size === 0) {
buffer = Buffer.allocUnsafeSlow(kReadFileUnknownBufferLength);
this.buffer = buffer;
offset = 0;
length = kReadFileUnknownBufferLength;
this.buffer = buffer;
} else {
buffer = this.buffer;
offset = this.pos;
Expand Down