From b0d4fbe94f94ae13efaf5243f52721798cc6e35e Mon Sep 17 00:00:00 2001 From: Yorhel Date: Thu, 18 Jul 2024 07:49:41 +0200 Subject: [PATCH] Rename threading flag to -t,--threads + update man page --- ncdu.1 | 16 +++++++++++++--- src/main.zig | 5 ++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/ncdu.1 b/ncdu.1 index e6b3769..edde33b 100644 --- a/ncdu.1 +++ b/ncdu.1 @@ -18,6 +18,7 @@ .Op Fl \-include\-caches , \-exclude\-caches .Op Fl L , \-follow\-symlinks , \-no\-follow\-symlinks .Op Fl \-include\-kernfs , \-exclude\-kernfs +.Op Fl t , \-threads Ar num .Op Fl 0 , 1 , 2 .Op Fl q , \-slow\-ui\-updates , \-fast\-ui\-updates .Op Fl \-enable\-shell , \-disable\-shell @@ -147,6 +148,16 @@ The exact counting behavior of this flag is subject to change in the future. .Pp The complete list of currently known pseudo filesystems is: binfmt, bpf, cgroup, cgroup2, debug, devpts, proc, pstore, security, selinux, sys, trace. +.It Fl t , \-threads Ar num +Number of threads to use when scanning the filesystem, currently defaults to 1. +.Pp +In single-threaded mode, the export function (see +.Fl o ) +can operate with very little memory, but in multi-threaded mode the entire +directory tree is first constructed in memory and written out after the +filesystem scan has completed, +This causes a delay in output and requires significantly more memory for large +directory trees. .El .Ss Interface Options .Bl -tag -width Ds @@ -159,9 +170,8 @@ When exporting the data with ncurses will not be initialized at all. This option is the default when exporting to standard output. .It Fl 1 -Similar to -.Fl 0 , -but does give feedback on the scanning progress with a single line of output. +Write progress information to the terminal, but don't open a full-screen +ncurses interface. This option is the default when exporting to a file. .Pp In some cases, the ncurses browser interface which you'll see after the diff --git a/src/main.zig b/src/main.zig index 88c3871..107f342 100644 --- a/src/main.zig +++ b/src/main.zig @@ -266,6 +266,9 @@ fn argConfig(args: *Args, opt: Args.Option) bool { else if (std.mem.eql(u8, val, "dark")) config.ui_color = .dark else if (std.mem.eql(u8, val, "dark-bg")) config.ui_color = .darkbg else ui.die("Unknown --color option: {s}.\n", .{val}); + } else if (opt.is("-t") or opt.is("--threads")) { + const val = args.arg(); + config.threads = std.fmt.parseInt(u8, val, 10) catch ui.die("Invalid number of --threads: {s}.\n", .{val}); } else return false; return true; } @@ -329,6 +332,7 @@ fn help() noreturn { \\ -v,-V,--version Print version \\ -x Same filesystem \\ -e Enable extended information + \\ -t NUM Number of threads to use \\ -r Read only \\ -o FILE Export scanned directory to FILE \\ -f FILE Import scanned directory from FILE @@ -487,7 +491,6 @@ pub fn main() void { else if (opt.is("-f")) import_file = allocator.dupeZ(u8, args.arg()) catch unreachable else if (opt.is("--ignore-config")) {} else if (opt.is("--quit-after-scan")) quit_after_scan = true // undocumented feature to help with benchmarking scan/import - else if (opt.is("--experimental-threads")) config.threads = std.fmt.parseInt(u8, args.arg(), 10) catch ui.die("Invalid number of threads.\n", .{}) else if (argConfig(&args, opt)) {} else ui.die("Unrecognized option '{s}'.\n", .{opt.val}); }