Gentoo Archives: gentoo-portage-dev

From: Fabian Groffen <grobian@g.o>
To: gentoo-portage-dev@l.g.o
Cc: Fabian Groffen <grobian@g.o>
Subject: [gentoo-portage-dev] [PATCH v5] collision_protect: use dynamic report interval
Date: Thu, 10 Jan 2019 15:30:39
Message-Id: 20190110153013.6186-1-grobian@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH v4] collision_protect: use dynamic report interval by Fabian Groffen
1 The reporting of files remaining can look somewhat odd since the report
2 interval is hardcoded to be per 1000 objects. Adjust this interval to
3 be time based. This means that modern (fast) machines likely will never
4 see the countdown messages at all. On slow setups the message will be
5 informative that there is progress, albeit rather slowly. While at it,
6 report percentage done.
7
8 Output before this patch:
9
10 * checking 6158 files for package collisions
11 5158 files remaining ...
12 4158 files remaining ...
13 3158 files remaining ...
14 2158 files remaining ...
15 1158 files remaining ...
16 158 files remaining ...
17
18 Possible output after this patch on a slower machine:
19
20 * checking 6158 files for package collisions
21 48% done, 3145 files remaining ...
22 96% done, 192 files remaining ...
23 100% done
24
25 Signed-off-by: Fabian Groffen <grobian@g.o>
26 ---
27 lib/portage/dbapi/vartree.py | 15 +++++++++++++--
28 1 file changed, 13 insertions(+), 2 deletions(-)
29
30 diff --git a/lib/portage/dbapi/vartree.py b/lib/portage/dbapi/vartree.py
31 index 4b91caea8..909c0e473 100644
32 --- a/lib/portage/dbapi/vartree.py
33 +++ b/lib/portage/dbapi/vartree.py
34 @@ -35,6 +35,7 @@ portage.proxy.lazyimport.lazyimport(globals(),
35 'portage.util.install_mask:install_mask_dir,InstallMask',
36 'portage.util.listdir:dircache,listdir',
37 'portage.util.movefile:movefile',
38 + 'portage.util.monotonic:monotonic',
39 'portage.util.path:first_existing,iter_parents',
40 'portage.util.writeable_check:get_ro_checker',
41 'portage.util._xattr:xattr',
42 @@ -3475,13 +3476,21 @@ class dblink(object):
43 symlink_collisions = []
44 destroot = self.settings['ROOT']
45 totfiles = len(file_list) + len(symlink_list)
46 + previous = monotonic()
47 + progress_shown = False
48 + report_interval = 1.7 # seconds
49 + falign = len("%d" % totfiles)
50 showMessage(_(" %s checking %d files for package collisions\n") % \
51 (colorize("GOOD", "*"), totfiles))
52 for i, (f, f_type) in enumerate(chain(
53 ((f, "reg") for f in file_list),
54 ((f, "sym") for f in symlink_list))):
55 - if i % 1000 == 0 and i != 0:
56 - showMessage(_("%d files remaining ...\n") % (totfiles - i))
57 + current = monotonic()
58 + if current - previous > report_interval:
59 + showMessage(_("%3d%% done, %*d files remaining ...\n") %
60 + (i * 100 / totfiles, falign, totfiles - i))
61 + previous = current
62 + progress_shown = True
63
64 dest_path = normalize_path(
65 os.path.join(destroot, f.lstrip(os.path.sep)))
66 @@ -3570,6 +3579,8 @@ class dblink(object):
67 break
68 if stopmerge:
69 collisions.append(f)
70 + if progress_shown:
71 + showMessage(_("100% done\n"))
72 return collisions, dirs_ro, symlink_collisions, plib_collisions
73
74 def _lstat_inode_map(self, path_iter):
75 --
76 2.20.1

Replies