Skip to content

Commit

Permalink
Configure BufferPool size depending on device type (#9764)
Browse files Browse the repository at this point in the history
  • Loading branch information
va-kuznecov authored Sep 25, 2024
1 parent 45718ca commit 8ebf595
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
10 changes: 7 additions & 3 deletions ydb/core/blobstorage/pdisk/blobstorage_pdisk_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ struct TPDiskConfig : public TThrRefBase {
ui64 CostLimitNs;

// AsyncBlockDevice settings
ui32 BufferPoolBufferSizeBytes = 512 << 10;
ui32 BufferPoolBufferCount = 256;
ui32 MaxQueuedCompletionActions = 128; // BufferPoolBufferCount / 2;
ui32 BufferPoolBufferSizeBytes;
ui32 BufferPoolBufferCount;
ui32 MaxQueuedCompletionActions;
bool UseSpdkNvmeDriver;

ui64 ExpectedSlotCount = 0;
Expand Down Expand Up @@ -211,6 +211,10 @@ struct TPDiskConfig : public TThrRefBase {
DeviceInFlight = choose(128, 4, hddInFlight);
CostLimitNs = choose(500'000ull, 20'000'000ull, 50'000'000ull);

BufferPoolBufferSizeBytes = choose(128 << 10, 256 << 10, 512 << 10);
BufferPoolBufferCount = choose(1024, 512, 256);
MaxQueuedCompletionActions = BufferPoolBufferCount / 2;

UseSpdkNvmeDriver = Path.StartsWith("PCIe:");
Y_ABORT_UNLESS(!UseSpdkNvmeDriver || deviceType == NPDisk::DEVICE_TYPE_NVME,
"SPDK NVMe driver can be used only with NVMe devices!");
Expand Down
14 changes: 8 additions & 6 deletions ydb/core/blobstorage/pdisk/blobstorage_pdisk_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ TPDisk::TPDisk(std::shared_ptr<TPDiskCtx> pCtx, const TIntrusivePtr<TPDiskConfig
0, 64 * 1024 * 1024);
ForsetiMaxLogBatchNs = TControlWrapper((PDiskCategory.IsSolidState() ? 50'000ll : 500'000ll), 0, 100'000'000ll);
ForsetiMaxLogBatchNsCached = ForsetiMaxLogBatchNs;
ForsetiOpPieceSizeSsd = TControlWrapper(64 * 1024, 1, 512 * 1024);
ForsetiOpPieceSizeRot = TControlWrapper(512 * 1024, 1, 512 * 1024);
ForsetiOpPieceSizeSsd = TControlWrapper(64 * 1024, 1, Cfg->BufferPoolBufferSizeBytes);
ForsetiOpPieceSizeRot = TControlWrapper(512 * 1024, 1, Cfg->BufferPoolBufferSizeBytes);
ForsetiOpPieceSizeCached = PDiskCategory.IsSolidState() ? ForsetiOpPieceSizeSsd : ForsetiOpPieceSizeRot;



if (Cfg->SectorMap) {
auto diskModeParams = Cfg->SectorMap->GetDiskModeParams();
if (diskModeParams) {
Expand Down Expand Up @@ -3419,12 +3421,12 @@ void TPDisk::Update() {
Mon.UpdateDurationTracker.UpdateStarted();
LWTRACK(PDiskUpdateStarted, UpdateCycleOrbit, PCtx->PDiskId);

ForsetiMaxLogBatchNsCached = ForsetiMaxLogBatchNs;
ForsetiOpPieceSizeCached = PDiskCategory.IsSolidState() ? ForsetiOpPieceSizeSsd : ForsetiOpPieceSizeRot;
ForsetiOpPieceSizeCached = Min<i64>(ForsetiOpPieceSizeCached, Cfg->BufferPoolBufferSizeBytes);
ForsetiOpPieceSizeCached = AlignDown<i64>(ForsetiOpPieceSizeCached, Format.SectorSize);
{
TGuard<TMutex> guard(StateMutex);
ForsetiMaxLogBatchNsCached = ForsetiMaxLogBatchNs;
ForsetiOpPieceSizeCached = PDiskCategory.IsSolidState() ? ForsetiOpPieceSizeSsd : ForsetiOpPieceSizeRot;
ForsetiOpPieceSizeCached = Min<i64>(ForsetiOpPieceSizeCached, Cfg->BufferPoolBufferSizeBytes);
ForsetiOpPieceSizeCached = AlignDown<i64>(ForsetiOpPieceSizeCached, Format.SectorSize);
// Switch the scheduler when possible
ForsetiScheduler.SetIsBinLogEnabled(EnableForsetiBinLog);

Expand Down

0 comments on commit 8ebf595

Please sign in to comment.