summaryrefslogtreecommitdiff
path: root/apt-pkg/acquire.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2019-04-16 12:53:09 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2019-04-16 12:59:54 +0200
commitf426580b9964a15fbb2074aee6d5fb61b5e45ee2 (patch)
treee5f3763ec97c79eee534585e67cdf671e4dad4e6 /apt-pkg/acquire.cc
parentfebbe5e33b2105c8f40006a4b92ab5aa169aa03c (diff)
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.
Diffstat (limited to 'apt-pkg/acquire.cc')
-rw-r--r--apt-pkg/acquire.cc12
1 files 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<decltype(Instances)>(_config->FindI("Acquire::QueueHost::Limit",10)))
+ if (Instances >= static_cast<decltype(Instances)>(Limit))
return U.Access;
return FullQueueName;