From 02a777f9c422d3b5ec895078530bb1a2b6f7bdf5 Mon Sep 17 00:00:00 2001 From: Lasse Collin Date: Fri, 19 Aug 2022 23:32:22 +0300 Subject: [PATCH] xz: Revise --info-memory output. The strings could be more descriptive but it's good to have some version of this committed now. --robot mode wasn't changed yet. --- src/xz/hardware.c | 32 ++++++++++++++++++++++++++------ src/xz/xz.1 | 1 + 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/xz/hardware.c b/src/xz/hardware.c index 986d0c1b..8f6a86e4 100644 --- a/src/xz/hardware.c +++ b/src/xz/hardware.c @@ -222,9 +222,9 @@ memlimit_show(const char *str, size_t str_columns, uint64_t value) // is 0 or UINT64_MAX. This might get a bit more complex once there // is threading support. See the comment in hardware_memlimit_get(). if (value == 0 || value == UINT64_MAX) - printf("%-*s %s\n", fw, str, _("Disabled")); + printf(" %-*s %s\n", fw, str, _("Disabled")); else - printf("%-*s %s MiB (%s B)\n", fw, str, + printf(" %-*s %s MiB (%s B)\n", fw, str, uint64_to_str(round_up_to_mib(value), 0), uint64_to_str(value, 1)); @@ -241,8 +241,11 @@ hardware_memlimit_show(void) } else { const char *msgs[] = { _("Amount of physical memory (RAM):"), - _("Memory usage limit for compression:"), - _("Memory usage limit for decompression:"), + _("Number of processor threads:"), + _("Compression:"), + _("Decompression:"), + _("Multi-threaded decompression:"), + _("Default for -T0:"), }; size_t width_max = 1; @@ -260,9 +263,26 @@ hardware_memlimit_show(void) width_max = w; } + uint32_t cputhreads = 1; +#ifdef MYTHREAD_ENABLED + cputhreads = lzma_cputhreads(); + if (cputhreads == 0) + cputhreads = 1; +#endif + + puts(_("Hardware information:")); memlimit_show(msgs[0], width_max, total_ram); - memlimit_show(msgs[1], width_max, memlimit_compress); - memlimit_show(msgs[2], width_max, memlimit_decompress); + printf(" %-*s %" PRIu32 "\n", + tuklib_mbstr_fw(msgs[1], (int)(width_max)), + msgs[1], cputhreads); + + putchar('\n'); + puts(_("Memory usage limits:")); + memlimit_show(msgs[2], width_max, memlimit_compress); + memlimit_show(msgs[3], width_max, memlimit_decompress); + memlimit_show(msgs[4], width_max, + hardware_memlimit_mtdec_get()); + memlimit_show(msgs[5], width_max, memlimit_mt_default); } tuklib_exit(E_SUCCESS, E_ERROR, message_verbosity_get() != V_SILENT); diff --git a/src/xz/xz.1 b/src/xz/xz.1 index 5fe4690e..7187b41e 100644 --- a/src/xz/xz.1 +++ b/src/xz/xz.1 @@ -1867,6 +1867,7 @@ for details. .TP .B \-\-info\-memory Display, in human-readable format, how much physical memory (RAM) +and how many processor threads .B xz thinks the system has and the memory usage limits for compression and decompression, and exit successfully.