Browse Source

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.
tags/devuan/2.0.1+devuan1
David Kalnischkies 1 year ago
parent
commit
f426580b99
1 changed files with 7 additions and 5 deletions
  1. +7
    -5
      apt-pkg/acquire.cc

+ 7
- 5
apt-pkg/acquire.cc View File

@@ -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;


Loading…
Cancel
Save