A minimal, fast alternative to du -sh
.
diskus
is a very simple program that computes the total size of the current directory. It is a
parallelized version of du -sh
. On my 8-core laptop, it is about ten times faster than du
with
a cold disk cache and more than three times faster with a warm disk cache.
> diskus
14.56 GB (14556806983 bytes)
The following benchmarks have been performed with hyperfine on a moderately large folder (15GB, 100k directories, 400k files). Smaller folders are not really of any interest since all programs would finish in a reasonable time that would not interrupt your workflow.
In addition to du
and diskus
, we also add tin-summer (sn
) and
dust
in our comparison. Both are also written in Rust and provide
much more features than diskus
(check them out!). The optimal number of threads for sn
(-j
option) was
determined via hyperfine --parameter-scan
.
sudo -v
hyperfine --prepare 'sync; echo 3 | sudo tee /proc/sys/vm/drop_caches' \
'diskus' 'sn p -d0 -j8' 'du -sb' 'dust -d0'
(the sudo
/sync
/drop_caches
commands are a way to
clear the filesystem caches between benchmarking runs)
Command | Mean [s] | Min…Max [s] |
---|---|---|
diskus |
1.649 ± 0.009 | 1.640…1.663 |
sn p -d0 -j8 |
9.701 ± 0.067 | 9.598…9.828 |
du -sb |
16.039 ± 0.069 | 15.918…16.152 |
dust -d0 |
19.769 ± 0.285 | 19.564…20.561 |
On a warm disk cache, the differences are smaller:
hyperfine --warmup 5 'diskus' 'sn p -d0 -j8' 'du -sb' 'dust -d0'
Command | Mean [s] | Min…Max [s] |
---|---|---|
diskus |
0.314 ± 0.007 | 0.303…0.329 |
sn p -d0 -j8 |
0.622 ± 0.008 | 0.611…0.634 |
du -sb |
1.130 ± 0.013 | 1.116…1.161 |
dust -d0 |
3.593 ± 0.057 | 3.544…3.743 |
wget "https://github.com/sharkdp/diskus/releases/download/v0.5.0/diskus_0.5.0_amd64.deb"
sudo dpkg -i diskus_0.5.0_amd64.deb
pacman -Syu diskus
Or download diskus-bin from the AUR.
xbps-install diskus
You can install diskus
with Homebrew:
brew install diskus
Or with MacPorts:
sudo port install diskus
pkgman install diskus
nix-env -iA nixos.diskus
Or add it to environment.systemPackages
in your configuration.nix
.
Check out the release page for binary builds.
If you have Rust 1.34 or higher, you can install diskus
from source via cargo
:
cargo install diskus
Windows-internal tools such as Powershell, Explorer or dir
are not respecting hardlinks or
junction points when determining the size of a directory. diskus
does the same and counts
such entries multiple times (on Unix systems, multiple hardlinks to a single file are counted
just once).
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.