Skip to content

Commit 83ee491

Browse files
authored
[ICRDMA] Chunk reclamation feature for slot mem pool. Change limit. EXT-1782 (#31708)
The original implementation of slot mem pool has no ability to reuse chunk for slots size X if it was split for slots size Y. It may cause the situation when we have no ability to allocate memory if all chunks was split for workset with different sizes. The proposed change track usage of chunk and allows to reuse it for any slot size if use count for the chunk becomes 0. This commit also changes limit so allocate object up to 32MB are allowed. Two improvement should be implemented in a future work: * Priority to allocate slots by use count of underlying chunk. This heuristic increases probability of success reclaimation * Varied chunk size. No need to use 32Mb chunk to split it in to 4K slots. It also increases probability of success reclaimation and improve performance of it
1 parent 1c215e4 commit 83ee491

File tree

8 files changed

+1269
-113
lines changed

8 files changed

+1269
-113
lines changed

ydb/library/actors/interconnect/rdma/mem_pool.cpp

Lines changed: 279 additions & 50 deletions
Large diffs are not rendered by default.

ydb/library/actors/interconnect/rdma/mem_pool.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,20 @@ namespace NMonitoring {
1414
struct TDynamicCounters;
1515
}
1616

17+
struct TMemRegCompare;
1718
namespace NInterconnect::NRdma {
1819

1920
class IMemPool;
2021
class TMemRegion;
2122
class TChunk;
2223
class TMemPoolImpl;
24+
class TSlotMemPool;
2325

2426
using TChunkPtr = TIntrusivePtr<TChunk>;
2527

2628
class TMemRegion: public NNonCopyable::TMoveOnly, public IContiguousChunk {
29+
friend struct ::TMemRegCompare;
30+
friend class TSlotMemPool;
2731
public:
2832
TMemRegion(TChunkPtr chunk, uint32_t offset, uint32_t size) noexcept;
2933
TMemRegion(TMemRegion&& other) noexcept = default;
@@ -35,16 +39,16 @@ namespace NInterconnect::NRdma {
3539
uint32_t GetLKey(size_t deviceIndex) const;
3640
uint32_t GetRKey(size_t deviceIndex) const;
3741

38-
void Resize(uint32_t newSize) noexcept;
39-
4042
public: // IContiguousChunk
4143
TContiguousSpan GetData() const override;
4244
TMutableContiguousSpan UnsafeGetDataMut() override;
4345
size_t GetOccupiedMemorySize() const override;
4446
EInnerType GetInnerType() const noexcept override;
4547
IContiguousChunk::TPtr Clone() noexcept override;
4648
protected:
49+
void Resize(uint32_t newSize) noexcept;
4750
TChunkPtr Chunk;
51+
ui64 Generation = 0;
4852
const uint32_t Offset;
4953
uint32_t Size;
5054
const uint32_t OrigSize;
@@ -97,9 +101,9 @@ namespace NInterconnect::NRdma {
97101
virtual TString GetName() const noexcept = 0;
98102

99103
protected:
100-
virtual TMemRegion* AllocImpl(int size, ui32 flags) noexcept = 0;
104+
virtual TMemRegionPtr AllocImpl(int size, ui32 flags) noexcept = 0;
101105
virtual void Free(TMemRegion&& mr, TChunk& chunk) noexcept = 0;
102-
virtual void DealocateMr(std::vector<ibv_mr*>& mrs) noexcept = 0;
106+
virtual void DealocateMr(TChunk*) noexcept = 0;
103107
private:
104108
virtual void Tick(NMonotonic::TMonotonic time) noexcept = 0;
105109
};

ydb/library/actors/interconnect/rdma/ut_mem_pool_limit/allocator_ut.cpp

Lines changed: 0 additions & 57 deletions
This file was deleted.

0 commit comments

Comments
 (0)