DiskBench

Script: diskbench.sh Package: fun Class: DiskBench.java

Benchmarks a disk with multithreaded I/O, testing read, write, and simultaneous read/write performance with configurable data sizes and thread counts.

Basic Usage

diskbench.sh path=<path> data=<8g> passes=<2> threads=<>

Benchmarks disk performance by writing and reading data files in the specified path using multiple threads. The tool measures throughput in MB/s for different I/O patterns.

Parameters

Parameters control the benchmark configuration including data size, thread count, and I/O modes. All parameters from the shell script are documented below.

Core Parameters

path=
Location to read and write test files. Directory will be created if it doesn't exist. Required parameter.
data=8g
Number of bytes to process per pass. Accepts size suffixes (k, m, g). Default is 8 gigabytes. This amount is divided among threads.
threads=
Number of threads to use. By default, uses all logical threads available. In RW mode the number of active threads is doubled (separate read and write threads).
passes=2
Number of benchmark passes to perform after the initial write. Default is 2 passes.
mode=rw
I/O mode for testing:
  • r: Test read speed only
  • w: Test write speed only
  • rw: Test read and write speed simultaneously (default)

Advanced Parameters

lines=
Maximum number of lines to process. Default is unlimited (Long.MAX_VALUE).
verbose=false
Enable verbose output for detailed benchmark information.
gzip=false
Enable gzip compression for test files (note: parameter name maps to verbose internally in current implementation).
read=false
Shortcut to set mode to read-only (equivalent to mode=r).
write=false
Shortcut to set mode to write-only (equivalent to mode=w).
readwrite=false
Shortcut to set mode to simultaneous read/write (equivalent to mode=rw).
printtid=false
Print thread IDs during benchmark execution for debugging.
processbis=false
Enable line processing when using BufferedInputStream methods (splits data into lines).
preread=false
Perform a preliminary read pass before the main benchmark to warm up the disk cache.

I/O Method Parameters

method=
Select the I/O method for reading files. Options:
  • BYTEFILE or bf: Use BBTools ByteFile (default)
  • TEXTFILE or tf: Use BBTools TextFile
  • QUICKFILE or qf: Use BBTools QuickFile
  • BUFFEREDINPUTSTREAM or bis: Use Java BufferedInputStream
  • FILEINPUTSTREAM or fis: Use Java FileInputStream
  • BUFFEREDINPUTSTREAM2 or bis2: BufferedInputStream with ArrayList storage
  • FILEINPUTSTREAM2 or fis2: FileInputStream with ArrayList storage
bytefile=false
Use ByteFile method for I/O (equivalent to method=bf).
textfile=false
Use TextFile method for I/O (equivalent to method=tf).
quickfile=false
Use QuickFile method for I/O (equivalent to method=qf).
bufferedinputstream=false
Use BufferedInputStream method for I/O (equivalent to method=bis).
fileinputstream=false
Use FileInputStream method for I/O (equivalent to method=fis).
bufferedinputstream2=false
Use BufferedInputStream with ArrayList storage (equivalent to method=bis2).
fileinputstream2=false
Use FileInputStream with ArrayList storage (equivalent to method=fis2).
buffer=4096
Buffer size in bytes for stream-based I/O methods. Default is 4096 bytes (4KB).
bufferlen=4096
Alias for buffer parameter. Sets buffer size for stream I/O operations.

Java Parameters

-Xmx
This will set Java's memory usage, overriding autodetection. -Xmx20g will specify 20 gigs of RAM, and -Xmx200m will specify 200 megs. The max is typically 85% of physical memory.
-eoom
This flag will cause the process to exit if an out-of-memory exception occurs. Requires Java 8u92+.
-da
Disable assertions.

Examples

Basic Disk Benchmark

diskbench.sh path=/tmp/benchmark data=1g passes=3

Performs disk benchmarking in /tmp/benchmark with 1GB of data per pass, running 3 passes in read-write mode.

Read-Only Performance Test

diskbench.sh path=/data/test mode=r data=2g threads=8

Tests read performance only with 2GB of data using 8 threads. Files must already exist from a previous write test.

Write-Only Performance Test

diskbench.sh path=/scratch/bench mode=w data=5g passes=1

Tests write performance only with 5GB of data for 1 pass. Useful for testing storage write speeds.

Comparing I/O Methods

diskbench.sh path=/tmp/test method=bis data=500m
diskbench.sh path=/tmp/test method=bf data=500m

Compare performance between BufferedInputStream and ByteFile methods using the same data size.

High-Performance SSD Test

diskbench.sh path=/fast/ssd threads=16 data=10g mode=rw passes=5

Intensive benchmark for high-performance SSDs using 16 threads, 10GB data, simultaneous read/write mode, and 5 passes.

Algorithm Details

Benchmark Architecture

DiskBench implements multithreaded I/O benchmarking through WriteThread and ReadThread classes with the following components:

Thread Management Strategy

Data Generation Algorithm

Write operations implement the writeRandomData() method using ByteStreamWriter and ByteBuilder classes:

Multiple I/O Method Support

The benchmark implements seven different I/O methods through separate run methods in the ReadThread class:

Performance Measurement

File Management

Memory Usage Characteristics

DiskBench implements memory constraints through shell script configuration and buffer management:

Benchmarking Modes Implementation

Performance Implementation Details

Support

For questions and support: