Commit graph

72 commits

Author SHA1 Message Date
Yorhel
b0d4fbe94f Rename threading flag to -t,--threads + update man page 2024-07-18 07:49:41 +02:00
Yorhel
e5508ba9b4 Fix OOM handling to be thread-safe 2024-07-17 11:48:58 +02:00
Yorhel
7558fd7f8e Re-add single-threaded JSON export
That was the easy part, next up is fixing multi-threaded JSON export.
2024-07-17 07:05:18 +02:00
Yorhel
d2e8dd8a90 Reimplement JSON import + minor fixes
Previous import code did not correctly handle a non-empty directory with
the "read_error" flag set. I have no clue if that can ever happen in
practice, but at least ncdu 1.x can theoretically emit such JSON so we
handle it now.

Also fixes mtime display of "special" files. i.e. don't display the
mtime of the parent directory - that's confusing.

Split a generic-ish JSON parser out of the import code for easier
reasoning and implemented a few more performance improvements as well.
New code is ~30% faster in both ReleaseSafe and ReleaseFast.
2024-07-16 14:20:30 +02:00
Yorhel
cc12c90dbc Re-add scan progress UI + directory refreshing 2024-07-14 20:17:19 +02:00
Yorhel
f2541d42ba Rewrite scan/import code, experiment with multithreaded scanning (again)
Benchmarks are looking very promising this time. This commit breaks a
lot, though:
- Hard link counting
- Refreshing
- JSON import
- JSON export
- Progress UI
- OOM handling is not thread-safe

All of which needs to be reimplemented and fixed again. Also haven't
really tested this code very well yet so there's likely to be bugs.

There's also a behavioral change: --exclude-kernfs is not checked on the
given root directory anymore, meaning that the filesystem the user asked
to scan is being scanned even if that's a 'kernfs'. I suspect that's
more sensible behavior.

The old scan.zig was quite messy and hard for me to reason about and
extend, this new sink API is looking to be less confusing. I hope it
stays that way as more features are added.
2024-07-14 20:17:18 +02:00
Yorhel
2f97601736 Don't complain about stdin with --quit-ater-scan
That flag is for benchmarking, we're not expecting to have user input.
2024-07-13 09:05:47 +02:00
Yorhel
d0d064aaf9 Version 2.4 2024-04-21 10:58:35 +02:00
Yorhel
d60bcb2113 Copyright: remove year & use alias
Tired of bumping files every year and slowly moving stuff to my alias.
2024-04-20 15:49:51 +02:00
Yorhel
e1818430b7 Set default --color to "off" 2024-04-20 15:45:37 +02:00
Eric Joldasov
946d2a0316
src: update to standard library changes in Zig 0.12.0-dev.3385+3a836b480
* rearrangment of entries in `std.os` and `std.c`, `std.posix`
 finally extracted in https://github.com/ziglang/zig/pull/19354 .

Signed-off-by: Eric Joldasov <bratishkaerik@landless-city.net>
2024-03-20 23:06:20 +05:00
Eric Joldasov
c83159f076
fix new "var never mutated" error on Zig 0.12.0-dev.1663+6b1a823b2
Fixes these errors (introduced in https://github.com/ziglang/zig/pull/18017
and 6b1a823b2b ):

```
src/main.zig:290:13: error: local variable is never mutated
        var line_ = line_fbs.getWritten();
            ^~~~~
src/main.zig:290:13: note: consider using 'const'
src/main.zig:450:17: error: local variable is never mutated
            var path = std.fs.path.joinZ(allocator, &.{p, "ncdu", "config"}) catch unreachable;
                ^~~~
src/main.zig:450:17: note: consider using 'const'

...
```

Will be included in future Zig 0.12, this fix is backward compatible:
ncdu still builds and runs fine on Zig 0.11.0.

Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-11-20 14:45:02 +06:00
Yorhel
a71bc6eca5 Add --quit-after-scan CLI flag for benchmarking 2023-08-08 10:30:33 +02:00
Yorhel
ec99218645 Version 2.3 2023-08-04 16:05:31 +02:00
Eric Joldasov
ab6dc5be75
Update to Zig 0.11.0
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-08-04 14:41:49 +06:00
Yorhel
46b88bcb5c Add --(enable|disable)-natsort options 2023-03-05 08:31:31 +01:00
Yorhel
ec233ff33a Version 2.2.2 + copyright year bump 2023-01-19 08:00:27 +01:00
Yorhel
cebaaf0972 Minor doc formatting fix & error message fix 2023-01-11 08:42:54 +01:00
Yorhel
1452b91032 Some fixes for building with Zig stage2
Building is currently broken on packed struct alignment issues. :/
2022-10-26 13:34:27 +02:00
Yorhel
f7e774ee6e Fixes for stdlib changes 2022-10-26 13:34:06 +02:00
Yorhel
f37362af36 Version 2.2.1 2022-10-25 08:14:36 +02:00
Yorhel
34dafffc62 Version 2.2 2022-10-17 12:37:59 +02:00
Yorhel
d523a77fdc Improve exclude pattern matching performance (and behavior, a bit)
Behavioral changes:
- A single wildcard ('*') does not cross directory boundary anymore.
  Previously 'a*b' would also match 'a/b', but no other tool that I am
  aware of matches paths that way. This change breaks compatibility with
  old exclude patterns but improves consistency with other tools.
- Patterns with a trailing '/' now prevent recursing into the directory.
  Previously any directory excluded with such a pattern would show up as
  a regular directory with all its contents excluded, but now the
  directory entry itself shows up as excluded.
