Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

Hackbench is a Linux scheduler and interprocess-communication (IPC) benchmark that also acts as a stress test. It times a workload in which many processes or threads exchange data through pipes or Unix-domain socket pairs. Use it to compare the same workload across controlled kernel or system configurations—not as a general score for a computer’s overall performance.

What Hackbench measures—and what it doesn’t

Hackbench times a communication-heavy workload that makes the Linux kernel create and schedule runnable tasks, switch between them, and coordinate data transfers. Depending on the implementation and options, it also exercises process or thread management, file-descriptor handling, and activity across CPUs.

That makes Hackbench useful for relative comparisons, such as testing whether a kernel change affects a particular scheduler-and-IPC workload. It is not a pure scheduler measurement: IPC costs, CPU topology, system load, virtualization, power management, and other factors affect the result. Nor is it a general CPU, memory, storage, or application benchmark.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

It is both a benchmark and a stress test. The elapsed time supports comparisons, while the workload can place substantial demand on tasks, CPUs, and file descriptors. Avoid running a heavy test on a production host if that load could disrupt services.

Standalone Hackbench and perf bench sched messaging

“Hackbench” can mean the standalone hackbench program or the related benchmark built into Linux’s perf tool. The standalone manual describes Hackbench as a scheduler benchmark and stress test. The perf bench documentation describes sched messaging as a benchmark based on Hackbench.

They are related, but their options, defaults, workload construction, and output need not match. Keep results from the two implementations in separate series unless you have verified that the workloads are equivalent.

Choose When it fits
Standalone hackbench You need the traditional command, options such as payload size or file descriptors, or compatibility with a test that explicitly uses it.
perf bench sched messaging You already have perf, want its repeat or output-format controls, or plan to use perf for measurement and analysis.
LKP tests You need a broader, automated kernel-performance testing workflow with parameterized jobs and result collection; see Intel’s LKP tests.

How the workload works

Conceptually, sender and receiver tasks exchange data over an IPC channel, repeatedly, while many such tasks or groups run as a workload:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sender process/thread  <── IPC channel ──>  receiver process/thread
        └──────────── repeated communication ────────────┘

Standalone Hackbench exposes controls that can change the workload:

  • --process or --threads selects processes or threads. These modes exercise overlapping but different kernel paths and should not be treated as interchangeable.
  • --pipe selects pipes where supported; otherwise the implementation may use socket pairs. Different IPC methods are different workloads.
  • --groups changes the number of groups; --loops changes the number of communication rounds.
  • --datasize changes the payload size, and --fds controls the number of file descriptors used by each child in implementations that offer that option.
  • --fifo requests FIFO scheduling in implementations that support it. This may require privileges or suitable real-time resource limits; elevated priority can starve ordinary work.

Names, availability, defaults, and short-option meanings can vary by version and package. Check the installed program’s own help and manual rather than assuming another machine’s command line applies.

Find an installed implementation

command -v hackbench
hackbench --help
man hackbench
perf bench
perf bench sched

A distribution may provide perf without standalone Hackbench, or package Hackbench separately. The available perf bench collections also depend on the installed version and build features, as the Linux workload-tracing documentation explains.

Run a basic test

If standalone Hackbench is installed, begin with its defaults only after checking what those defaults mean for that version:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
hackbench

Depending on the local interface, explicit options may look like these examples:

hackbench --process
hackbench --threads
hackbench --pipe
hackbench --groups 10
hackbench --loops 100
hackbench --datasize 100

Do not combine these blindly: validate each option with hackbench --help or man hackbench. If the standalone command is unavailable, try the related perf benchmark:

perf bench sched messaging
perf bench sched messaging --thread
perf bench sched messaging --pipe
perf bench sched messaging --group=10 --nr_loops=100

For the documented perf implementation, --pipe uses pipe() instead of socketpair(), --thread selects threads, and the group and loop options control workload size. Its documentation gives an example with 20 sender-and-receiver processes per group and 10 groups—400 processes total. That is an example for this perf workload, not a universal default for standalone Hackbench.

perf also has framework-level repetition and format options:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
perf bench --repeat=10 sched messaging
perf bench --format=simple --repeat=10 sched messaging

The documented default repeat count for perf bench is 10. It is distinct from the messaging workload’s own group and loop settings; check the local perf bench help and documentation for the installed version.

Interpret the elapsed time carefully

The main result is generally elapsed time. Lower time means faster completion of that exact workload, not that the machine is universally faster. A slower result can reflect scheduler or IPC overhead, CPU contention, virtualization, power behavior, or a kernel change; Hackbench alone cannot identify the cause.

