Skip to content

fix(perf,allocator): use a separate threshold to batch atomic counter updates deallocating memory #3546

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: stable-23.10
Choose a base branch
from
Draft
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
4 changes: 3 additions & 1 deletion utils/common/countingallocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ const constexpr int64_t MemoryLimitLowerBound = 500 * 1024 * 1024;
// Higher values demonstrate slower response to memory limit violations.
const constexpr int64_t CheckPointStepSize = 100 * 1024;

const constexpr int64_t DeallocateCheckPointStepSize = 100 * 1024 * 1024;

// Custom Allocator that tracks allocated memory using an atomic counter
template <typename T>
class CountingAllocator
Expand Down Expand Up @@ -138,7 +140,7 @@ class CountingAllocator
int64_t sizeChangeWDirection =
(currentLocalMemoryUsage_ >= lastMemoryLimitCheckpoint_) ? -sizeToDeallocate : sizeToDeallocate;
int64_t diffSinceLastCheckPoint = int_distance(currentLocalMemoryUsage_, lastMemoryLimitCheckpoint_);
bool needsCheckpoint = needCheckPoint(sizeChangeWDirection, diffSinceLastCheckPoint, checkPointStepSize_);
bool needsCheckpoint = needCheckPoint(sizeChangeWDirection, diffSinceLastCheckPoint, DeallocateCheckPointStepSize);

// Now safe to delete
::operator delete(ptr);
Expand Down