- If the path given to ncdu matches one of the exclude patterns, the old
  implementation would exclude every file/dir being read, this new
  implementation would instead ignore the rule. Not quite sure how to
  best handle this case, perhaps just exit with an error message?

Performance wise, I haven't yet found a scenario where this
implementation is slower than the old one and it's *significantly*
faster in some cases - in particular when using a large amount of
patterns, especially with literal paths and file names.

That's not to say this implementation is anywhere near optimal:
- A list of relevant patterns is constructed for each directory being
  scanned. It may be possible to merge pattern lists that share
  the same prefix, which could both reduce memory use and the number of
  patterns that need to be matched upon entering a directory.
- A hash table with dynamic arrays as values is just garbage from a
  memory allocation point of view.
- This still uses libc fnmatch(), but there's an opportunity to
  precompile patterns for faster matching.
2022-08-10 09:46:39 +02:00
Yorhel
f0764ea24e Fix unreferenced test in model.zig
The other files were already indirectly referenced, but it's good to
make it explicit.
2022-08-08 18:23:53 +02:00
Yorhel
e6806059e6 Version 2.1.2 2022-04-28 11:19:43 +02:00
Yorhel
2e4f0f0bce Version 2.1.1 2022-03-25 12:38:47 +01:00
Yorhel
3942722eba Revert default --graph-style to "hash"
Because, even in 2022, there are systems where the libc locale is not,
in fact, UTF-8. Fixes #186.
2022-03-16 09:53:02 +01:00
Yorhel
1a3de55e68 Still accept "eigth-block" typo argument for compat 2022-03-14 15:58:41 +01:00
Phil Jones
1f46dacf12 Fix typo in --graph-style option
Change "eigth-block" to "eighth-block"
2022-03-14 13:31:01 +00:00
Yorhel
35dd631e55 Version 2.1; remove 1.x changes from the ChangeLog 2022-02-07 13:59:22 +01:00
Yorhel
7d2905952d Add --graph-style option and Unicode graph drawing
And also adjust the graph width calculation to do a better job when the
largest item is smaller than the number of columns used for the graph,
which would previously draw either nothing (if size = 0) or a full bar
(if size > 0).

Fixes #172.
2022-02-03 16:10:18 +01:00
Yorhel
41f7ecafcb Mention --ignore-config flag when reading config fails 2022-02-02 12:32:41 +01:00
Yorhel
f46c7ec65d Ignore ENOTDIR when trying to open config files 2022-02-02 11:49:04 +01:00
Yorhel
01f1e9188a Version 2.0.1 + copyright year bump 2022-01-01 16:01:47 +01:00
Yorhel
23c59f2874 Version 2.0
I'm tagging this as a "stable" 2.0 release because the 2.0-beta#
numbering will get confusing when I'm working on new features and fixes.
It's still only usable for people who can use the particular Zig version
that's required (0.9.0 currently) and it will certainly break on
different Zig versions. But once you have a working binary for a
supported arch, it's perfectly stable.
2021-12-21 10:56:51 +01:00
Yorhel
6a68cd9b89 Fixes and updates for Zig 0.9.0 2021-12-21 10:34:44 +01:00
Yorhel
14b90444c9 Version 2.0-beta3 2021-11-09 09:11:35 +01:00
Yorhel
90873ef956 Fix defaults of scan_ui and --enable-* flags
Bit pointless to make these options nullable when you never assign null
to them.
2021-10-06 15:32:49 +02:00
Yorhel
fdb93bb9e6 Fix use-after-free in argument parsing
Introduced in 53d3e4c112
2021-10-06 14:06:50 +02:00
Yorhel
d1adcde15c Add --ignore-config command line option 2021-10-06 13:59:14 +02:00
Yorhel
39a137c132 Add reference to "man ncdu" in --help text
Not going to bloat the help output with all those settings...
2021-10-06 13:52:08 +02:00
Yorhel
53d3e4c112 Make argument parsing code non-generic and simplify config file parsing
Saves about 15k on the binary size. It does allocate a bit more, but it
also frees the memory this time.
2021-10-06 11:52:37 +02:00
Yorhel
4b1da95835 Add configuration file support 2021-10-06 11:05:56 +02:00
Yorhel
88c8f13c35 Add CLI options for default sort 2021-10-06 09:21:13 +02:00
Yorhel
900d31f6fd Add CLI options for all UI settings
+ reorder manpage a bit, since the scan options tend to be more relevant
than all those UI options.

Again, these are mainly useful with a config file.
2021-10-05 17:17:01 +02:00
Yorhel
b3c6f0f48a Add CLI options for individual -r features and to counter previous options
The --enable-* options also work for imported files, this fixes #120.

Most other options are not super useful on its own, but these will be
useful when there's a config file.
2021-10-05 16:27:23 +02:00
Yorhel
bfead635e4 Don't enable -x by default
That was an oversight. Especially useless when there's no option to
disable -x.
2021-09-28 17:56:09 +02:00
Yorhel
f448e8ea67 Add dark-bg color scheme + enable colors by default if !NO_COLOR
Same thing as commit 376aad0d35 in the C
version.
2021-08-16 16:33:23 +02:00
Yorhel
1de70064e7 Version 2.0-beta2 + more convenient static binary generation 2021-07-31 07:14:04 +02:00
Yorhel
36bc405a69 Add parent node pointers to Dir struct + remove Parents abstraction
While this simplifies the code a bit, it's a regression in the sense
that it increases memory use.

This commit is yak shaving for another hard link counting approach I'd
like to try out, which should be a *LOT* less memory hungry compared to
the current approach. Even though it does, indeed, add an extra cost of
these parent node pointers.
2021-07-26 14:03:10 +02:00