From f426580b9964a15fbb2074aee6d5fb61b5e45ee2 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 16 Apr 2019 12:53:09 +0200 Subject: Don't limit cpu-limited queues to at most 10 Queues for processes like rred are not created by hostname but we spawn at most CPU*2 queues to place items in. The problem is that we then proceeded to limit it to at most 10 queues (via QueueHost::Limit) again at the end of the method so that all items (after the first 10 queues are busy) are forcibly placed into a generic catch-all instance which is bad because we don't keep all CPUs we have available busy and worse we end up sheduling the most work to a single one while random distribution was intended. --- apt-pkg/acquire.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc index 295af6eca..3abebc8d4 100644 --- a/apt-pkg/acquire.cc +++ b/apt-pkg/acquire.cc @@ -396,6 +396,7 @@ string pkgAcquire::QueueName(string Uri,MethodConfig const *&Config) if (Config->SingleInstance == true || QueueMode == QueueAccess) return U.Access; + int Limit = 10; string AccessSchema = U.Access + ':'; string FullQueueName; @@ -414,15 +415,15 @@ string pkgAcquire::QueueName(string Uri,MethodConfig const *&Config) #ifdef _SC_NPROCESSORS_ONLN long cpuCount = sysconf(_SC_NPROCESSORS_ONLN) * 2; #else - long cpuCount = 10; + long cpuCount = Limit; #endif - cpuCount = _config->FindI("Acquire::QueueHost::Limit", cpuCount); + Limit = _config->FindI("Acquire::QueueHost::Limit", cpuCount); - if (cpuCount <= 0 || existing < cpuCount) + if (Limit <= 0 || existing < Limit) strprintf(FullQueueName, "%s%ld", AccessSchema.c_str(), existing); else { - long const randomQueue = random() % cpuCount; + long const randomQueue = random() % Limit; strprintf(FullQueueName, "%s%ld", AccessSchema.c_str(), randomQueue); } @@ -430,6 +431,7 @@ string pkgAcquire::QueueName(string Uri,MethodConfig const *&Config) clog << "Chose random queue " << FullQueueName << " for " << Uri << endl; } else { + Limit = _config->FindI("Acquire::QueueHost::Limit", Limit); FullQueueName = AccessSchema + U.Host; } unsigned int Instances = 0, SchemaLength = AccessSchema.length(); @@ -448,7 +450,7 @@ string pkgAcquire::QueueName(string Uri,MethodConfig const *&Config) clog << "Found " << Instances << " instances of " << U.Access << endl; } - if (Instances >= static_cast(_config->FindI("Acquire::QueueHost::Limit",10))) + if (Instances >= static_cast(Limit)) return U.Access; return FullQueueName; -- cgit v1.2.3-18-g5258