Skip to content

Commit

Permalink
Deprecate transfer capacity for shared arbitrator
Browse files Browse the repository at this point in the history
  • Loading branch information
tanjialiang committed Sep 25, 2024
1 parent 2bfc0eb commit 9892ff3
Show file tree
Hide file tree
Showing 12 changed files with 3,154 additions and 9 deletions.
2 changes: 1 addition & 1 deletion velox/common/memory/SharedArbitrator.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class SharedArbitrator : public memory::MemoryArbitrator {
static constexpr std::string_view kMemoryPoolTransferCapacity{
"memory-pool-transfer-capacity"};
static constexpr std::string_view kDefaultMemoryPoolTransferCapacity{
"128MB"};
"0B"};
static uint64_t getMemoryPoolTransferCapacity(
const std::unordered_map<std::string, std::string>& configs);

Expand Down
11 changes: 6 additions & 5 deletions velox/common/memory/tests/MemoryArbitratorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ TEST_F(MemoryArbitrationTest, queryMemoryCapacity) {
ASSERT_FALSE(manager.arbitrator()->growCapacity(rootPool.get(), 6 << 20));
ASSERT_EQ(rootPool->capacity(), 1 << 20);
ASSERT_TRUE(manager.arbitrator()->growCapacity(rootPool.get(), 2 << 20));
ASSERT_TRUE(manager.arbitrator()->growCapacity(rootPool.get(), 1 << 20));
ASSERT_EQ(rootPool->capacity(), 4 << 20);
ASSERT_EQ(manager.arbitrator()->stats().freeCapacityBytes, 2 << 20);
ASSERT_EQ(manager.arbitrator()->stats().freeReservedCapacityBytes, 2 << 20);
Expand All @@ -154,19 +155,19 @@ TEST_F(MemoryArbitrationTest, queryMemoryCapacity) {
"Exceeded memory pool capacity after attempt to grow capacity through "
"arbitration. Requestor pool name 'leaf-1.0', request size 7.00MB, "
"memory pool capacity 4.00MB, memory pool max capacity 8.00MB");
ASSERT_EQ(manager.arbitrator()->shrinkCapacity(rootPool.get(), 0), 1 << 20);
ASSERT_EQ(manager.arbitrator()->shrinkCapacity(rootPool.get(), 0), 0);
ASSERT_EQ(manager.arbitrator()->shrinkCapacity(leafPool.get(), 0), 0);
ASSERT_EQ(manager.arbitrator()->shrinkCapacity(leafPool.get(), 1), 0);
ASSERT_EQ(manager.arbitrator()->shrinkCapacity(rootPool.get(), 1), 0);
ASSERT_EQ(rootPool->capacity(), 3 << 20);
ASSERT_EQ(rootPool->capacity(), 4 << 20);
static_cast<MemoryPoolImpl*>(rootPool.get())->testingSetReservation(0);
ASSERT_EQ(
manager.arbitrator()->shrinkCapacity(leafPool.get(), 1 << 20), 1 << 20);
ASSERT_EQ(
manager.arbitrator()->shrinkCapacity(rootPool.get(), 1 << 20), 1 << 20);
ASSERT_EQ(rootPool->capacity(), 1 << 20);
ASSERT_EQ(leafPool->capacity(), 1 << 20);
ASSERT_EQ(manager.arbitrator()->shrinkCapacity(leafPool.get(), 0), 1 << 20);
ASSERT_EQ(rootPool->capacity(), 2 << 20);
ASSERT_EQ(leafPool->capacity(), 2 << 20);
ASSERT_EQ(manager.arbitrator()->shrinkCapacity(leafPool.get(), 0), 2 << 20);
ASSERT_EQ(rootPool->capacity(), 0);
ASSERT_EQ(leafPool->capacity(), 0);
}
Expand Down
2 changes: 1 addition & 1 deletion velox/common/memory/tests/MockSharedArbitratorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ TEST_F(MockSharedArbitrationTest, extraConfigs) {
ASSERT_EQ(
SharedArbitrator::ExtraConfig::getMemoryPoolTransferCapacity(
emptyConfigs),
128 << 20);
0);
ASSERT_EQ(
SharedArbitrator::ExtraConfig::getMemoryReclaimMaxWaitTimeMs(
emptyConfigs),
Expand Down
2 changes: 0 additions & 2 deletions velox/exec/tests/utils/ArbitratorTestUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ std::unique_ptr<memory::MemoryManager> createMemoryManager(
options.extraArbitratorConfigs = {
{std::string(ExtraConfig::kMemoryPoolInitialCapacity),
folly::to<std::string>(memoryPoolInitCapacity) + "B"},
{std::string(ExtraConfig::kMemoryPoolTransferCapacity),
folly::to<std::string>(memoryPoolTransferCapacity) + "B"},
{std::string(ExtraConfig::kMemoryReclaimMaxWaitTime),
folly::to<std::string>(maxReclaimWaitMs) + "ms"},
{std::string(ExtraConfig::kGlobalArbitrationEnabled), "true"},
Expand Down
Loading

0 comments on commit 9892ff3

Please sign in to comment.