1 |
On 08/01/19 19:15, Zac Medico wrote: |
2 |
> On 1/8/19 5:42 AM, Fabian Groffen wrote: |
3 |
>> The reporting of files remaining can look somewhat odd since the report |
4 |
>> interval is hardcoded to be per 1000 objects. Adjust this interval to |
5 |
>> be time based. This means that modern (fast) machines likely will never |
6 |
>> see the countdown messages at all. On slow setups the message will be |
7 |
>> informative that there is progress, albeit rather slowly. While at it, |
8 |
>> report percentage done. |
9 |
>> |
10 |
>> Output before this patch: |
11 |
>> |
12 |
>> * checking 6158 files for package collisions |
13 |
>> 5158 files remaining ... |
14 |
>> 4158 files remaining ... |
15 |
>> 3158 files remaining ... |
16 |
>> 2158 files remaining ... |
17 |
>> 1158 files remaining ... |
18 |
>> 158 files remaining ... |
19 |
>> |
20 |
>> Possible output after this patch on a slower machine: |
21 |
>> |
22 |
>> * checking 6158 files for package collisions |
23 |
>> 48% done, 3145 files remaining ... |
24 |
>> 96% done, 192 files remaining ... |
25 |
>> 100% done |
26 |
>> |
27 |
>> Signed-off-by: Fabian Groffen <grobian@g.o> |
28 |
>> --- |
29 |
>> lib/portage/dbapi/vartree.py | 11 +++++++++-- |
30 |
>> 1 file changed, 9 insertions(+), 2 deletions(-) |
31 |
>> |
32 |
>> diff --git a/lib/portage/dbapi/vartree.py b/lib/portage/dbapi/vartree.py |
33 |
>> index 4b91caea8..244195fad 100644 |
34 |
>> --- a/lib/portage/dbapi/vartree.py |
35 |
>> +++ b/lib/portage/dbapi/vartree.py |
36 |
>> @@ -3475,13 +3475,18 @@ class dblink(object): |
37 |
>> symlink_collisions = [] |
38 |
>> destroot = self.settings['ROOT'] |
39 |
>> totfiles = len(file_list) + len(symlink_list) |
40 |
>> + tnow = time.time() |
41 |
>> + tinterv = 2 # seconds |
42 |
>> + ninterv = tnow + tinterv |
43 |
>> showMessage(_(" %s checking %d files for package collisions\n") % \ |
44 |
>> (colorize("GOOD", "*"), totfiles)) |
45 |
>> for i, (f, f_type) in enumerate(chain( |
46 |
>> ((f, "reg") for f in file_list), |
47 |
>> ((f, "sym") for f in symlink_list))): |
48 |
>> - if i % 1000 == 0 and i != 0: |
49 |
>> - showMessage(_("%d files remaining ...\n") % (totfiles - i)) |
50 |
>> + if time.time() > ninterv: |
51 |
>> + showMessage(_("%3d%% done, %d files remaining ...\n") % |
52 |
>> + (i * 100 / totfiles, totfiles - i)) |
53 |
>> + ninterv = time.time() + tinterv |
54 |
>> |
55 |
>> dest_path = normalize_path( |
56 |
>> os.path.join(destroot, f.lstrip(os.path.sep))) |
57 |
>> @@ -3570,6 +3575,8 @@ class dblink(object): |
58 |
>> break |
59 |
>> if stopmerge: |
60 |
>> collisions.append(f) |
61 |
>> + if tnow + tinterv < ninterv: |
62 |
>> + showMessage(_("100% done\n")) |
63 |
>> return collisions, dirs_ro, symlink_collisions, plib_collisions |
64 |
>> |
65 |
>> def _lstat_inode_map(self, path_iter): |
66 |
>> |
67 |
> Please replace time.time() with portage.util.monotonic.monotonic(). |
68 |
It's a bit of a nit-pick, granted, but can we ensure that the count-down's |
69 |
remain padded/justified such that the numbers line up for easy at-a-glance |
70 |
inspection ? The optimal standard looks somewhat like the pre-merge Sizes: |
71 |
|
72 |
* Final size of build directory: 2696 KiB (2.6 MiB) |
73 |
* Final size of installed tree: 5372 KiB (5.2 MiB) |
74 |
|
75 |
Otherwise, I think this will be quite helpful. Thanks. |