Compbench
An exhaustive benchmark for Btrfs transparent compression
Install / Use
/learn @robindubreuil/CompbenchREADME
An exhaustive benchmark for Btrfs transparent compression
Compbench is a comprehensive Python tool designed to evaluate and compare the performance of Btrfs transparent compression algorithms. It allows you to benchmark different compression methods (e.g., zstd, lzo, none) under various conditions, providing detailed metrics and comparative results—all while offering a user-friendly interface with a minimal output mode for beginners.
Features
-
Exhaustive Testing:
Test a full range of zstd levels (configurable with--max-zstd), as well as lzo and no compression. -
Repeatable Benchmarks:
Repeat the entire test sequence multiple times (-n/--repeat) to obtain averaged, reliable results. -
Force Mode Options:
Use standardcompressor forcecompress-forcemodes (via-f/--forcewith optionsnone,zstd,lzo,all, orboth).
When--force bothis selected, the tool runs each test twice (standard and force) and compares the results. -
HDD Testing:
Optionally test on specific zones of a disk using the--hddparameter (e.g., first and last n% of the disk) to evaluate spatial performance variations. -
RAM Estimation & Warning:
Before starting, the script estimates the required RAM based on the decompressed size of the archive and warns the user if available memory might be insufficient. The script also calculates the total volume of data that will be written to the target disk (based on the decompressed archive size and the number of tests) and warns the user accordingly. -
Synchronized Writes Option:
An optional sync mode can be enabled (using an extra argument, e.g.,-s) to wait until the disk is fully synchronized before measuring performance. This reflects more realistic write performance. -
Minimal & Verbose Modes:
In non-verbose mode, the script updates the status on a single line to provide a clean, minimal interface. Verbose mode (-v/--verbose) displays detailed logs. -
Detailed Results & CSV Export:
Final results include throughput, compression ratios, CPU load, and best-case summaries. In--force bothmode, a comparison table shows percentage differences between standard and force variants. All results, along with archive metadata, can be exported to CSV.
Installation
To install the latest Compbench Debian package on your Debian/Ubuntu system, follow these steps:
-
Download the Package:
Download the latest.debfile from the GitHub Releases page. -
Install the Package:
Open a terminal, navigate to the directory containing the downloaded package, and run:sudo dpkg -i compbench_1.0rc1-1_all.deb -
Fix Missing Dependencies (if necessary):
If any dependencies are missing, run:sudo apt-get install -f -
Usage:
Once installed, you can run Compbench by simply executing:compbench --help
Note: Replace compbench_1.0rc1-1_all.deb with the actual name of the package if it differs.
Requirements
System Packages (Debian 12)
sudo apt update && sudo apt install python3 python3-psutil xz-utils pv btrfs-progs btrfs-compsize gdisk
Note:
Thetarandblockdevcommands (provided byutil-linux) are usually installed by default.
Python Modules
- psutil
Install viapip install psutilif not available.
Usage
Warning:
This script formats the specified disk, erasing all existing data.
Use it on a test disk or in a controlled environment.
Basic Command
sudo compbench /dev/sdX https://example.com/archive.tar.xz
Command-Line Options
-
-v, --verbose
Enable detailed logging output. -
-n, --repeat <number>
Number of times to repeat the test sequence (default: 1). -
--max-zstd <level>
Maximum zstd level to test (default: 15). -
-f, --force <option>
Force option for compression mode. Options:none(default): Use standardcompressfor all tests.zstd: Usecompress-forcefor zstd tests only.lzo: Usecompress-forcefor lzo tests only.all: Forcecompress-forcefor all tests.both: Run tests twice (standard and force mode) for comparison.
-
--hdd <percentage>
Specify the percentage of the disk to use for each partition (between 1 and 50).
For example,--hdd 10tests on the first 10% and last 10% of the disk. -
--nointegritycheck
Skip the integrity check of the xz archive. -
-s, --sync
Measure performance after forcing disk synchronization (usingsync), providing lower throughput numbers that better reflect real-world write performance.
Example
sudo compbench /dev/sdX https://example.com/archive.tar.xz -n 3 --max-zstd 10 -f both --hdd 10 -v
This command will:
- Test on
/dev/sdXusing the archive from the given URL. - Repeat the entire sequence 3 times.
- Test zstd compression levels from 10 down to 1, plus lzo and no compression.
- Run each test twice (standard and force mode), and compare the two.
- Partition the disk to test on the first and last 10%.
- Run in verbose mode.
How It Works
-
Preparation:
The script downloads the archive and, if possible, checks its size via an HTTP HEAD request (or usingfile://for local files). It estimates the required RAM based on the decompressed size and warns the user if available memory may be insufficient. -
Extraction:
The archive is extracted into a tmpfs (RAM disk) sized according to the decompressed data, ensuring a consistent, isolated dataset for testing. -
Testing:
The script formats the target disk (or partitions in HDD mode), mounts it with Btrfs using the chosen compression options, and copies data from the tmpfs while measuring throughput, CPU load, and disk usage (viacompsize). -
Results & Comparison:
Results are aggregated and averaged (if tests are repeated) and displayed in detailed tables. In--force bothmode, additional tables compare standard vs. force modes, highlighting percentage differences. -
CSV Export:
All results and metadata (archive URL, decompressed size, archive size, overall compression factor, and test parameters) can be exported to a CSV file. -
Minimal Interface:
In non-verbose mode, progress is shown as a single, updating line (e.g., "Downloading archive...") so that the output remains clean. Detailed results are displayed at the end.
Contributing
Contributions, bug reports, and suggestions are welcome! Please open an issue or submit a pull request on GitHub.
License
This project is licensed under the GNU GPL v3 License.
Related Skills
node-connect
344.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
96.8kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
344.1kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
344.1kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
