Part 7 of 7 · 3 min read
Exercises
Easy
Easy 1: Saturated or not (20 minutes)
A machine with 8 cores shows r = 6, id = 20. Is the processor saturated?
Done when: no: the run queue is below the number of cores, though the use is high (80 per cent).
Hint
compare r with 8.
Easy 2: Share (20 minutes)
Six loops run on 3 cores. What share of a core does each get?
Done when: 3 / 6 = 0.5, that is 50 per cent.
Hint
cores divided by loops.
Easy 3: Which resource (20 minutes)
vmstat shows si 800, so 1,200, free near 0. Which resource is short?
Done when: memory, the system is swapping.
Hint
see the memory row of section 1.
Medium
Medium 1: Reproduce the CPU test (45 minutes)
Compile burn, run twice as many copies as cores, and report r, us, id, and the %CPU of each copy.
Done when: r equal to the number of copies, id 0, and each copy near 50 per cent.
Hint
nproc gives the number of cores.
Medium 2: Reproduce the disk test (45 minutes)
Compile syncer, run it for 10 seconds and report b, wa, the STAT and WCHAN of the process.
Done when: b of 1, a non-zero wa, state D and a block-layer or file-system wchan.
Hint
ps -o stat,wchan:16 -C syncer.
Medium 3: Throughput (45 minutes)
From bo = 47,844 blocks per second (1 KiB each), compute MB per second and the number of 4 KiB writes per second.
Done when: about 46.7 MiB per second (47,844 / 1,024), and about 11,961 writes of 4 KiB per second.
Hint
47,844 divided by 1,024 and by 4.
Hard
Hard 1: Fix the syncer (90 minutes)
Change syncer to call fsync once for every 64 writes. Measure bo, wa and the number of writes per second before and after, and explain the change.
Done when: wa lower, writes per second much higher, and an explanation by batching (group commit, Level 8).
Hint
add a counter in the loop and call fsync when it reaches 64.
Hard 2: Mixed load (90 minutes)
Run two burn and one syncer together on two cores. Report r, b, us, sy, wa and which resource limits each program.
Done when: a table of the numbers and a short analysis, such as the burns limited by cores and the syncer by the disk.
Hint
use taskset if you want to place programs on given cores.
Hard 3: Write a triage script (90 minutes)
Write a script that prints vmstat 1 5, free -m, the five largest processes by memory and by CPU, and the last ten lines of dmesg, and ends with a one-line verdict by simple rules from the table of section 5.
Done when: a script that runs, with rules for processor, disk and memory and a test on each of the three workloads.
Hint
read us, id, wa, si, so from the last line of vmstat.