Skip to content

fs: remove chunk by chunk file read #44276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 1 addition & 2 deletions lib/internal/fs/promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ const {
constants: {
kIoMaxLength,
kMaxUserId,
kReadFileBufferLength,
kReadFileUnknownBufferLength,
kWriteFileMaxChunkSize,
},
Expand Down Expand Up @@ -450,7 +449,7 @@ async function readFileHandle(filehandle, options) {
} else {
buffer = fullBuffer;
offset = totalRead;
length = MathMin(size - totalRead, kReadFileBufferLength);
length = size - totalRead;
}

const bytesRead = (await binding.read(filehandle.fd, buffer, offset,
Expand Down
4 changes: 1 addition & 3 deletions lib/internal/fs/read_file_context.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

const {
ArrayPrototypePush,
MathMin,
ReflectApply,
} = primordials;

const {
constants: {
kReadFileBufferLength,
kReadFileUnknownBufferLength,
}
} = require('internal/fs/utils');
Expand Down Expand Up @@ -99,7 +97,7 @@ class ReadFileContext {
} else {
buffer = this.buffer;
offset = this.pos;
length = MathMin(kReadFileBufferLength, this.size - this.pos);
length = this.size - this.pos;
}

const req = new FSReqCallback();
Expand Down
2 changes: 0 additions & 2 deletions lib/internal/fs/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ const kIoMaxLength = 2 ** 31 - 1;
// Use up to 512kb per read otherwise to partition reading big files to prevent
// blocking other threads in case the available threads are all in use.
const kReadFileUnknownBufferLength = 64 * 1024;
const kReadFileBufferLength = 512 * 1024;

const kWriteFileMaxChunkSize = 512 * 1024;

Expand Down Expand Up @@ -924,7 +923,6 @@ module.exports = {
constants: {
kIoMaxLength,
kMaxUserId,
kReadFileBufferLength,
kReadFileUnknownBufferLength,
kWriteFileMaxChunkSize,
},
Expand Down