Skip to content
Merged
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
5 changes: 0 additions & 5 deletions ydb/library/actors/interconnect/rdma/mem_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -666,9 +666,4 @@ namespace NInterconnect::NRdma {
static TSlotMemPool pool(MakeCounters(counters), settings);
return std::shared_ptr<TSlotMemPool>(&pool, [](TSlotMemPool*) {});
}

// Just for UT
std::shared_ptr<IMemPool> CreateNonStaticSlotMemPool(TDynamicCounters* counters, std::optional<TMemPoolSettings> settings) noexcept {
return std::make_shared<TSlotMemPool>(MakeCounters(counters), settings);
}
}
41 changes: 0 additions & 41 deletions ydb/library/actors/interconnect/rdma/ut/allocator_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@ bool IsFastPool(std::shared_ptr<NInterconnect::NRdma::IMemPool> memPool) {
return memPool->GetName() == "SlotMemPool" || memPool->GetName() == "IncrementalMemPool";
}

namespace NMonitoring {
struct TDynamicCounters;
}

namespace NInterconnect::NRdma {
std::shared_ptr<IMemPool> CreateNonStaticSlotMemPool(NMonitoring::TDynamicCounters* counters, std::optional<TMemPoolSettings> settings) noexcept;
}

class TAllocatorSuite : public TSkipFixture {};

TEST_F(TAllocatorSuite, AllocMemoryManually) {
Expand Down Expand Up @@ -379,39 +371,6 @@ TEST_P(WithAllPools, DetachAndDestroySrc) {
UNIT_ASSERT_EQUAL(::memcmp(res, "test", 4), 0);
}

TEST_F(TAllocatorSuite, SlotPoolLimit) {
const NInterconnect::NRdma::TMemPoolSettings settings {
.SizeLimitMb = 32
};
static auto pool = NInterconnect::NRdma::CreateNonStaticSlotMemPool(nullptr, settings);

const size_t sz = 4 << 20;
std::vector<NInterconnect::NRdma::TMemRegionPtr> regions;
regions.reserve(8);
size_t i = 0;
for (;;i++) {
auto reg = pool->Alloc(sz, 0);
if (!reg) {
UNIT_ASSERT(i == 8); // 32 / 4
break;
}
ASSERT_TRUE(reg->GetAddr()) << "invalid address";
ASSERT_TRUE(reg->GetSize() == sz) << "invalid size of allocated chunk";
regions.push_back(reg);
}

regions.erase(regions.begin()); // free one region

{
auto reg = pool->Alloc(sz, 0); // allocate one
ASSERT_TRUE(reg->GetAddr()) << "invalid address";
ASSERT_TRUE(reg->GetSize() == sz) << "invalid size of allocated chunk";
UNIT_ASSERT(!pool->Alloc(sz, 0)); // pool is full
}

regions.clear();
}

INSTANTIATE_TEST_SUITE_P(
TAllocatorSuite,
WithAllPools,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#include <ydb/library/actors/interconnect/rdma/mem_pool.h>
#include <ydb/library/actors/interconnect/rdma/ut/utils/utils.h>

#include <library/cpp/testing/gtest/gtest.h>
#include <ydb/library/testlib/unittest_gtest_macro_subst.h>

namespace NMonitoring {
struct TDynamicCounters;
}

static void GTestSkip() {
GTEST_SKIP() << "Skipping all rdma tests for suit, set \""
<< NRdmaTest::RdmaTestEnvSwitchName << "\" env if it is RDMA compatible";
}

class TAllocatorSuite : public ::testing::Test {
protected:
void SetUp() override {
using namespace NRdmaTest;
if (IsRdmaTestDisabled()) {
GTestSkip();
}
}
};

TEST_F(TAllocatorSuite, SlotPoolLimit) {
const NInterconnect::NRdma::TMemPoolSettings settings {
.SizeLimitMb = 32
};
static auto pool = NInterconnect::NRdma::CreateSlotMemPool(nullptr, settings);

const size_t sz = 4 << 20;
std::vector<NInterconnect::NRdma::TMemRegionPtr> regions;
regions.reserve(8);
size_t i = 0;
for (;;i++) {
auto reg = pool->Alloc(sz, 0);
if (!reg) {
UNIT_ASSERT(i == 8); // 32 / 4
break;
}
ASSERT_TRUE(reg->GetAddr()) << "invalid address";
ASSERT_TRUE(reg->GetSize() == sz) << "invalid size of allocated chunk";
regions.push_back(reg);
}

regions.erase(regions.begin()); // free one region

{
auto reg = pool->Alloc(sz, 0); // allocate one
ASSERT_TRUE(reg->GetAddr()) << "invalid address";
ASSERT_TRUE(reg->GetSize() == sz) << "invalid size of allocated chunk";
UNIT_ASSERT(!pool->Alloc(sz, 0)); // pool is full
}

regions.clear();
}
23 changes: 23 additions & 0 deletions ydb/library/actors/interconnect/rdma/ut_mem_pool_limit/ya.make
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
GTEST()

IF (OS_LINUX AND SANITIZER_TYPE != "memory")

IF (SANITIZER_TYPE == "thread")
SIZE(LARGE)
TAG(ya:fat)
ELSE()
SIZE(MEDIUM)
ENDIF()

SRCS(
allocator_ut.cpp
)

PEERDIR(
ydb/library/actors/interconnect/rdma
ydb/library/actors/interconnect/rdma/ut/utils
)

ENDIF()

END()
5 changes: 5 additions & 0 deletions ydb/library/actors/interconnect/rdma/ya.make
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ IF (OS_LINUX)

PEERDIR(
ydb/library/actors/interconnect/address
ydb/library/actors/util
contrib/libs/ibdrv
contrib/libs/protobuf
library/cpp/monlib/dynamic_counters
)

ELSE()
Expand All @@ -26,7 +28,9 @@ ELSE()

PEERDIR(
ydb/library/actors/interconnect/address
ydb/library/actors/util
contrib/libs/protobuf
library/cpp/monlib/dynamic_counters
)

ENDIF()
Expand All @@ -39,4 +43,5 @@ RECURSE(

RECURSE_FOR_TESTS(
ut
ut_mem_pool_limit
)
Loading