From b89cd2e36f9696ccd56167593c792116ae4fc97f Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Thu, 7 Jan 2016 17:06:55 +0100 Subject: acquire: Allow parallelizing methods without hosts The maximum parallelization soft limit is the number of CPU cores * 2 on systems defining _SC_NPROCESSORS_ONLN. The hard limit in all cases is Acquire::QueueHost::Limit. --- apt-pkg/acquire.cc | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'apt-pkg/acquire.cc') diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc index 3010f55aa..7a483f272 100644 --- a/apt-pkg/acquire.cc +++ b/apt-pkg/acquire.cc @@ -351,8 +351,28 @@ string pkgAcquire::QueueName(string Uri,MethodConfig const *&Config) if (Config->SingleInstance == true || QueueMode == QueueAccess) return U.Access; - string AccessSchema = U.Access + ':', - FullQueueName = AccessSchema + U.Host; + string AccessSchema = U.Access + ':'; + string FullQueueName; + + if (U.Host.empty()) + { + long randomQueue = random(); +#ifdef _SC_NPROCESSORS_ONLN + long cpuCount = sysconf(_SC_NPROCESSORS_ONLN) * 2; +#else + long cpuCount = _config->FindI("Acquire::QueueHost::Limit",10); +#endif + if (cpuCount > 0) + randomQueue %= cpuCount; + + strprintf(FullQueueName, "%s%ld", AccessSchema.c_str(), randomQueue); + if (Debug) { + clog << "Chose random queue " << FullQueueName << " for " << Uri << endl; + } + } else + { + FullQueueName = AccessSchema + U.Host; + } unsigned int Instances = 0, SchemaLength = AccessSchema.length(); Queue *I = Queues; -- cgit v1.2.3