mbw
Measure memory bandwidth
TLDR
Run 3 memory bandwidth tests with 512MB size
Run 3 memory bandwidth tests with 512MB memory size, output only statistics, not averages
Run memcpy test 3 times with 512MB size, only display statistics
Run the memcpy test 10 times with 1024 byte blocks allocated 8192MB of memory
Run dumb test with 2048MB size, output only statistics, run forever
SYNOPSIS
mbw [OPTIONS] memory_size_in_MB
Example: mbw 1024
Example: mbw -n 5 -a 2048
PARAMETERS
memory_size_in_MB
The size of the memory block in megabytes on which the benchmark will be performed. This is a mandatory argument unless -h or -V is used.
-n
Specifies the number of iterations to run the benchmark. The default is 1.
-a
(all) Runs all available benchmark methods (copy, write, fill) sequentially. If not specified, only memcpy is run by default.
-t
Selects a specific test type.
0: memcpy (default, standard C library copy)
1: memset (standard C library set)
2: memfill (fill memory with a specific pattern)
3: copy_mem_fwd (manual copy forward)
4: copy_mem_bwd (manual copy backward)
5: copy_mem_rand (manual copy with random access)
-b
Sets the block size in MB for each chunk of memory accessed. This affects how much data is processed in one go. Default is typically memory_size_in_MB.
-s
Specifies the stride size in bytes, primarily used with copy_mem_rand to define access patterns.
-o
Outputs results in CSV (Comma Separated Values) format, useful for scripting and data analysis.
-h
Displays a brief help message and exits.
-V
Displays version information and exits.
DESCRIPTION
mbw (Memory Bandwidth Benchmark) is a lightweight command-line utility for Linux systems designed to measure the memory bandwidth performance of a system. It works by performing various memory operations, such as copying, writing, and filling blocks of memory, and then calculates the speed at which these operations can be completed, typically expressed in megabytes per second (MB/s).
This tool is invaluable for system administrators, developers, and hardware enthusiasts who need to quickly assess memory performance, identify potential bottlenecks, or compare the memory throughput across different hardware configurations. While not a substitute for comprehensive benchmark suites, mbw provides a fast and straightforward way to get a snapshot of memory read and write speeds, offering insights into the overall memory subsystem's efficiency and responsiveness. It's particularly useful for diagnosing memory-related performance issues or validating memory upgrades.
CAVEATS
The results from mbw should be interpreted with caution. Memory bandwidth measurements can be significantly influenced by factors such as CPU cache effectiveness (L1, L2, L3), compiler optimizations, the operating system's memory management, and other concurrent processes. mbw provides a synthetic benchmark; therefore, its results may not perfectly reflect real-world application performance, which can depend on specific access patterns and data locality. Ensure sufficient free physical memory is available for the test size to avoid swapping, which would heavily skew results.
INTERPRETING RESULTS
The output of mbw typically shows the method used (e.g., memcpy, memset), the block size, and the calculated memory bandwidth in MB/s. Higher values generally indicate better memory performance. When using -a, multiple lines will be output, one for each method. The copy_mem_rand test can be particularly useful for simulating less sequential memory access patterns.
PERMISSIONS
mbw usually does not require special permissions. It operates within user space, performing standard memory allocation and access operations. However, running it in an environment with restricted memory limits (like a cgroup) might affect results or cause allocation failures.
HISTORY
mbw is a relatively old and stable utility, typically maintained as a standalone open-source project. Its development has focused on providing a simple, quick way to assess memory throughput without complex dependencies. It has been refined over the years to include various access patterns and output options, adapting to different system architectures and performance analysis needs. While not part of the core Linux utilities, it's widely available in many distributions' repositories due to its utility in system diagnostics and benchmarking.