@@ -348,7 +348,7 @@ bool SharedArbitrator::ensureCapacity(
348
348
if (checkCapacityGrowth (*requestor, targetBytes)) {
349
349
return true ;
350
350
}
351
- const uint64_t reclaimedBytes = reclaim (requestor, targetBytes);
351
+ const uint64_t reclaimedBytes = reclaim (requestor, targetBytes, true );
352
352
// NOTE: return the reclaimed bytes back to the arbitrator and let the memory
353
353
// arbitration process to grow the requestor's memory capacity accordingly.
354
354
incrementFreeCapacity (reclaimedBytes);
@@ -427,6 +427,8 @@ bool SharedArbitrator::arbitrateMemory(
427
427
428
428
VELOX_CHECK_LT (freedBytes, growTarget);
429
429
RECORD_METRIC_VALUE (kMetricArbitratorGlobalArbitrationCount );
430
+ addThreadLocalRuntimeStat (
431
+ " globalArbitrationCount" , RuntimeCounter (1 , RuntimeCounter::Unit::kNone ));
430
432
freedBytes += reclaimUsedMemoryFromCandidatesBySpill (
431
433
requestor, candidates, growTarget - freedBytes);
432
434
if (requestor->aborted ()) {
@@ -494,7 +496,7 @@ uint64_t SharedArbitrator::reclaimUsedMemoryFromCandidatesBySpill(
494
496
const int64_t bytesToReclaim = std::max<int64_t >(
495
497
targetBytes - freedBytes, memoryPoolTransferCapacity_);
496
498
VELOX_CHECK_GT (bytesToReclaim, 0 );
497
- freedBytes += reclaim (candidate.pool , bytesToReclaim);
499
+ freedBytes += reclaim (candidate.pool , bytesToReclaim, false );
498
500
if ((freedBytes >= targetBytes) ||
499
501
(requestor != nullptr && requestor->aborted ())) {
500
502
break ;
@@ -531,7 +533,8 @@ uint64_t SharedArbitrator::reclaimUsedMemoryFromCandidatesByAbort(
531
533
532
534
uint64_t SharedArbitrator::reclaim (
533
535
MemoryPool* pool,
534
- uint64_t targetBytes) noexcept {
536
+ uint64_t targetBytes,
537
+ bool isLocalArbitration) noexcept {
535
538
uint64_t reclaimDurationUs{0 };
536
539
uint64_t reclaimedBytes{0 };
537
540
uint64_t freedBytes{0 };
@@ -542,7 +545,12 @@ uint64_t SharedArbitrator::reclaim(
542
545
try {
543
546
freedBytes = pool->shrink (targetBytes);
544
547
if (freedBytes < targetBytes) {
545
- RECORD_METRIC_VALUE (kMetricArbitratorLocalArbitrationCount );
548
+ if (isLocalArbitration) {
549
+ RECORD_METRIC_VALUE (kMetricArbitratorLocalArbitrationCount );
550
+ addThreadLocalRuntimeStat (
551
+ " localArbitrationCount" ,
552
+ RuntimeCounter (1 , RuntimeCounter::Unit::kNone ));
553
+ }
546
554
pool->reclaim (
547
555
targetBytes - freedBytes, memoryReclaimWaitMs_, reclaimerStats);
548
556
}
0 commit comments