-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Avoid unnecessary reclaim on non-reclaimable query #9737
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -181,9 +181,10 @@ void SharedArbitrator::getCandidateStats( | |
op->candidates.clear(); | ||
op->candidates.reserve(op->candidatePools.size()); | ||
for (const auto& pool : op->candidatePools) { | ||
const bool selfCandidate = op->requestRoot == pool.get(); | ||
op->candidates.push_back( | ||
{freeCapacityOnly ? 0 : reclaimableUsedCapacity(*pool), | ||
reclaimableFreeCapacity(*pool), | ||
{freeCapacityOnly ? 0 : reclaimableUsedCapacity(*pool, selfCandidate), | ||
reclaimableFreeCapacity(*pool, selfCandidate), | ||
pool->currentBytes(), | ||
pool.get()}); | ||
} | ||
|
@@ -199,26 +200,31 @@ void SharedArbitrator::updateArbitrationFailureStats() { | |
++numFailures_; | ||
} | ||
|
||
int64_t SharedArbitrator::maxReclaimableCapacity(const MemoryPool& pool) const { | ||
int64_t SharedArbitrator::maxReclaimableCapacity( | ||
const MemoryPool& pool, | ||
bool isSelfReclaim) const { | ||
// Checks if a query memory pool has finished processing or not. If it has | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we update the comments here as well? |
||
// finished, then we don't have to respect the memory pool reserved capacity | ||
// limit check. | ||
// NOTE: for query system like Prestissimo, it holds a finished query | ||
// state in minutes for query stats fetch request from the Presto coordinator. | ||
if (pool.currentBytes() == 0 && pool.peakBytes() != 0) { | ||
if (isSelfReclaim || (pool.currentBytes() == 0 && pool.peakBytes() != 0)) { | ||
return pool.capacity(); | ||
} | ||
return std::max<int64_t>(0, pool.capacity() - memoryPoolReservedCapacity_); | ||
} | ||
|
||
int64_t SharedArbitrator::reclaimableFreeCapacity( | ||
const MemoryPool& pool) const { | ||
return std::min<int64_t>(pool.freeBytes(), maxReclaimableCapacity(pool)); | ||
const MemoryPool& pool, | ||
bool isSelfReclaim) const { | ||
return std::min<int64_t>( | ||
pool.freeBytes(), maxReclaimableCapacity(pool, isSelfReclaim)); | ||
} | ||
|
||
int64_t SharedArbitrator::reclaimableUsedCapacity( | ||
const MemoryPool& pool) const { | ||
const auto maxReclaimableBytes = maxReclaimableCapacity(pool); | ||
const MemoryPool& pool, | ||
bool isSelfReclaim) const { | ||
const auto maxReclaimableBytes = maxReclaimableCapacity(pool, isSelfReclaim); | ||
const auto reclaimableBytes = pool.reclaimableBytes(); | ||
return std::min<int64_t>(maxReclaimableBytes, reclaimableBytes.value_or(0)); | ||
} | ||
|
@@ -656,7 +662,8 @@ uint64_t SharedArbitrator::reclaimFreeMemoryFromCandidates( | |
} | ||
const int64_t bytesToReclaim = std::min<int64_t>( | ||
reclaimTargetBytes - reclaimedBytes, | ||
reclaimableFreeCapacity(*candidate.pool)); | ||
reclaimableFreeCapacity( | ||
*candidate.pool, candidate.pool == op->requestRoot)); | ||
if (bytesToReclaim <= 0) { | ||
continue; | ||
} | ||
|
@@ -725,7 +732,8 @@ uint64_t SharedArbitrator::reclaim( | |
uint64_t targetBytes, | ||
bool isLocalArbitration) noexcept { | ||
int64_t bytesToReclaim = std::min<uint64_t>( | ||
std::max(targetBytes, memoryPoolTransferCapacity_), pool->capacity()); | ||
std::max(targetBytes, memoryPoolTransferCapacity_), | ||
maxReclaimableCapacity(*pool, true)); | ||
if (bytesToReclaim == 0) { | ||
return 0; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/selfCandidate/isSelfReclaim/ to have the consistent name across methods.