
เครื่องวิเคราะห์การใช้ดิสก์ที่ค่อนข้างเร็วเขียนใน GO
GDU มีไว้สำหรับดิสก์ SSD เป็นหลักซึ่งสามารถใช้ประโยชน์จากการประมวลผลแบบขนานได้อย่างเต็มที่ อย่างไรก็ตาม HDDs ก็ทำงานได้เช่นกัน แต่การได้รับประสิทธิภาพไม่ใหญ่มาก
มุ่งหน้าไปยังหน้ารีลีสและดาวน์โหลดไบนารีสำหรับระบบของคุณ
ใช้ Curl:
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
ดูหน้าการติดตั้งสำหรับวิธีอื่น ๆ วิธีการติดตั้ง GDU เข้ากับระบบของคุณ
หรือคุณสามารถใช้ GDU ได้โดยตรงผ่าน Docker:
docker run --rm --init --interactive --tty --privileged --volume /:/mnt/root ghcr.io/dundee/gdu /mnt/root
gdu [flags] [directory_to_scan]
Flags:
--config-file string Read config from file (default is $HOME/.gdu.yaml)
-g, --const-gc Enable memory garbage collection during analysis with constant level set by GOGC
--enable-profiling Enable collection of profiling data and provide it on http://localhost:6060/debug/pprof/
-L, --follow-symlinks Follow symlinks for files, i.e. show the size of the file to which symlink points to (symlinks to directories are not followed)
-h, --help help for gdu
-i, --ignore-dirs strings Absolute paths to ignore (separated by comma) (default [/proc,/dev,/sys,/run])
-I, --ignore-dirs-pattern strings Absolute path patterns to ignore (separated by comma)
-X, --ignore-from string Read absolute path patterns to ignore from file
-f, --input-file string Import analysis from JSON file
-l, --log-file string Path to a logfile (default "/dev/null")
-m, --max-cores int Set max cores that Gdu will use. 12 cores available (default 12)
-c, --no-color Do not use colorized output
-x, --no-cross Do not cross filesystem boundaries
--no-delete Do not allow deletions
-H, --no-hidden Ignore hidden directories (beginning with dot)
--no-mouse Do not use mouse
--no-prefix Show sizes as raw numbers without any prefixes (SI or binary) in non-interactive mode
-p, --no-progress Do not show progress in non-interactive mode
-u, --no-unicode Do not use Unicode symbols (for size bar)
-n, --non-interactive Do not run in interactive mode
-o, --output-file string Export all info into file as JSON
-r, --read-from-storage Read analysis data from persistent key-value storage
--sequential Use sequential scanning (intended for rotating HDDs)
-a, --show-apparent-size Show apparent size
-d, --show-disks Show all mounted disks
-C, --show-item-count Show number of items in directory
-M, --show-mtime Show latest mtime of items in directory
-B, --show-relative-size Show relative size
--si Show sizes with decimal SI prefixes (kB, MB, GB) instead of binary prefixes (KiB, MiB, GiB)
--storage-path string Path to persistent key-value storage directory (default "/tmp/badger")
-s, --summarize Show only a total in non-interactive mode
-t, --top int Show only top X largest files in non-interactive mode
--use-storage Use persistent key-value storage for analysis data (experimental)
-v, --version Print version
--write-config Write current configuration to file (default is $HOME/.gdu.yaml)
Basic list of actions in interactive mode (show help modal for more):
↑ or k Move cursor up
↓ or j Move cursor down
→ or Enter or l Go to highlighted directory
← or h Go to parent directory
d Delete the selected file or directory
e Empty the selected directory
n Sort by name
s Sort by size
c Show number of items in directory
? Show help modal
gdu # analyze current dir
gdu -a # show apparent size instead of disk usage
gdu --no-delete # prevent write operations
gdu <some_dir_to_analyze> # analyze given dir
gdu -d # show all mounted disks
gdu -l ./gdu.log <some_dir> # write errors to log file
gdu -i /sys,/proc / # ignore some paths
gdu -I '.*[abc]+' # ignore paths by regular pattern
gdu -X ignore_file / # ignore paths by regular patterns from file
gdu -c / # use only white/gray/black colors
gdu -n / # only print stats, do not start interactive mode
gdu -np / # do not show progress, useful when using its output in a script
gdu -nps /some/dir # show only total usage for given dir
gdu -nt 10 / # show top 10 largest files
gdu / > file # write stats to file, do not start interactive mode
gdu -o- / | gzip -c >report.json.gz # write all info to JSON file for later analysis
zcat report.json.gz | gdu -f- # read analysis from file
GOGC=10 gdu -g --use-storage / # use persistent key-value storage for saving analysis data
gdu -r / # read saved analysis data from persistent key-value storage
GDU มีสามโหมด: อินเทอร์แอคทีฟ (ค่าเริ่มต้น), ไม่โต้ตอบและส่งออก
โหมดที่ไม่โต้ตอบจะเริ่มต้นโดยอัตโนมัติเมื่อไม่พบ TTY (โดยใช้ Go-Isatty) ตัวอย่างเช่นหากเอาต์พุตถูกส่งไปยังไฟล์หรือสามารถเริ่มต้นได้อย่างชัดเจนโดยใช้ธง
โหมดส่งออก (FLAG -o ) ส่งออกข้อมูลการใช้งานทั้งหมดเป็น JSON ซึ่งสามารถเปิดได้ในภายหลังโดยใช้ค่าสถานะ -f
การเชื่อมโยงอย่างหนักจะถูกนับเพียงครั้งเดียว
ไฟล์และไดเรกทอรีอาจถูกนำหน้าด้วยธงหนึ่งตัวอักษรที่มีความหมายดังต่อไปนี้:
! เกิดข้อผิดพลาดขณะอ่านไดเรกทอรีนี้
. เกิดข้อผิดพลาดขณะอ่านไดเรกทอรีย่อยขนาดอาจไม่ถูกต้อง
@ ไฟล์คือ symlink หรือซ็อกเก็ต
H ไฟล์เดียวกันถูกนับแล้ว (Hard Link)
e ไดเรกทอรีว่างเปล่า
GDU สามารถอ่าน (และเขียน) ไฟล์การกำหนดค่า YAML
$HOME/.config/gdu/gdu.yaml และ $HOME/.gdu.yaml ได้รับการตรวจสอบเพื่อรับรางวัลไฟล์กำหนดค่าตามค่าเริ่มต้น
ดูรายการทั้งหมดของตัวเลือกการกำหนดค่าทั้งหมด
echo "no-color: true" >> ~/.gdu.yaml
sorting:
by: name // size, name, itemCount, mtime
order: desc
echo "change-cwd: true" >> ~/.gdu.yaml
gdu --write-config
มีวิธีการที่เทอร์มินัลสามารถระบายสีได้ GDU Primitives บางตัว (เช่นข้อความพื้นฐาน) addapt ไปยัง schemas สีที่แตกต่างกัน แต่แถวที่เลือก/ไฮไลต์ไม่ได้
หากรูปลักษณ์เริ่มต้นไม่เพียงพอสามารถเปลี่ยนแปลงได้ในไฟล์กำหนดค่าเช่น:
style:
selected-row:
text-color: black
background-color: "#ff0000"
GDU สามารถลบรายการในพื้นหลังได้ดังนั้นจึงไม่ปิดกั้น UI สำหรับงานเพิ่มเติม เพื่อเปิดใช้งาน:
echo "delete-in-background: true" >> ~/.gdu.yaml
รายการไดเรกทอรีสามารถลบได้ในแบบคู่ขนานซึ่งอาจเพิ่มความเร็วในการลบ เพื่อเปิดใช้งาน:
echo "delete-in-parallel: true" >> ~/.gdu.yaml
GDU พยายามปรับสมดุลประสิทธิภาพและการใช้หน่วยความจำ
เมื่อ GDU ใช้หน่วยความจำน้อยกว่าหน่วยความจำฟรีทั้งหมดของโฮสต์การรวบรวมขยะจะถูกปิดใช้งานในระหว่างขั้นตอนการวิเคราะห์อย่างสมบูรณ์เพื่อให้ได้ความเร็วสูงสุด
มิฉะนั้นจะเปิดใช้งาน GC ยิ่งมีการใช้หน่วยความจำมากขึ้นและยิ่งหน่วยความจำน้อยลงก็จะยิ่งเกิด GC บ่อยขึ้นเท่านั้น
หากคุณต้องการควบคุมการรวบรวมขยะด้วยตนเองคุณสามารถใช้ --const-gc / -g FLAG มันจะเรียกใช้การเก็บขยะในระหว่างขั้นตอนการวิเคราะห์ด้วยระดับความก้าวร้าวอย่างต่อเนื่อง เป็นผลให้การวิเคราะห์จะช้าลงประมาณ 25% และจะใช้หน่วยความจำน้อยลงประมาณ 30% ในการเปลี่ยนระดับคุณสามารถตั้งค่าตัวแปรสภาพแวดล้อม GOGC เพื่อระบุความถี่ของการรวบรวมขยะที่จะเกิดขึ้น ค่าที่ต่ำกว่า (มากกว่า 100) หมายถึง GC จะทำงานบ่อยขึ้น สูงกว่าหมายถึงน้อยลง จำนวนลบจะหยุด GC
ตัวอย่างการรัน GDU ด้วยค่าคงที่ GC แต่ไม่ก้าวร้าวเป็นค่าเริ่มต้น:
GOGC=200 gdu -g /
GDU สามารถจัดเก็บข้อมูลการวิเคราะห์ไปยังที่เก็บค่าคีย์ค่าถาวรแทนเพียงแค่หน่วยความจำ GDU จะทำงานช้าลงมาก (ประมาณ 10x) แต่ควรใช้หน่วยความจำน้อยกว่ามาก (เมื่อใช้ GOGC ขนาดเล็กเช่นกัน) GDU ยังสามารถเปิดข้อมูลอีกครั้งด้วยข้อมูลที่บันทึกไว้ ปัจจุบันมีเพียง BadgerDB เท่านั้นที่ได้รับการสนับสนุนเป็นที่เก็บคีย์-ค่า (ฝัง)
GOGC=10 gdu -g --use-storage / # saves analysis data to key-value storage
gdu -r / # reads just saved data, does not run analysis again
make install-dev-dependencies
make test
GDU สามารถรวบรวมข้อมูลการทำโปรไฟล์เมื่อตั้งค่าสถานะ --enable-profiling ได้ ข้อมูลมีให้ผ่านเซิร์ฟเวอร์ HTTP แบบฝังตัวบน URL http://localhost:6060/debug/pprof/
จากนั้นคุณสามารถใช้เช่น go tool pprof -web http://localhost:6060/debug/pprof/heap เพื่อเปิดโปรไฟล์ HEAP เป็นภาพ SVG ในเว็บเบราว์เซอร์ของคุณ
เกณฑ์มาตรฐานดำเนินการบนไดเรกทอรี 50G (ไดเรกทอรี 100K, ไฟล์ 400K) บน 500 GB SSD โดยใช้ Hyperfine ดูเป้าหมาย benchmark ใน MakeFile สำหรับข้อมูลเพิ่มเติม
แคชระบบไฟล์ถูกล้างโดยใช้ sync; echo 3 | sudo tee /proc/sys/vm/drop_caches
| สั่งการ | วิธี] | นาที [s] | สูงสุด [s] | ญาติ |
|---|---|---|---|---|
diskus ~ | 3.126 ± 0.020 | 3.087 | 3.155 | 1.00 |
gdu -npc ~ | 3.132 ± 0.019 | 3.111 | 3.173 | 1.00 ± 0.01 |
gdu -gnpc ~ | 3.136 ± 0.012 | 3.112 | 3.155 | 1.00 ± 0.01 |
pdu ~ | 3.657 ± 0.013 | 3.641 | 3.677 | 1.17 ± 0.01 |
dust -d0 ~ | 3.933 ± 0.144 | 3.849 | 4.213 | 1.26 ± 0.05 |
dua ~ | 3.994 ± 0.073 | 3.827 | 4.134 | 1.28 ± 0.02 |
gdu -npc --use-storage ~ | 12.812 ± 0.078 | 12.644 | 12.912 | 4.10 ± 0.04 |
du -hs ~ | 14.120 ± 0.213 | 13.969 | 14.703 | 4.52 ± 0.07 |
duc index ~ | 14.567 ± 0.080 | 14.385 | 14.657 | 4.66 ± 0.04 |
ncdu -0 -o /dev/null ~ | 14.963 ± 0.254 | 14.759 | 15.637 | 4.79 ± 0.09 |
| สั่งการ | หมายถึง [MS] | นาที [MS] | สูงสุด [MS] | ญาติ |
|---|---|---|---|---|
pdu ~ | 226.6 ± 3.7 | 219.6 | 231.2 | 1.00 |
diskus ~ | 227.7 ± 5.2 | 221.6 | 239.9 | 1.00 ± 0.03 |
dust -d0 ~ | 400.1 ± 7.1 | 386.7 | 409.4 | 1.77 ± 0.04 |
dua ~ | 444.9 ± 2.4 | 442.4 | 448.9 | 1.96 ± 0.03 |
gdu -npc ~ | 451.3 ± 3.8 | 445.9 | 458.5 | 1.99 ± 0.04 |
gdu -gnpc ~ | 516.1 ± 6.7 | 503.1 | 527.5 | 2.28 ± 0.05 |
du -hs ~ | 905.0 ± 3.9 | 901.2 | 913.4 | 3.99 ± 0.07 |
duc index ~ | 1053.0 ± 5.1 | 1046.2 | 1064.1 | 4.65 ± 0.08 |
ncdu -0 -o /dev/null ~ | 1653.9 ± 5.7 | 2188.9 | 220630 | 7.30 ± 0.12 |
gdu -npc --use-storage ~ | 9754.9 ± 688.7 | 8403.8 | 10427.4 | 43.04 ± 3.12 |
C (LTS) หรือ zig (เสถียร)Rust พร้อมอินเทอร์เฟซคล้ายกับ GDU (และ NCDU)RustRust แสดงต้นไม้เช่นโครงสร้างของการใช้ดิสก์Rust แสดงต้นไม้เช่นโครงสร้างของการใช้ดิสก์ ไอคอน HDD ที่สร้างโดย Nikita Golubev - Flaticon