diff options
author | Craig Tiller <ctiller@google.com> | 2017-03-24 14:16:28 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-24 14:16:28 -0700 |
commit | 7e6b7df8d6bbb80c19ae1736e0c35b4eab06c541 (patch) | |
tree | 89282ea0b49325c3e65ceeabc2431f8e32cd7500 /src/core/lib/surface | |
parent | ac4a7283ee77bfe5118a061a62930019ff090e37 (diff) | |
parent | b64d652703e998525291eef36c416874894d5749 (diff) |
Merge pull request #10275 from ctiller/memory
Memory usage tweaks
Diffstat (limited to 'src/core/lib/surface')
-rw-r--r-- | src/core/lib/surface/channel.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/core/lib/surface/channel.c b/src/core/lib/surface/channel.c index d6c7aee40d..b4bfb92042 100644 --- a/src/core/lib/surface/channel.c +++ b/src/core/lib/surface/channel.c @@ -194,8 +194,14 @@ grpc_channel *grpc_channel_create(grpc_exec_ctx *exec_ctx, const char *target, size_t grpc_channel_get_call_size_estimate(grpc_channel *channel) { #define ROUND_UP_SIZE 256 + /* We round up our current estimate to the NEXT value of ROUND_UP_SIZE. + This ensures: + 1. a consistent size allocation when our estimate is drifting slowly + (which is common) - which tends to help most allocators reuse memory + 2. a small amount of allowed growth over the estimate without hitting + the arena size doubling case, reducing overall memory usage */ return ((size_t)gpr_atm_no_barrier_load(&channel->call_size_estimate) + - ROUND_UP_SIZE) & + 2 * ROUND_UP_SIZE) & ~(size_t)(ROUND_UP_SIZE - 1); } |