Gentoo Archives: gentoo-portage-dev

From: Zac Medico <zmedico@g.o>
To: gentoo-portage-dev@l.g.o
Cc: Zac Medico <zmedico@g.o>
Subject: [gentoo-portage-dev] [PATCH] GenChangeLogs: parallelize remaining git calls, scale linearly (bug 565540)
Date: Fri, 13 Nov 2015 07:20:46
Message-Id: 1447399206-25940-1-git-send-email-zmedico@gentoo.org
1 Move all git calls to the subprocesses, so performance scales linearly
2 with --jobs.
3
4 X-Gentoo-Bug: 565540
5 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=565540
6 ---
7 bin/egencache | 33 ++++++++++++++++++---------------
8 1 file changed, 18 insertions(+), 15 deletions(-)
9
10 diff --git a/bin/egencache b/bin/egencache
11 index b44ad11..1cc2f3d 100755
12 --- a/bin/egencache
13 +++ b/bin/egencache
14 @@ -781,6 +781,23 @@ class GenChangeLogs(object):
15 encoding=_encodings['stdio'], errors='strict')
16
17 def generate_changelog(self, cp):
18 +
19 + os.chdir(os.path.join(self._repo_path, cp))
20 + # Determine whether ChangeLog is up-to-date by comparing
21 + # the newest commit timestamp with the ChangeLog timestamp.
22 + lmod = self.grab(['git', self._work_tree, 'log', '--format=%ct', '-1', '.'])
23 + if not lmod:
24 + # This cp has not been added to the repo.
25 + return
26 +
27 + try:
28 + cmod = os.stat('ChangeLog').st_mtime
29 + except OSError:
30 + cmod = 0
31 +
32 + if float(cmod) >= float(lmod):
33 + return
34 +
35 try:
36 output = io.open(self._changelog_output,
37 mode='w', encoding=_encodings['repo.content'],
38 @@ -913,21 +930,7 @@ class GenChangeLogs(object):
39 return
40
41 for cp in self._portdb.cp_all():
42 - os.chdir(os.path.join(self._repo_path, cp))
43 - # Determine whether ChangeLog is up-to-date by comparing
44 - # the newest commit timestamp with the ChangeLog timestamp.
45 - lmod = self.grab(['git', self._work_tree, 'log', '--format=%ct', '-1', '.'])
46 - if not lmod:
47 - # This cp has not been added to the repo.
48 - continue
49 -
50 - try:
51 - cmod = os.stat('ChangeLog').st_mtime
52 - except OSError:
53 - cmod = 0
54 -
55 - if float(cmod) < float(lmod):
56 - yield AsyncFunction(target=self.generate_changelog, args=[cp])
57 + yield AsyncFunction(target=self.generate_changelog, args=[cp])
58
59 def run(self):
60 return run_main_scheduler(
61 --
62 2.4.9

Replies