Skip to content

create --progress: show big sizes with more decimals, fixes #3559 - #10088

Merged
ThomasWaldmann merged 1 commit into
borgbackup:masterfrom
ThomasWaldmann:progress-digits-3559
Aug 12, 2026
Merged

create --progress: show big sizes with more decimals, fixes #3559#10088
ThomasWaldmann merged 1 commit into
borgbackup:masterfrom
ThomasWaldmann:progress-digits-3559

Conversation

@ThomasWaldmann

Copy link
Copy Markdown
Member

Fixes #3559.

At TB scale, the sizes in the borg create --progress status line only changed every 10GB, so
one could not tell whether it was still making progress (the more so when running from cron and
not seeing the beginning of the run).

Formatting

format_file_size (and the sizeof_fmt* helpers) got a fine=False option that gives big sizes
a scale dependent precision, so that changes of ~1MB stay visible:

size default fine=True
1234567 1.23 MB 1.23 MB
10**9 1.00 GB 1.000 GB
5000001000000 5.00 TB 5.000001 TB
5*10**15 + 10**6 5.00 PB 5.000000001 PB

Decimals are capped at 9 - a float can not resolve more anyway, and it bounds the output width.

Unit selection is deliberately unchanged (the rounding guard still uses the base precision), so
a size is never shown with a different unit than before. As a consequence, 999999000000 shows
as 0.999999 TB where the default format rounds to 1.00 TB - the value is exact, the unit is
the same. There is a test for it.

Status line

@ThomasWaldmann noted in the issue that more digits shrink the space left for the path, which is
a problem at 80 columns, and that increasing the digits only for much wider terminals would be
the way to go. So:

  • on a terminal, the precise format is only used at >= 110 columns. fine adds at most 7 chars
    per size field, i.e. 14 for both, so even in the worst case the path still gets more room than
    it had at 80 columns with the compact format. It is re-evaluated on every refresh, so resizing
    the terminal degrades gracefully.
  • if the output does not go to a terminal (e.g. into a logfile), the precise format is always
    used - there is no width limit there.
  • the JSON progress output is unchanged (it has raw byte values anyway).

At 80 columns nothing changes:

5.00 TB O 1.57 TB U 362508 N mnt/to_backup/oct/some...her_long_filename_here.bin

At 110 columns, 1MB steps become visible:

5.000000 TB O 1.570000 TB U 362508 N mnt/to_backup/oct/some_rather_long_filename_here.bin
5.000001 TB O 1.570000 TB U 362508 N mnt/to_backup/oct/some_rather_long_filename_here.bin
5.000002 TB O 1.570000 TB U 362508 N mnt/to_backup/oct/some_rather_long_filename_here.bin

--stats / borg info / all other size output keep the default 2 decimals (fine defaults to
False, and Statistics.osize_fmt/usize_fmt are untouched).

…p#3559

At TB scale, the sizes shown by "borg create --progress" only changed
every 10GB, so one could not tell whether it was still making progress.

format_file_size (and the sizeof_fmt* helpers) now have a "fine" option
giving big sizes a scale dependent precision, so that changes of ~1MB
stay visible: GB: 3, TB: 6, PB: 9 decimals (capped at 9, a float can not
resolve more anyway). Unit selection is not affected, so a size is always
shown with the same unit as before.

More decimals eat into the space left for the path, so on a terminal they
are only used if it is at least 110 columns wide - even in the worst case,
that still leaves more room for the path than 80 columns did before. If
the output does not go to a terminal (e.g. into a logfile), the precise
format is always used. The JSON progress output is unchanged.
@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.78%. Comparing base (bf6a449) to head (98b8b4f).
⚠️ Report is 5 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #10088   +/-   ##
=======================================
  Coverage   86.77%   86.78%           
=======================================
  Files          98       98           
  Lines       17277    17285    +8     
  Branches     2622     2623    +1     
=======================================
+ Hits        14992    15000    +8     
  Misses       1587     1587           
  Partials      698      698           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@ThomasWaldmann ThomasWaldmann added this to the 2.0.0b23 milestone Aug 12, 2026
@ThomasWaldmann ThomasWaldmann self-assigned this Aug 12, 2026
@ThomasWaldmann
ThomasWaldmann merged commit 654fbb2 into borgbackup:master Aug 12, 2026
20 checks passed
@ThomasWaldmann
ThomasWaldmann deleted the progress-digits-3559 branch August 12, 2026 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

resolution of status display in create - make MB visible

1 participant