summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2016-01-07 17:06:55 +0100
committerJulian Andres Klode <jak@debian.org>2016-01-07 17:31:24 +0100
commitb89cd2e36f9696ccd56167593c792116ae4fc97f (patch)
treed29f0513dd89364a592b936f8ecb027cbee7c585 /apt-pkg
parent40940e63a4dd3c7ef09ea1175e189350457b7270 (diff)
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.
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/acquire.cc24
1 files changed, 22 insertions, 2 deletions
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;