[yum-commits] docs/yum.conf.5 yum/config.py yum/drpm.py

James Antill james at osuosl.org
Wed Mar 6 21:30:39 UTC 2013


 docs/yum.conf.5 |    4 +++-
 yum/config.py   |    3 +--
 yum/drpm.py     |   20 +++++++++++++++++++-
 3 files changed, 23 insertions(+), 4 deletions(-)

New commits:
commit b2e61324385f147090ba9dce9e310f0fd34cb878
Author: James Antill <james at and.org>
Date:   Wed Mar 6 16:30:32 2013 -0500

    Remove per. repo. deltarpm config., as it doesn't work. Add deltarpm=-2.

diff --git a/docs/yum.conf.5 b/docs/yum.conf.5
index 850b8be..c701890 100644
--- a/docs/yum.conf.5
+++ b/docs/yum.conf.5
@@ -375,7 +375,9 @@ and the downloader honors these too.
 \fBdeltarpm\fR
 
 When non-zero, delta-RPM files are used if available.  The value specifies
-the maximum number of "applydeltarpm" processes Yum will spawn. (4 by default).
+the maximum number of "applydeltarpm" processes Yum will spawn, if the value
+is negative then yum works out how many cores you have and multiplies that
+by the value (cores=2, deltarpm=-2; 4 processes). (-2 by default).
 
 .IP
 \fBdeltarpm_percentage\fR
diff --git a/yum/config.py b/yum/config.py
index 3d8f754..f658f5b 100644
--- a/yum/config.py
+++ b/yum/config.py
@@ -791,7 +791,7 @@ class YumConf(StartupConf):
             allowed = ('ipv4', 'ipv6', 'whatever'),
             mapper  = {'4': 'ipv4', '6': 'ipv6'})
     max_connections = IntOption(0, range_min=0)
-    deltarpm = IntOption(4, range_min=-2)
+    deltarpm = IntOption(-2, range_min=-16, range_max=128)
     deltarpm_percentage = IntOption(75, range_min=1, range_max=100)
 
     http_caching = SelectionOption('all', ('none', 'packages', 'all'))
@@ -951,7 +951,6 @@ class RepoConf(BaseConfig):
     throttle = Inherit(YumConf.throttle)
     timeout = Inherit(YumConf.timeout)
     ip_resolve = Inherit(YumConf.ip_resolve)
-    deltarpm = Inherit(YumConf.deltarpm)
     deltarpm_percentage = Inherit(YumConf.deltarpm_percentage)
 
     http_caching = Inherit(YumConf.http_caching)
diff --git a/yum/drpm.py b/yum/drpm.py
index 9f0e109..3bcbcde 100644
--- a/yum/drpm.py
+++ b/yum/drpm.py
@@ -68,11 +68,30 @@ class DeltaPackage:
         # hooray
         return True
 
+def _num_cpus_online(unknown=1):
+    if not hasattr(os, "sysconf"):
+        return unknown
+
+    if not os.sysconf_names.has_key("SC_NPROCESSORS_ONLN"):
+        return unknown
+
+    ncpus = os.sysconf("SC_NPROCESSORS_ONLN")
+    try:
+        if int(ncpus) > 0:
+            return ncpus
+    except:
+        pass
+
+    return unknown
+
 class DeltaInfo:
     def __init__(self, ayum, pkgs):
         self.verbose_logger = ayum.verbose_logger
         self.jobs = {}
         self.limit = ayum.conf.deltarpm
+        if self.limit < 0:
+            nprocs = _num_cpus_online()
+            self.limit *= -nprocs
 
         # calculate update sizes
         oldrpms = {}
@@ -106,7 +125,6 @@ class DeltaInfo:
         # download delta metadata
         mdpath = {}
         for repo in reposize:
-            self.limit = max(self.limit, repo.deltarpm)
             for name in ('prestodelta', 'deltainfo'):
                 try: data = repo.repoXML.getData(name); break
                 except: pass


More information about the Yum-commits mailing list