Skip to content
Closed
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
6 changes: 6 additions & 0 deletions velox/common/memory/MemoryPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,12 @@ size_t MemoryPool::getPreferredSize(size_t size) {
return lower * 2;
}

void MemoryPool::setPreferredSize(
std::function<size_t(size_t)> getPreferredSizeFunc) {
VELOX_CHECK_NOT_NULL(getPreferredSizeFunc);
getPreferredSize_ = getPreferredSizeFunc;
}

MemoryPoolImpl::MemoryPoolImpl(
MemoryManager* memoryManager,
const std::string& name,
Expand Down
5 changes: 4 additions & 1 deletion velox/common/memory/MemoryPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,9 @@ class MemoryPool : public std::enable_shared_from_this<MemoryPool> {
return bits::roundUp(size, 8 * kMB);
}

// Overrides getPreferredSize to allow specializing behavior for this pool.
void setPreferredSize(std::function<size_t(size_t)> getPreferredSizeFunc);

protected:
static constexpr uint64_t kMB = 1 << 20;

Expand Down Expand Up @@ -530,7 +533,7 @@ class MemoryPool : public std::enable_shared_from_this<MemoryPool> {
const bool threadSafe_;
const bool debugEnabled_;
const bool coreOnAllocationFailureEnabled_;
const std::function<size_t(size_t)> getPreferredSize_;
std::function<size_t(size_t)> getPreferredSize_;

/// Indicates if the memory pool has been aborted by the memory arbitrator or
/// not.
Expand Down
Loading