Skip to content

Commit 7d4123a

Browse files
committed
perf(cs): make inputBuffer size progressive
The current implementation of the WriteHighLevelOp class always asks for maxBlocksPerHddWriteJob_ blocks for its next inputBuffer_, i.e the structure to land the upcoming data blocks to be written to the drive. This can became a significant waste of memory when the write high level operation only writes 1 block, but asks for 32, if the MAX_BLOCKS_PER_HDD_WRITE_JOB is set to that number, for instance. The change proposed targets limiting the use of memory for any number of blocks written in a single write high level operation to the double of the strictly necessary memory. Considering the previous case, the write high level operation will ask for 1, 2, 4, 8, 16, 32 and continue asking for input buffers of 32 blocks. The main downside is a possible increase in the number of drive operations when the number of blocks written is between 2 and 15. Signed-off-by: Dave <dave@leil.io>
1 parent 5c742a6 commit 7d4123a

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/chunkserver/chunk_high_level_ops.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,8 +466,10 @@ void WriteHighLevelOp::prepareInputBufferForWrite(bool isForward) {
466466
if (inputBuffer_ == nullptr) {
467467
inputBuffer_ = getWriteInputBufferPool().get(
468468
isForward ? kSauWriteDataPrefixSizeForward : kSauWriteDataPrefixSize,
469-
maxBlocksPerHddWriteJob_);
469+
nextInputBufferBlockCount_);
470470
}
471+
nextInputBufferBlockCount_ =
472+
std::min<uint16_t>(nextInputBufferBlockCount_ * 2, maxBlocksPerHddWriteJob_);
471473

472474
inputBuffer_->addNewWriteOperation();
473475
}

src/chunkserver/chunk_high_level_ops.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,10 @@ class WriteHighLevelOp : public HighLevelOp {
300300
/// Prepares the input buffer for a write operation.
301301
void prepareInputBufferForWrite(bool isForward);
302302

303-
///< Number of blocks to write to the device in one write job.
303+
/// Size in blocks of the next input buffer.
304+
uint16_t nextInputBufferBlockCount_ = 1;
305+
306+
/// Number of blocks to write to the device in one write job.
304307
uint16_t maxBlocksPerHddWriteJob_;
305308

306309
/// Indicates if the chunk is locked for writing. If true, master will be waiting for the lock

0 commit comments

Comments
 (0)