From a84622377797f0b3d3fbf48fb05144bbea38a50b Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Fri, 14 Feb 2025 07:05:50 -0600 Subject: [PATCH] increased r/w buffer size --- .cspell/words.txt | 3 ++- src/ops/index.js | 5 +++-- src/utils/constants.js | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.cspell/words.txt b/.cspell/words.txt index 19bcf93..9001c35 100644 --- a/.cspell/words.txt +++ b/.cspell/words.txt @@ -1 +1,2 @@ -blockstorage \ No newline at end of file +blockstorage +uuidv4 \ No newline at end of file diff --git a/src/ops/index.js b/src/ops/index.js index 6918242..dc388b3 100644 --- a/src/ops/index.js +++ b/src/ops/index.js @@ -3,6 +3,7 @@ import { Uint64BE } from 'int64-buffer'; import file from '../io/file'; import packet from '../networking/packet'; +import { RW_BUFFER_SIZE } from '../utils/constants'; const _snapshot_directory = async (conn, remote_path) => { try { @@ -218,7 +219,7 @@ export const download_file = async ( let remain = src_size - offset; while (remain > 0) { - const to_write = remain >= 65536 ? 65536 : remain; + const to_write = remain >= RW_BUFFER_SIZE ? RW_BUFFER_SIZE : remain; const buffer = await src.read(offset, to_write); const written = fs.writeSync(dst_fd, buffer, 0, to_write, offset); if (written > 0) { @@ -531,7 +532,7 @@ export const upload_file = async ( } let remain = src_st.size - offset; - const default_buffer = Buffer.alloc(65536 * 2); + const default_buffer = Buffer.alloc(RW_BUFFER_SIZE); while (remain > 0) { const to_write = remain >= default_buffer.length ? default_buffer.length : remain; diff --git a/src/utils/constants.js b/src/utils/constants.js index d1e15ca..0447efb 100644 --- a/src/utils/constants.js +++ b/src/utils/constants.js @@ -14,3 +14,4 @@ export const setCustomEncryption = (ce) => { export const instance_id = uuidv4(); export const package_json = _package_json; export const get_version = () => _package_json.version; +export const RW_BUFFER_SIZE = 1024 * 1024;