From 1835ca1918a4408e4ea1ba778919cea2c9a3b53e Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 9 May 2022 10:04:09 -0700 Subject: [PATCH] Remove the "25% of active pool" growth rate throttle from Drydock Summary: Ref T13677. Drydock has a hard-coded and fairly arbitrary limit which prevents a resource pool from growing more than 25% at once. This is vaguely reasonable for resources which allocate quickly, but suffocating for slower resources. It's also wholly arbitrary, and the "one per lease" limit introduced in D21807 should do a better job of covering the same ground while generally being more reasonable, expected, and predictable. Test Plan: Ran Drydock allocations without the throttle, saw faster pool growth. Subscribers: yelirekim, PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T13677 Differential Revision: https://secure.phabricator.com/D21808 --- .../DrydockBlueprintImplementation.php | 46 +++++-------------- 1 file changed, 11 insertions(+), 35 deletions(-) diff --git a/src/applications/drydock/blueprint/DrydockBlueprintImplementation.php b/src/applications/drydock/blueprint/DrydockBlueprintImplementation.php index c5e9f811b5..27ba6e623f 100644 --- a/src/applications/drydock/blueprint/DrydockBlueprintImplementation.php +++ b/src/applications/drydock/blueprint/DrydockBlueprintImplementation.php @@ -506,28 +506,21 @@ abstract class DrydockBlueprintImplementation extends Phobject { protected function shouldLimitAllocatingPoolSize( DrydockBlueprint $blueprint) { - // TODO: If this mechanism sticks around, these values should be - // configurable by the blueprint implementation. - // Limit on total number of active resources. $total_limit = $this->getConcurrentResourceLimit($blueprint); - - // Always allow at least this many allocations to be in flight at once. - $min_allowed = 1; - - // Allow this fraction of allocating resources as a fraction of active - // resources. - $growth_factor = 0.25; + if ($total_limit === null) { + return false; + } $resource = new DrydockResource(); - $conn_r = $resource->establishConnection('r'); + $conn = $resource->establishConnection('r'); $counts = queryfx_all( - $conn_r, - 'SELECT status, COUNT(*) N FROM %T + $conn, + 'SELECT status, COUNT(*) N FROM %R WHERE blueprintPHID = %s AND status != %s GROUP BY status', - $resource->getTableName(), + $resource, $blueprint->getPHID(), DrydockResourceStatus::STATUS_DESTROYED); $counts = ipull($counts, 'N', 'status'); @@ -539,29 +532,12 @@ abstract class DrydockBlueprintImplementation extends Phobject { // If we're at the limit on total active resources, limit additional // allocations. - if ($total_limit !== null) { - $n_total = ($n_alloc + $n_active + $n_broken + $n_released); - if ($n_total >= $total_limit) { - return true; - } + $n_total = ($n_alloc + $n_active + $n_broken + $n_released); + if ($n_total >= $total_limit) { + return true; } - // If the number of in-flight allocations is fewer than the minimum number - // of allowed allocations, don't impose a limit. - if ($n_alloc < $min_allowed) { - return false; - } - - $allowed_alloc = (int)ceil($n_active * $growth_factor); - - // If the number of in-flight allocation is fewer than the number of - // allowed allocations according to the pool growth factor, don't impose - // a limit. - if ($n_alloc < $allowed_alloc) { - return false; - } - - return true; + return false; } }