From f5f44d86a3cf1bf6200e7817360879afce3a4cf4 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Tue, 9 Jun 2020 15:31:27 -0700 Subject: [PATCH 1/2] no unref when there's no aborted allocations --- src/core/lib/iomgr/resource_quota.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/lib/iomgr/resource_quota.cc b/src/core/lib/iomgr/resource_quota.cc index b5df53ecdb8..967d0b7e4f4 100644 --- a/src/core/lib/iomgr/resource_quota.cc +++ b/src/core/lib/iomgr/resource_quota.cc @@ -334,7 +334,9 @@ static bool rq_alloc(grpc_resource_quota* resource_quota) { resource_user->free_pool += aborted_allocations; grpc_core::ExecCtx::RunList(DEBUG_LOCATION, &resource_user->on_allocated); gpr_mu_unlock(&resource_user->mu); - ru_unref_by(resource_user, static_cast(aborted_allocations)); + if (aborted_allocations > 0) { + ru_unref_by(resource_user, static_cast(aborted_allocations)); + } continue; } if (resource_user->free_pool < 0 && From 5e6b089f16570e3e4c2dcc7626f4c8c56ddf1e11 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Fri, 12 Jun 2020 12:18:57 -0700 Subject: [PATCH 2/2] Print outstanding allocations in log --- src/core/lib/iomgr/resource_quota.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/lib/iomgr/resource_quota.cc b/src/core/lib/iomgr/resource_quota.cc index 967d0b7e4f4..de5b25a7827 100644 --- a/src/core/lib/iomgr/resource_quota.cc +++ b/src/core/lib/iomgr/resource_quota.cc @@ -320,9 +320,9 @@ static bool rq_alloc(grpc_resource_quota* resource_quota) { if (GRPC_TRACE_FLAG_ENABLED(grpc_resource_quota_trace)) { gpr_log(GPR_INFO, "RQ: check allocation for user %p shutdown=%" PRIdPTR - " free_pool=%" PRId64, + " free_pool=%" PRId64 " outstanding_allocations=%" PRId64, resource_user, gpr_atm_no_barrier_load(&resource_user->shutdown), - resource_user->free_pool); + resource_user->free_pool, resource_user->outstanding_allocations); } if (gpr_atm_no_barrier_load(&resource_user->shutdown)) { resource_user->allocating = false;