gdu: A Lightning-Fast Disk Usage Analyzer Written in Go, 5x Faster Than du

98 views 0 likes 0 comments 10 minutesOriginalOpen Source

Discover gdu, a blazing-fast disk usage analyzer written in Go that's up to 5x faster than traditional du commands. Features an interactive TUI, intelligent memory management, persistent storage support, and multiple output modes - perfect for system administrators and developers dealing with disk space emergencies.

#GitHub #OpenSource #Go #disk analysis #system tools #performance optimization #command line tools
gdu: A Lightning-Fast Disk Usage Analyzer Written in Go, 5x Faster Than du

As a Java veteran who's been tormented by the Spring ecosystem for years, I was absolutely thrilled when I discovered gdu, a disk analysis tool written in Go! This tool is essentially the Swiss Army knife for system administrators and developers – and I mean the premium version with LED lighting.

What exactly is this magical tool?

In simple terms, gdu is an ultra-fast disk usage analyzer. Imagine your server's disk suddenly fills up completely. The traditional du -sh * command crawls like a snail, while gdu scans through your filesystem like The Flash to quickly identify which directories are secretly devouring your disk space. It's specifically optimized for SSDs to fully leverage parallel processing advantages, though it works perfectly fine on HDDs too (just with less dramatic performance gains).

What excites me most is its interactive interface – not the boring command-line output you'd expect, but a visual interface similar to ncdu. You can navigate with arrow keys, press Enter to dive into directories, and even delete files directly from the interface! This experience is like upgrading from a black-and-white TV to a 4K OLED display.

Installation is refreshingly straightforward

As a Java developer accustomed to Maven dependencies, Go's installation approach feels incredibly liberating. No complex environment setup needed – just download the binary and run:

bash 复制代码
curl -L https://github.com/dundee/gdu/releases/latest/download/gdu_linux_amd64.tgz | tar xz
chmod +x gdu_linux_amd64
mv gdu_linux_amd64 /usr/bin/gdu

Or if you're feeling extra lazy, use Docker:

bash 复制代码
docker run --rm --init --interactive --tty --privileged --volume /:/mnt/root ghcr.io/dundee/gdu /mnt/root

This reminds me of the days spent wrestling with Java environment variables. Go's "compile-and-deploy" philosophy is incredibly developer-friendly!

Core feature highlights

1. Intelligent memory management

What impresses me most about gdu is its memory management strategy. It automatically detects available system memory – completely disabling garbage collection when memory is abundant to achieve maximum speed, and automatically enabling GC when memory is tight. This adaptive approach is far smarter than manually tuning JVM parameters in our Java applications.

Of course, if you're a control freak (like me when optimizing MySQL indexes), you can take manual control:

bash 复制代码
GOGC=200 gdu -g /

2. Persistent storage support

For analyzing massive directories, gdu supports saving analysis data to persistent storage (based on BadgerDB). While this slows things down by roughly 10x, it dramatically reduces memory consumption. This means you can perform a complete analysis once, then reload the results anytime:

bash 复制代码
GOGC=10 gdu -g --use-storage /    # Save analysis data
gdu -r /                          # Reload saved data

3. Flexible output modes

gdu offers three working modes: interactive (default), non-interactive, and export mode. Non-interactive mode is perfect for scripting:

bash 复制代码
gdu -t 10 /                           # Display the 10 largest files
gdu -ps /some/dir                     # Show only total usage
gdu -o- / | gzip -c >report.json.gz   # Export as JSON

Real-world scenarios

As a backend developer who frequently cleans up log files, I find gdu absolutely indispensable. For example, to find the 10 largest files in the /home directory:

bash 复制代码
gdu -t 10 /home

Or if I want to analyze the entire system while ignoring certain system directories:

bash 复制代码
gdu -i /sys,/proc,dev / 

The coolest part? It can display the actual size of Git Annex files, which is particularly useful for teams using Git LFS.

How does it perform?

According to benchmark tests in the README, gdu is nearly 5x faster than traditional du commands in cold cache scenarios, and almost 4x faster in hot cache scenarios! While it's slightly slower than diskus, the rich interactive features make this minor performance trade-off completely worthwhile.

Is it worth learning?

Absolutely! Although I'm a Java developer, gdu's design philosophy has given me valuable insights:

  1. User experience first: Powerful functionality paired with an intuitive interactive interface
  2. Performance-memory balance: The intelligent memory management strategy is worth adopting in other system tools
  3. Configuration flexibility: Supports YAML configuration files to persist user preferences

If I were to rewrite a similar tool in Java, I'd probably use CompletableFuture for asynchronous scanning and JLine for terminal interaction – though the performance would never match Go's, given goroutines' natural advantage in I/O-intensive tasks.

In summary, gdu is a tool that combines both beauty and brains. Whether for daily use or learning Go best practices, it's definitely worth trying. Next time your disk runs low on space, ditch the sluggish du command and give this Go-powered rocket a shot!

Last Updated:2026-01-01 10:02:26

Comments (0)

Post Comment

Loading...
0/500
Loading comments...