One run is not enough to establish a small difference. Repeat runs under consistent conditions and compare medians and ranges (or another suitable measure of spread). A change in groups, loops, payload size, task type, or IPC method changes the workload—not merely the precision of the same test. More load can shift the bottleneck toward IPC, descriptor management, memory pressure, or CPU saturation.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Make kernel comparisons reproducible

  1. Use the same machine and keep CPU topology and SMT state fixed. Record whether it is bare metal or a virtual machine.
  2. Keep kernel configuration and other software constant except for the change being investigated. Reboot into each kernel where appropriate.
  3. Use the same implementation, binary version, command line, and workload mode each time.
  4. Keep background activity and power conditions consistent. Short runs can be affected by frequency ramp-up or turbo behavior; repeated runs may heat the system enough to trigger thermal limits.
  5. If CPU affinity is part of the experiment, apply it identically and report it. For example:
taskset -c 0-7 perf bench sched messaging --group=10 --nr_loops=100

Pinning restricts the benchmark to those CPUs, so this tests a different condition from unrestricted scheduling across all available CPUs. It is useful when controlled, but it must be recorded.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Capture enough context to interpret the numbers:

uname -a
lscpu
nproc
ulimit -n
ulimit -u
cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor 2>/dev/null

Not every system exposes the listed CPU-frequency files. Also note the distribution, architecture, kernel configuration, physical and logical CPU counts, SMT state, power profile, groups, loops, payload, IPC method, process or thread mode, cgroup or container limits, affinity, machine load, run count, and summary statistics.

Use perf to investigate, not just score

perf stat can add counter context around a run:

perf stat -- perf bench sched messaging
perf stat -e context-switches,cpu-migrations,task-clock 
  -- perf bench sched messaging

Event availability depends on the kernel, architecture, permissions, and CPU. Instrumentation can add overhead, so distinguish the benchmark result from the measurement conditions used to diagnose it. A changed elapsed time is a signal to investigate, not proof that a particular scheduler path caused a regression. Profiling, tracing, or kernel-source analysis may be needed to explain the difference. The kernel documentation on workload tracing describes perf and its use with the perf_events interface.

Common problems and cautions

  • hackbench: command not found: The standalone binary may not be installed. Check your distribution’s package availability or use perf bench sched messaging if that benchmark is present.
  • “Too many open files” or channel creation failure: The workload may exceed the process or system descriptor limit. Inspect ulimit -n before increasing groups or file descriptors. Do not raise limits permanently without understanding the resource and service impact.
  • Cannot fork or create threads: Task-count limits, cgroup restrictions, memory pressure, or an oversized workload may be responsible. Check applicable limits and reduce workload size before retrying.
  • Unexpectedly high load: Hackbench can create many schedulable tasks and channels. Stop or scale back on a controlled host rather than risking disruption to production services.
  • Permission or scheduling-policy error: FIFO or real-time scheduling may require appropriate privileges or resource limits. Do not add sudo automatically; test such modes only in an isolated environment where a high-priority task cannot harm other work.
  • Different results in a VM or container: A hypervisor adds another scheduling layer, and host contention or vCPU placement can affect timing. Cgroups and containers may also restrict CPU time, task counts, memory, or visible CPUs. Record these limits.

Related tools: pick by purpose

  • perf bench sched pipe: A narrower pipe-system-call benchmark, not the Hackbench messaging workload. The perf bench documentation describes its timing and operations-per-second output.
  • stress-ng: Better suited to broad system stress across areas such as CPU, memory, I/O, filesystems, networking, and scheduling. It is not a drop-in replacement when you need a Hackbench-compatible comparison; see the Linux documentation.
  • LKP tests: A more involved framework for repeatable kernel performance jobs, including Hackbench variants and result collection. See the LKP tests project.

Reporting checklist

  • Exact command, implementation, and version
  • Kernel version, configuration, distribution, and architecture
  • Machine type: bare metal, cloud VM, or local VM
  • CPU model, logical and physical CPU counts, SMT state, and affinity
  • Process or thread mode; pipe or socket-pair IPC
  • Groups, loops, payload size, and file-descriptor settings where applicable
  • Cgroup/container limits, system load, and power or thermal conditions
  • Number of repetitions and median plus spread, rather than a single result

With those details, Hackbench can provide a useful, bounded comparison of scheduler-and-IPC behavior. Without them, an elapsed time is difficult to interpret and easy to overstate.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.