Day 10: Benchmarking – measuring honestly
Goal: build benchmarks that measure what they are supposed to measure, recognize the typical mistakes, describe load profiles as a fio job file, report the spread and actively check every benchmark while it runs · Duration: about 3 hours · Prerequisite: Day 0–9
Where we start
/daten is empty, no device mapper devices from Day 9 are
left, and no fio is running.
# on perf1
ls /datenExpected:
lost+found
# on perf1
sudo dmsetup lsExpected:
No devices found
pgrep -c counts processes with this name:
# on perf1
pgrep -c fioExpected:
0
Introduction
So far you have observed systems that were under load – passive measurement. Today you create the load yourself to answer a question: How fast is this disk? Can this server handle the expected load? Did the setting help? That is benchmarking, and it is harder than it looks.
A benchmark always delivers a number. Whether it means anything is
another question. The famous quick dd test often measures
main memory instead of the disk. A ten-second run on a virtual machine
also measures what the neighbors on the host are doing at that moment.
And a benchmark with a single request at a time measures latency, not
what the device can do. If you let such numbers flow into purchasing
decisions or comparisons, you are deciding on sand.
Today you learn to build and check benchmarks so that you can trust their numbers. The most important principle comes from Brendan Gregg’s methodology: active benchmarking. While the benchmark runs, you watch with the tools of the last days what the system actually does. Only then do you know what the number means.
Today you learn:
- to recognize the most common benchmark mistakes: cache instead of device, wrong parallelism, runs that are too short, missing repetition, unnoticed interference,
- to benchmark actively: to check the run with
iostat,vmstatandpidstat, - to capture load profiles in a fio job file and read the results per profile,
- to measure and report the spread,
- to compare CPU performance with
stress-ng, - to expose a flattering benchmark and repeat it correctly.
Background
The picture for today: a car’s fuel consumption figure
Everybody knows it: according to the brochure the car needs 4.5 liters, in everyday use it is 7. Nobody lied – something else was measured.
- Measured downhill with a tailwind is a benchmark whose data is in the page cache: the number is real, but it says nothing about the disk.
- The driving profile (city, country road, highway) is the load profile: block size, read/write, parallelism. If you only measure the highway, you know nothing about city traffic.
- A single lap says nothing – weather, traffic and driver vary. Several laps show the spread.
- The passenger with measuring instruments who checks during the drive whether the engine is really working or the car is just rolling is active benchmarking.
The terms
| Term | Meaning | in the picture |
|---|---|---|
| benchmark | create load to answer a question with a number | consumption measurement |
| load profile | block size, pattern, mix, parallelism, fsync of the
real application |
driving profile |
direct I/O (--direct=1) |
bypassing the page cache | on a flat road without wind |
| spread | range of the results over several runs | several laps |
| active benchmarking | checking during the run where the bottleneck is | passenger with measuring instruments |
| fio job file | load profile as a file, repeatable | the standardized test procedure |
Remember: A benchmark always delivers a number. Only the check during the run tells you what the number measures.
What a good benchmark needs
- A question. “How fast is the disk?” is not a question. “How many random 8 KiB reads per second does it handle with 16 concurrent requests, and what is p99?” is one.
- A matching load. The load should resemble the real
application: block size, reading or writing, random or sequential,
parallelism,
fsync. A benchmark with 1 MiB blocks says nothing about a database that works with 8 KiB. - The right layer. If the device is to be measured,
the page cache must be bypassed (
--direct=1). If the application is to be measured, the cache is part of it – but then with realistically large data. - Duration and repetition. Long enough that warm-up effects and caches do not matter, and several times so that the spread becomes visible.
- A quiet system – or a known one. Whatever else is running distorts the result. In VMs this can also be something you cannot see.
- Verification. During the run, check whether the system does what the benchmark claims.
Typical mistakes
| Mistake | Consequence | How you notice it |
|---|---|---|
| data fits into the page cache | memory measured instead of disk, fantasy values | iostat shows no load on the device |
| one request at a time | only latency measured, not capacity | aqu-sz in iostat around 1 |
| run time too short | caches and warm-up determine the result | values change with the run time |
| a single run | chance counts as a result | repetition scatters |
| load generator is the bottleneck | you measure the benchmark instead of the system | pidstat: benchmark process at 100 % CPU |
| background load | result depends on the moment | vmstat, iostat, sar before and during the
run |
Active benchmarking
A benchmark is an experiment, and an experiment needs a control.
While the benchmark runs, you check with the tools of the last days
where the bottleneck is: Is the device really busy
(iostat)? Is the benchmark waiting for the device or
computing (pidstat, vmstat)? Is the block size
that arrives at the device correct (areq-sz)? Only when the
bottleneck is where you want to measure it does the number tell you
something about what you want to know.
Reporting the spread
A number without spread is a claim. Report at least the range (minimum to maximum) or the mean and standard deviation over several runs. Differences smaller than the spread are not differences.
Drill 1: The quick dd test and what it really measures
Where you are: on perf1.
What you have afterwards: seen how a popular disk test measures main memory, and repeated the same measurement honestly.
Step 1 – The classic: writing.
# on perf1
cd /daten# on perf1
dd if=/dev/zero of=/daten/test.bin bs=1M count=1024ddcopies blocks:if=/dev/zerodelivers zeros,of=is the target file,bs=1M count=1024= 1 GiB. At the end,ddreports the data rate.
Expected:
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 2.79575 s, 384 MB/s
Step 2 – The classic: reading.
# on perf1
dd if=/daten/test.bin of=/dev/null bs=1MExpected:
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 0.283638 s, 3.8 GB/s
3.8 GB/s reading – on a virtual disk that managed 25,000 IOPS of 4 KiB each on Day 0 (about 100 MB/s). The read came entirely from the page cache: the file had just been written and was still in memory – downhill with a tailwind. And the write (384 MB/s) was partly just copying into the cache.
Step 3 – Honest: empty the cache first. Write back everything dirty:
# on perf1
syncThen drop the page cache (as on Day 8):
# on perf1
echo 3 | sudo tee /proc/sys/vm/drop_caches > /dev/nullStep 4 – Writing past the cache.
# on perf1
dd if=/dev/zero of=/daten/test.bin bs=1M count=1024 oflag=directoflag=directwrites past the page cache.
Expected (excerpt – the last line):
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 2.57962 s, 416 MB/s
Step 5 – Writing with a flush.
# on perf1
dd if=/dev/zero of=/daten/test.bin bs=1M count=1024 conv=fdatasyncconv=fdatasyncwrites through the cache but callsfdatasyncat the end – so the time also includes the writeback. That corresponds to a program that saves large files safely.
Expected (excerpt – the last line):
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 3.9282 s, 273 MB/s
Step 6 – Reading past the cache.
# on perf1
dd if=/daten/test.bin of=/dev/null bs=1M iflag=directiflag=directreads past the cache.
Expected (excerpt – the last line):
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 1.64514 s, 653 MB/s
Reading: 653 MB/s instead of 3.8 GB/s – almost six times less. Writing with a flush: 273 MB/s. That is the disk.
# on perf1
rm -f /daten/test.binBut dd has a second weakness: it only ever sends
one request at a time. What the device can do with more
parallelism is shown in the diagnosis task.
Remember: A file you have just written is read from memory. Disk tests need
direct– or an emptied cache and much more data than main memory.
Save your progress? Sign up for free
Drill 2: fio takes care – but not of everything
Where you are: on perf1, two terminals.
What you have afterwards: seen that fio avoids the cache mistake on its own, and why you should still not rely on it.
Step 1 – A small file, without
--direct. A 64 MiB file would easily fit into the
page cache. fio’s summary goes into a file so that you can measure
alongside:
# on perf1, terminal 1
fio --name=klein --filename=/daten/klein.bin --size=64M --rw=randread --bs=4k \
--ioengine=psync --runtime=20 --time_based > /tmp/klein.txtStep 2 – Is the disk working? After about eight seconds:
# on perf1, terminal 2
iostat -sxz 1 2Expected (excerpt – the line sdb in the
second report):
sdb 2326.00 9304.00 0.00 0.36 4.00 0.84 80.20
Step 3 – What fio reports. When fio is done,
grep fetches the result line from the file
(^ +read: = a line that starts with spaces and
read:):
# on perf1
grep -E "^ +read:" /tmp/klein.txtExpected:
read: IOPS=2255, BW=9021KiB/s (9237kB/s)(176MiB/20001msec)
The disk is busy, and fio read 176 MiB in 20 seconds – almost three
times the file – all from the disk. The reason is the fio option
invalidate, switched on by default: fio
drops the pages of its test file from the page cache before the run
and before every new pass. So fio protects you from the
most common mistake.
You should not rely on it: other tools do not do this (see
dd), fio job files sometimes set invalidate=0,
and with several processes reading the same data they can fill the cache
for each other. That is why iostat belongs next to every
benchmark – as here.
# on perf1
rm -f /daten/klein.binRemember: No benchmark without
iostatnext to it. If the device shows no load, you have measured the cache – no matter which tool.
Save your progress? Sign up for free
Drill 3: Load profiles as a fio job file
Where you are: on perf1, in the directory
~/tag10.What you have afterwards: a job file with two load profiles and their results – throughput and percentiles per profile.
Long command lines are hard to repeat and compare. fio can describe loads in a job file that you can version and pass on – the standardized test procedure from the picture.
Step 1 – Directory.
# on perf1
mkdir -p ~/tag10# on perf1
cd ~/tag10Step 2 – The job file.
# on perf1
nano profile.fioContent (nano as on Day 0: Ctrl+O and Enter saves, Ctrl+X exits):
; Zwei Lastprofile für /daten – nacheinander, je 30 Sekunden
[global]
directory=/daten
direct=1
ioengine=libaio
time_based
runtime=30
size=2G
group_reporting
[datenbank]
; 8-KiB-Seiten, 70 % lesen, 30 % schreiben, 8 Anfragen gleichzeitig
rw=randrw
rwmixread=70
bs=8k
iodepth=8
numjobs=2
[protokoll]
; der Reihe nach schreiben, 64 KiB, nach jedem 32. Block fdatasync
stonewall
rw=write
bs=64k
iodepth=1
fdatasync=32
numjobs=1The structure of a job file (the comments in the file say: two load
profiles for /daten, one after the other, 30 seconds
each):
- Lines starting with
;are comments. [global]sets values for all jobs: directory, direct access, asynchronous I/O, run time 30 seconds, file size 2 GiB, a combined report per job (group_reporting).[datenbank](“database”) is a job: random reading and writing in a ratio of 70 to 30, 8 KiB, eight concurrent requests, two processes.[protokoll](“log”) is a second job.stonewallmeans: wait until all previous jobs are done – otherwise both would run at the same time. It writes sequentially in 64 KiB blocks and callsfdatasyncafter every 32 blocks.
Step 3 – Run it.
# on perf1
fio profile.fioThat takes a little over a minute. At the end fio prints a long report for each job.
Expected (excerpt – the header line of each job, the
read:/write: lines, the percentiles 30–60 and
99–99.95 and the sync line):
datenbank: (groupid=0, jobs=2): err= 0: pid=6130: Mon Nov 30 14:12:27 2026
read: IOPS=1541, BW=12.0MiB/s (12.6MB/s)(362MiB/30029msec)
clat percentiles (usec):
| 30.00th=[ 486], 40.00th=[ 1139], 50.00th=[ 4228], 60.00th=[ 6587],
| 99.00th=[ 81265], 99.50th=[105382], 99.90th=[164627], 99.95th=[189793],
write: IOPS=661, BW=5294KiB/s (5421kB/s)(155MiB/30029msec); 0 zone resets
clat percentiles (usec):
| 30.00th=[ 371], 40.00th=[ 400], 50.00th=[ 429], 60.00th=[ 465],
| 99.00th=[ 2147], 99.50th=[ 2933], 99.90th=[ 4490], 99.95th=[ 7767],
protokoll: (groupid=1, jobs=1): err= 0: pid=6132: Mon Nov 30 14:12:27 2026
write: IOPS=1723, BW=108MiB/s (113MB/s)(3231MiB/30001msec); 0 zone resets
clat percentiles (usec):
| 30.00th=[ 367], 40.00th=[ 392], 50.00th=[ 416], 60.00th=[ 441],
| 99.00th=[ 1221], 99.50th=[ 1663], 99.90th=[ 3359], 99.95th=[ 3720],
sync (usec): min=421, max=60529, avg=1760.92, stdev=2092.74
What you read from it:
| Profile | Throughput | Median | p99 | Interpretation |
|---|---|---|---|---|
| datenbank, reads | 1,541 IOPS | 4.2 ms | 81 ms | surprisingly bad – pure reads were below 1 ms on Day 9 |
| datenbank, writes | 661 IOPS | 0.43 ms | 2.1 ms | the storage under the VM accepts writes quickly (probably into a write cache on the host); the reads wait behind them |
| protokoll | 108 MiB/s | 0.42 ms | 1.2 ms | fdatasync 1.8 ms on average, outliers up to 60 ms |
A mixed load behaves differently from the sum of its parts – that is exactly why a profile that resembles the real application is worth it.
Step 4 – Clean up. fio names its files after the job:
# on perf1
rm -f /daten/datenbank.* /daten/protokoll.*From building this course: Immediately afterwards, three short comparison runs of 15 seconds each ran on perf1: pure random reads 5,613 IOPS, mixed 4,061 read IOPS, pure random reads again 3,602 IOPS. The same command, two minutes apart, 36 % difference. The storage under the VM was not quiet that afternoon (see also Day 9). A single run could have presented any of these numbers as “the performance of the disk”.
Remember: Measure your application’s driving profile, not the prettiest one. A job file makes the measurement repeatable and comparable.
Save your progress? Sign up for free
Drill 4: Measuring the spread
Where you are: on perf1.
What you have afterwards: five measurements of the same benchmark and their spread.
Step 1 – Five laps. The same run, ten seconds each. Run the command five times in a row – arrow up and Enter bring it back:
# on perf1
fio --name=d --filename=/daten/fio-test --size=1G --rw=randread --bs=4k --direct=1 \
--ioengine=libaio --iodepth=16 --runtime=10 --time_basedExpected (excerpt – the line read: from
each of the five runs):
read: IOPS=28.1k, BW=110MiB/s (115MB/s)(1098MiB/10001msec)
read: IOPS=27.9k, BW=109MiB/s (114MB/s)(1090MiB/10001msec)
read: IOPS=27.2k, BW=106MiB/s (111MB/s)(1062MiB/10001msec)
read: IOPS=25.9k, BW=101MiB/s (106MB/s)(1012MiB/10001msec)
read: IOPS=25.8k, BW=101MiB/s (106MB/s)(1008MiB/10001msec)
Five runs, mean 27,000 IOPS, range 25,800 to 28,100 – about ±4 %. This is how you report the result: “27,000 IOPS (25,800–28,100, n = 5)”. If you then changed a setting and measured 28,000, that would not be an improvement but spread. The trend is also striking: every run was a little slower than the previous one. Whether that was due to the device, the file or the host, you would only know with more runs and a pause in between – but a falling trend is a reason to look more closely before publishing a number.
Step 2 – Clean up.
# on perf1
rm -f /daten/fio-testRemember: A number without spread is a claim. Differences within the spread are not differences.
Save your progress? Sign up for free
Drill 5: Comparing CPU performance
Where you are: on perf1.
What you have afterwards: compared the computing power of one and of all CPUs with a fixed method.
Step 1 – One CPU.
# on perf1
stress-ng --cpu 1 --cpu-method matrixprod --timeout 15s --metrics-brief| Option | Meaning |
|---|---|
--cpu 1 |
one compute worker |
--cpu-method matrixprod |
fixed computation method: matrix multiplication. Without this option stress-ng switches between many methods, and the results are harder to compare |
--timeout 15s |
15 seconds |
--metrics-brief |
a short table with the throughput at the end |
Expected (excerpt – the header and the result line of the table at the end):
stress-ng: metrc: [6139] stressor bogo ops real time usr time sys time bogo ops/s bogo ops/s
stress-ng: metrc: [6139] cpu 8979 15.00 14.99 0.01 598.46 598.45
Step 2 – Four CPUs.
# on perf1
stress-ng --cpu 4 --cpu-method matrixprod --timeout 15s --metrics-briefExpected (excerpt – the result line):
stress-ng: metrc: [6142] cpu 35721 15.00 59.96 0.03 2380.68 595.49
| Column | Meaning |
|---|---|
bogo ops |
computation steps completed in total |
real time / usr time /
sys time |
wall-clock time / CPU time used in user and kernel mode |
first bogo ops/s |
per second of wall-clock time |
second bogo ops/s |
per second of CPU time (usr+sys) |
One CPU: 598 per second. Four CPUs: 2,381 – 3.98 times as much, and still 595 per CPU second. So the four virtual CPUs scale practically perfectly; they do not slow each other down (for example through shared caches or hyper-threading on the host). For comparing two servers, exactly this value is useful – but only with the same method and the same stress-ng version.
Remember: Compare CPUs only with a fixed method and the same version. The performance per CPU second shows whether more CPUs also bring more.
Save your progress? Sign up for free
Diagnosis task
A colleague “tested” the new data disk and writes in the team chat:
“The new disk is amazing: 3.2 GB/s reads, measured with
dd. I suggest we put all databases on it, then we don’t need an SSD upgrade.”
His test – first write a 2 GiB file:
# on perf1
dd if=/dev/zero of=/daten/test.bin bs=1M count=2048 status=noneThen read it, with timing:
# on perf1
time dd if=/daten/test.bin of=/dev/null bs=1MExpected:
2048+0 records in
2048+0 records out
2147483648 bytes (2.1 GB, 2.0 GiB) copied, 0.663241 s, 3.2 GB/s
real 0m0.668s
user 0m0.009s
sys 0m0.659s
Task (20 minutes): Prove with active benchmarking what this test measures. Then find out what the disk really achieves with large sequential reads – and why even that does not yet answer the question “Is it good enough for databases?”.
Solution path
Step 1 – What does the disk do while reading? A
single read takes only two thirds of a second – too short to watch. So
you read the file ten times in a row. cat gets the same
name ten times; in the lab this took a little over six seconds:
# on perf1, terminal 1
cat /daten/test.bin /daten/test.bin /daten/test.bin /daten/test.bin /daten/test.bin /daten/test.bin /daten/test.bin /daten/test.bin /daten/test.bin /daten/test.bin > /dev/nullImmediately afterwards in the second terminal:
# on perf1, terminal 2
iostat -sxz 1 2Expected (excerpt – the second report; the first shows, as always, the averages since boot):
avg-cpu: %user %nice %system %iowait %steal %idle
0.75 0.00 24.25 0.00 0.25 74.75
Device tps kB/s rqm/s await areq-sz aqu-sz %util
In the second in which more than 3 GB/s are “read”, not a
single device appears – not even sdb, the disk
does nothing. (-z leaves out idle devices.) Instead,
%system is at 24 %: one of the four CPUs is fully busy
copying in the kernel. The colleague’s timing confirms it:
sys = 0.659 of 0.668 seconds. dd spent almost
the whole time in the kernel copying from the page cache. The test
measures memory bandwidth – the car was rolling
downhill.
Step 2 – What does the disk really achieve? Empty the cache:
# on perf1
sync# on perf1
echo 3 | sudo tee /proc/sys/vm/drop_caches > /dev/nullThen read directly, in the first terminal:
# on perf1, terminal 1
dd if=/daten/test.bin of=/dev/null bs=1M iflag=directAfter one second in the second:
# on perf1, terminal 2
iostat -sxz 1 2Expected (excerpt – the line sdb):
sdb 1330.00 680960.00 0.00 1.31 512.00 1.75 86.70
And dd reports (excerpt – the last line):
2147483648 bytes (2.1 GB, 2.0 GiB) copied, 3.78827 s, 567 MB/s
Step 3 – With several concurrent requests.
# on perf1
fio --name=seq --filename=/daten/test.bin --rw=read --bs=1M --direct=1 --ioengine=libaio \
--iodepth=8 --runtime=15 --time_basedExpected (excerpt – the line
read:):
read: IOPS=1370, BW=1370MiB/s (1437MB/s)(20.1GiB/15018msec)
- Now
sdbis working: 1,330 requests of 512 KiB per second (the kernel splitsdd’s 1 MiB blocks in two), 87 % utilized.ddreaches 567 MB/s. - fio with eight concurrent requests reaches 1,370
MiB/s.
ddonly ever sends one request and waits for it – it measures the latency of a single data stream, not what the device manages in parallel.
The honest answer to the colleague: for large sequential reads the disk manages about 570 MB/s with one data stream and 1.4 GB/s with eight – not 3.2 GB/s.
Step 4 – Does that answer the database question?
No. Databases mostly read and write small blocks randomly, with
fsync, mixed – a completely different driving profile. The
right measurement is a profile like datenbank from Drill 3
– and on the same disk that produced 1,541 read IOPS with a median of
4.2 ms and a p99 of 81 ms. With these numbers the decision about the SSD
upgrade looks very different. And because the storage under the VM
fluctuates, several runs at different times of day are part of it.
Step 5 – Clean up.
# on perf1
rm -f /daten/test.binRemember: First prove that the device is working, then believe the number. And the question “is it enough?” is only answered by the load profile of the real application.
If it doesn’t work
iostatdoes show load onsdbduring the tenfold read: The file was no longer completely in the cache, for example because something else was read in between. Read it once withcat /daten/test.bin > /dev/nulland start the tenfold read again.
Challenge
Add a third profile sicherung (“backup”) to the job
file: large sequential reads with 1 MiB blocks and four concurrent
requests that runs in parallel with the profile
datenbank (not after it). How do the percentiles of the
database reads change? What does that mean for planning nightly
backups?
Solution path: A new section
[sicherung] with rw=read, bs=1M,
iodepth=4 and without
stonewall directly after [datenbank] – then
both run at the same time; the profile protokoll with
stonewall still only starts afterwards. So that fio reports
the jobs separately, do not set group_reporting under
[global] but only in the section [datenbank]
(there it combines the two processes). With
fio --section=datenbank DATEI a single section runs for the
comparison.
In the author’s lab (30 seconds each):
| Database reads | alone | with backup |
|---|---|---|
| IOPS | 1,493 | 470 |
| p99 | 92 ms | 236 ms |
The large blocks of the backup occupy the queues; the database loses
two thirds of its reads, and one in a hundred takes almost a quarter of
a second. The consequence is classic: no backups during busy hours, or
with limited bandwidth (Day 15 shows IOReadBandwidthMax for
that). The size of the effect depends on the storage under your VM.
Save your progress? Sign up for free
Checkpoint
# on perf1
ls /datenExpected: only lost+found.
# on perf1
pgrep -c fioExpected: 0.
grep -c counts matching lines – here lines that start
with [ (the backslash takes [ literally):
# on perf1
grep -c "^\[" ~/tag10/profile.fioExpected: 3 – the sections global,
datenbank and protokoll.
Test yourself
- A
ddread test right after writing gives 3.8 GB/s. What did you measure, and how do you prove it? - Why does
ddnot measure what the disk can do, even withiflag=direct? - Two settings give 27,000 and 28,000 IOPS. Is the second one better?
- What is
stonewallfor in a fio job file? - Why is a sequential 1 MiB test not enough to evaluate a disk for databases?
Answers:
- The page cache. Proof:
iostatduring the run shows no load on the device,timeshows almost onlysystime. ddonly ever sends one request and waits for it – it measures one data stream, not the parallelism of the device (1,370 MiB/s with fio and eight requests versus 567 MB/s).- Not without the spread: with 25,800–28,100 over five runs, the difference lies within the spread.
- The job waits until all previous ones are done – otherwise they would run at the same time.
- Databases work with small, random, mixed accesses and
fsync; such a profile behaved completely differently (1,541 read IOPS, p99 81 ms).
Interview Note
“How would you evaluate a new storage solution?” – A good answer
starts with the application’s load (block size, pattern, parallelism,
fsync), mentions direct I/O, sufficiently large test data
and run times, several runs with spread and percentiles instead of
averages – and above all active benchmarking: iostat and
pidstat during the run to prove that the bottleneck is in
the storage and not in the cache or in the load generator. If you can
name the dd test as an antipattern and explain why, you
have won the question.
Enterprise Note
Benchmarks flow into purchasing decisions and architecture comparisons – with corresponding damage if they are wrong. In every benchmark report, record: the question, the load profile (ideally the fio job file itself), hardware and software with versions, run time, number of runs, spread, percentiles and what was observed during the run. Vendor figures are almost always best-case values with an ideal load; the yardstick is your own load. In virtualized environments and clouds, this includes the note that neighbors influence the result – and measurements at different times.
Summary
- A benchmark needs a question, a matching load, the right layer, duration and repetition, a quiet or known system and verification.
- Active benchmarking:
iostat,vmstat,pidstatduring the run – only then do you know what the number measures. - The
ddread test after writing measures the page cache (3.2–3.8 GB/s instead of 570–650 MB/s);ddalso only sends one request at a time (fio with eight: 1,370 MiB/s). - fio drops the cache of its test files on its own
(
invalidate) – still always check withiostat. - Job files capture load profiles;
stonewallseparates jobs in time. A mixed load behaves differently from the sum of its parts. - Report the spread: 27,000 IOPS (25,800–28,100, n = 5). Differences within the spread are none.
stress-ng --cpu-method matrixprod --metrics-brief: 598 operations per second on one CPU, 2,381 on four – perfect scaling.
Commands at a glance
| Command | What it does | Parameters |
|---|---|---|
dd if=… of=… bs=1M count=N [oflag=direct\|conv=fdatasync] |
simple write test | oflag=direct past the cache,
conv=fdatasync with flush |
dd if=DATEI of=/dev/null bs=1M iflag=direct |
simple read test past the cache | iflag=direct |
sync +
echo 3 \| sudo tee /proc/sys/vm/drop_caches |
empty the cache before a test | – |
fio JOBDATEI |
run load profiles from a file | see Drill 3 |
[global], [job],
stonewall |
structure of a fio job file | stonewall = wait for previous jobs |
fio … --rw=read --bs=1M --iodepth=8 |
large sequential reads, in parallel | – |
grep -E "^ +read:" DATEI |
result line from a fio report | – |
stress-ng --cpu N --cpu-method matrixprod --metrics-brief |
comparable CPU load with throughput | --cpu-method method |
iostat -sxz 1 2 (during the run) |
active check of the device | – |
time BEFEHL |
wall-clock versus CPU time | real, user, sys |