1 |
On 1/9/19 12:33 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 | 13 +++++++++++-- |
29 |
> 1 file changed, 11 insertions(+), 2 deletions(-) |
30 |
> |
31 |
> diff --git a/lib/portage/dbapi/vartree.py b/lib/portage/dbapi/vartree.py |
32 |
> index 4b91caea8..df192e6fc 100644 |
33 |
> --- a/lib/portage/dbapi/vartree.py |
34 |
> +++ b/lib/portage/dbapi/vartree.py |
35 |
> @@ -35,6 +35,7 @@ portage.proxy.lazyimport.lazyimport(globals(), |
36 |
> 'portage.util.install_mask:install_mask_dir,InstallMask', |
37 |
> 'portage.util.listdir:dircache,listdir', |
38 |
> 'portage.util.movefile:movefile', |
39 |
> + 'portage.util.monotonic:monotonic', |
40 |
> 'portage.util.path:first_existing,iter_parents', |
41 |
> 'portage.util.writeable_check:get_ro_checker', |
42 |
> 'portage.util._xattr:xattr', |
43 |
> @@ -3475,13 +3476,19 @@ class dblink(object): |
44 |
> symlink_collisions = [] |
45 |
> destroot = self.settings['ROOT'] |
46 |
> totfiles = len(file_list) + len(symlink_list) |
47 |
> + tnow = monotonic() |
48 |
> + tinterv = 2 # seconds |
49 |
> + ninterv = tnow + tinterv |
50 |
> + falign = len("%d" % totfiles) |
51 |
> showMessage(_(" %s checking %d files for package collisions\n") % \ |
52 |
> (colorize("GOOD", "*"), totfiles)) |
53 |
> for i, (f, f_type) in enumerate(chain( |
54 |
> ((f, "reg") for f in file_list), |
55 |
> ((f, "sym") for f in symlink_list))): |
56 |
> - if i % 1000 == 0 and i != 0: |
57 |
> - showMessage(_("%d files remaining ...\n") % (totfiles - i)) |
58 |
> + if monotonic() > ninterv: |
59 |
> + showMessage(_("%3d%% done, %*d files remaining ...\n") % |
60 |
> + (falign, i * 100 / totfiles, totfiles - i)) |
61 |
> + ninterv = monotonic() + tinterv |
62 |
> |
63 |
> dest_path = normalize_path( |
64 |
> os.path.join(destroot, f.lstrip(os.path.sep))) |
65 |
> @@ -3570,6 +3577,8 @@ class dblink(object): |
66 |
> break |
67 |
> if stopmerge: |
68 |
> collisions.append(f) |
69 |
> + if tnow + tinterv < ninterv: |
70 |
> + showMessage(_("100% done\n")) |
71 |
|
72 |
It took me a moment to understand the calculation here. How about if we |
73 |
do something like this instead: |
74 |
|
75 |
|
76 |
previous = monotonic() |
77 |
progress_shown = False |
78 |
|
79 |
for f in files: |
80 |
current = monotonic() |
81 |
if current - previous > tinterv: |
82 |
showMessage(...) |
83 |
previous = current |
84 |
progress_shown = True |
85 |
|
86 |
if progress_shown: |
87 |
showMessage(_("100% done\n")) |
88 |
|
89 |
|
90 |
|
91 |
> return collisions, dirs_ro, symlink_collisions, plib_collisions |
92 |
> |
93 |
> def _lstat_inode_map(self, path_iter): |
94 |
> |
95 |
|
96 |
|
97 |
-- |
98 |
Thanks, |
99 |
Zac |