commit:     1ac5e7f9b92b33f76cdb1e6e6f7e5bba42f2b496
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Nov 13 07:18:38 2015 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Nov 13 17:52:01 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=1ac5e7f9

GenChangeLogs: parallelize remaining git calls, scale linearly (bug 565540)

Move all git calls to the subprocesses, so performance scales linearly
with --jobs.

X-Gentoo-Bug: 565540
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=565540
Acked-by: Alexander Berntsen <bernalex <AT> gentoo.org>

 bin/egencache | 33 ++++++++++++++++++---------------
 1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/bin/egencache b/bin/egencache
index b44ad11..1cc2f3d 100755
--- a/bin/egencache
+++ b/bin/egencache
@@ -781,6 +781,23 @@ class GenChangeLogs(object):
                                encoding=_encodings['stdio'], errors='strict')
 
        def generate_changelog(self, cp):
+
+               os.chdir(os.path.join(self._repo_path, cp))
+               # Determine whether ChangeLog is up-to-date by comparing
+               # the newest commit timestamp with the ChangeLog timestamp.
+               lmod = self.grab(['git', self._work_tree, 'log', 
'--format=%ct', '-1', '.'])
+               if not lmod:
+                       # This cp has not been added to the repo.
+                       return
+
+               try:
+                       cmod = os.stat('ChangeLog').st_mtime
+               except OSError:
+                       cmod = 0
+
+               if float(cmod) >= float(lmod):
+                       return
+
                try:
                        output = io.open(self._changelog_output,
                                mode='w', encoding=_encodings['repo.content'],
@@ -913,21 +930,7 @@ class GenChangeLogs(object):
                        return
 
                for cp in self._portdb.cp_all():
-                       os.chdir(os.path.join(self._repo_path, cp))
-                       # Determine whether ChangeLog is up-to-date by comparing
-                       # the newest commit timestamp with the ChangeLog 
timestamp.
-                       lmod = self.grab(['git', self._work_tree, 'log', 
'--format=%ct', '-1', '.'])
-                       if not lmod:
-                               # This cp has not been added to the repo.
-                               continue
-
-                       try:
-                               cmod = os.stat('ChangeLog').st_mtime
-                       except OSError:
-                               cmod = 0
-
-                       if float(cmod) < float(lmod):
-                               yield 
AsyncFunction(target=self.generate_changelog, args=[cp])
+                       yield AsyncFunction(target=self.generate_changelog, 
args=[cp])
 
        def run(self):
                return run_main_scheduler(

Reply via email to