s3du

command module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 14, 2026 License: MIT Imports: 31 Imported by: 0

README

s3du

du for S3. Scans bucket in parallel, groups by prefix and storage class, keeps everything in a compressed radix-tree snapshot you can re-open without re-paying the list cost.

s3du TUI

Install

# The browser
go install github.com/ochaton/s3du@latest

# Companion: parallel batched delete by prefix (the rm -rf for S3)
go install github.com/ochaton/s3du/cmd/s3rmrf@latest

Or build from source:

git clone https://github.com/ochaton/s3du && cd s3du
go build -o s3du .

Run

# Scan a bucket and drop into the TUI
s3du -bucket my-bucket -i

# Re-open the snapshot without re-scanning (default path resolved automatically)
s3du -bucket my-bucket -load -i

# Snapshot + print stats only
s3du -snapshot path -load -stats

# Tune parallelism, override region
s3du -bucket my-bucket -workers 64 -region us-west-2

AWS credentials come from the env/profile chain (AWS_PROFILE, ~/.aws/credentials, IAM role, etc). The bucket's region is auto-detected via HeadBucket when -region is left blank.

Snapshot

Each scan writes a binary snapshot under the platform's user-cache dir (os.UserCacheDir):

Linux : ~/.cache/s3du/<bucket>@<region>/tree.snap
macOS : ~/Library/Caches/s3du/<bucket>@<region>/tree.snap

Re-open with -load -snapshot <path> — no re-scan, full TUI / -stats / -i flows work against the loaded snapshot.

TUI keybindings

Navigation       Sort                 Display
↑/k  ↓/j         s  by size           g  cycle bar widget
Home  End/G      n  by name           ?  show this help
PgUp PgDn        C  by object count
Enter / l        $  by monthly cost
Bksp / h         t  toggle dirs first
                                       q  quit

g cycles: no bar → bar only (default) → bar + percentage → percentage only. Bar is normalised to the listing total (entries sum to 100%).

Logs

Structured slog logs are off by default — pass -log <path> to enable file logging. SDK retry events (SlowDown, adaptive throttling) surface through the file logger so you can diagnose a scan that goes quiet.

Regenerating demo.gif

The README animation comes from a fully synthetic snapshot — no real bucket data. To re-record:

brew install vhs ffmpeg ttyd   # one-time
go install .                   # current s3du on $PATH
go run ./internal/cmd/gen-demo # writes /tmp/s3du-demo.snap
vhs demo.tape                  # writes demo.gif

The synthetic dataset has ~7 000 objects across datasets/, logs/, archive/, reports/, and misc/ prefixes, mixing STANDARD, STANDARD_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, and ONEZONE_IA storage classes. Total ~370 GiB.

Documentation

Overview

s3du scans an S3 bucket and builds a compressed radix-tree index of every object's key, size, and storage class. The index is snapshotted to disk and can be browsed interactively via the bubbletea TUI.

Directories

Path Synopsis
cmd
s3rmrf command
s3rmrf: parallel batched DeleteObjects under a single non-empty prefix.
s3rmrf: parallel batched DeleteObjects under a single non-empty prefix.
internal
cmd/gen-demo command
gen-demo generates a synthetic radix snapshot for screenshots and demos.
gen-demo generates a synthetic radix snapshot for screenshots and demos.
cmd/radix-bench command
radix-bench loads an S3 listing snapshot (JSONL with key/size/class), builds the radix tree via chained AddBatch calls, and prints structural stats and heap usage.
radix-bench loads an S3 listing snapshot (JSONL with key/size/class), builds the radix tree via chained AddBatch calls, and prints structural stats and heap usage.
cmd/s3du-sim command
s3du-sim drives sim.Strategy implementations against a loaded radix snapshot and prints per-strategy request-count / parallelism summary.
s3du-sim drives sim.Strategy implementations against a loaded radix snapshot and prints per-strategy request-count / parallelism summary.
pricing
Package pricing holds the AWS S3 cost tables s3du applies in the UI and CLI.
Package pricing holds the AWS S3 cost tables s3du applies in the UI and CLI.
progress
Package progress aggregates the live scan/load metrics (atomic counters, EWMAs) and the bubbletea dashboards that visualise them.
Package progress aggregates the live scan/load metrics (atomic counters, EWMAs) and the bubbletea dashboards that visualise them.
Package radix implements an in-memory compressed radix tree (Patricia trie) over full S3 object keys, providing filesystem-style navigation by '/' boundary together with precomputed per-directory aggregates.
Package radix implements an in-memory compressed radix tree (Patricia trie) over full S3 object keys, providing filesystem-style navigation by '/' boundary together with precomputed per-directory aggregates.
Package sim simulates an S3 bucket on top of a radix.Tree, implementing just enough of the ListObjectsV2 surface to drive discovery-strategy comparisons without round-tripping to AWS.
Package sim simulates an S3 bucket on top of a radix.Tree, implementing just enough of the ListObjectsV2 surface to drive discovery-strategy comparisons without round-tripping to AWS.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL