Gentoo Archives: gentoo-portage-dev

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

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies

Subject Author
Re: [gentoo-portage-dev] [PATCH v3] collision_protect: use dynamic report interval "M. J. Everitt" <m.j.everitt@×××.org>