Skip to content

Commit 1120c1a

Browse files
authored
Test a few small completion threads count (#10253)
1 parent 4c77083 commit 1120c1a

File tree

2 files changed

+44
-43
lines changed

2 files changed

+44
-43
lines changed

ydb/core/blobstorage/pdisk/blobstorage_pdisk_blockdevice_ut.cpp

Lines changed: 43 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -236,50 +236,51 @@ Y_UNIT_TEST_SUITE(TBlockDeviceTest) {
236236
TActorSystemCreator creator;
237237
auto start = TMonotonic::Now();
238238
while ((TMonotonic::Now() - start).Seconds() < 5) {
239-
const TIntrusivePtr<::NMonitoring::TDynamicCounters> counters = new ::NMonitoring::TDynamicCounters;
240-
THolder<TPDiskMon> mon(new TPDiskMon(counters, 0, nullptr));
241-
242-
ui32 buffSize = 64_KB;
243-
auto randomData = PrepareData(buffSize);
244-
ui32 bufferPoolSize = 512;
245-
THolder<NPDisk::TBufferPool> bufferPool(NPDisk::CreateBufferPool(buffSize, bufferPoolSize, false, {}));
246-
ui64 inFlight = 128;
247-
ui32 maxQueuedCompletionActions = bufferPoolSize / 2;
248-
ui32 completionThreadsCount = 1;
249-
ui64 diskSize = 32_GB;
250-
251-
TIntrusivePtr<NPDisk::TSectorMap> sectorMap = new NPDisk::TSectorMap(diskSize, NSectorMap::DM_NONE);
252-
THolder<NPDisk::IBlockDevice> device(CreateRealBlockDevice("", *mon, 0, 0, inFlight, TDeviceMode::None,
253-
maxQueuedCompletionActions, completionThreadsCount, sectorMap));
254-
device->Initialize(std::make_shared<TPDiskCtx>(creator.GetActorSystem()));
255-
256-
TAtomic counter = 0;
257-
const i64 totalRequests = 500;
258-
for (i64 i = 0; i < totalRequests; i++) {
259-
auto *completion = new TCompletionWorkerWithCounter(counter, TDuration::MicroSeconds(100));
260-
NPDisk::TBuffer::TPtr buffer(bufferPool->Pop());
261-
buffer->FlushAction = completion;
262-
auto* data = buffer->Data();
263-
switch (RandomNumber<ui32>(3)) {
264-
case 0:
265-
device->PreadAsync(data, 32_KB, 0, buffer.Release(), TReqId(), nullptr);
266-
break;
267-
case 1:
268-
memcpy(data, randomData.data(), 32_KB);
269-
device->PwriteAsync(data, 32_KB, 0, buffer.Release(), TReqId(), nullptr);
270-
break;
271-
case 2:
272-
device->FlushAsync(completion, TReqId());
273-
buffer->FlushAction = nullptr;
274-
break;
275-
default:
276-
break;
239+
for (auto completionThreadsCount : {0, 1, 2, 3}) {
240+
const TIntrusivePtr<::NMonitoring::TDynamicCounters> counters = new ::NMonitoring::TDynamicCounters;
241+
THolder<TPDiskMon> mon(new TPDiskMon(counters, 0, nullptr));
242+
243+
ui32 buffSize = 64_KB;
244+
auto randomData = PrepareData(buffSize);
245+
ui32 bufferPoolSize = 512;
246+
THolder<NPDisk::TBufferPool> bufferPool(NPDisk::CreateBufferPool(buffSize, bufferPoolSize, false, {}));
247+
ui64 inFlight = 128;
248+
ui32 maxQueuedCompletionActions = bufferPoolSize / 2;
249+
ui64 diskSize = 32_GB;
250+
251+
TIntrusivePtr<NPDisk::TSectorMap> sectorMap = new NPDisk::TSectorMap(diskSize, NSectorMap::DM_NONE);
252+
THolder<NPDisk::IBlockDevice> device(CreateRealBlockDevice("", *mon, 0, 0, inFlight, TDeviceMode::None,
253+
maxQueuedCompletionActions, completionThreadsCount, sectorMap));
254+
device->Initialize(std::make_shared<TPDiskCtx>(creator.GetActorSystem()));
255+
256+
TAtomic counter = 0;
257+
const i64 totalRequests = 500;
258+
for (i64 i = 0; i < totalRequests; i++) {
259+
auto *completion = new TCompletionWorkerWithCounter(counter, TDuration::MicroSeconds(100));
260+
NPDisk::TBuffer::TPtr buffer(bufferPool->Pop());
261+
buffer->FlushAction = completion;
262+
auto* data = buffer->Data();
263+
switch (RandomNumber<ui32>(3)) {
264+
case 0:
265+
device->PreadAsync(data, 32_KB, 0, buffer.Release(), TReqId(), nullptr);
266+
break;
267+
case 1:
268+
memcpy(data, randomData.data(), 32_KB);
269+
device->PwriteAsync(data, 32_KB, 0, buffer.Release(), TReqId(), nullptr);
270+
break;
271+
case 2:
272+
device->FlushAsync(completion, TReqId());
273+
buffer->FlushAction = nullptr;
274+
break;
275+
default:
276+
break;
277+
}
277278
}
278-
}
279279

280-
Ctest << AtomicGet(counter) << Endl;
281-
device.Destroy();
282-
UNIT_ASSERT(AtomicGet(counter) == totalRequests);
280+
Ctest << AtomicGet(counter) << Endl;
281+
device.Destroy();
282+
UNIT_ASSERT(AtomicGet(counter) == totalRequests);
283+
}
283284
}
284285
}
285286

ydb/core/blobstorage/pdisk/blobstorage_pdisk_impl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ LWTRACE_USING(BLOBSTORAGE_PROVIDER);
2525
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2626

2727
TPDisk::TPDisk(std::shared_ptr<TPDiskCtx> pCtx, const TIntrusivePtr<TPDiskConfig> cfg, const TIntrusivePtr<::NMonitoring::TDynamicCounters>& counters)
28-
: PCtx(std::move(pCtx)) //std::make_shared<TPDiskCtx>())
28+
: PCtx(std::move(pCtx))
2929
, Mon(counters, cfg->PDiskId, cfg.Get())
3030
, DriveModel(cfg->DriveModelSeekTimeNs,
3131
cfg->DriveModelSpeedBps,

0 commit comments

Comments
 (0)