From c8f56cf3f10aacbaf68f35491c32b17fcb956294 Mon Sep 17 00:00:00 2001 From: illustris Date: Sun, 11 Jan 2026 10:53:20 +0530 Subject: [PATCH] remove valgrind, update docs --- README.md | 11 ++++++----- nix/packages.nix | 3 +-- scenario3-syscall-storm/README.md | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index de877b4..df0db62 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,6 @@ sudo apt install -y \ # Optional but recommended sudo apt install -y \ hyperfine \ - valgrind \ systemtap-sdt-dev # Python tools @@ -125,7 +124,7 @@ Get all workshop tools in your current shell without installing anything system- cd perf-workshop nix develop -# Now you have: perf, strace, py-spy, bpftrace, hyperfine, valgrind, flamegraph, pyroscope +# Now you have: perf, strace, py-spy, bpftrace, hyperfine, flamegraph, pyroscope perf --version py-spy --help ``` @@ -272,8 +271,11 @@ perf-workshop/ ├── scenario4-cache-misses/ │ ├── README.md │ ├── Makefile -│ ├── cache_demo.c # Row vs column major -│ └── list_vs_array.c # Array vs linked list +│ ├── matrix_col_major.c # BAD: Column-major traversal +│ ├── matrix_row_major.c # GOOD: Row-major traversal +│ ├── list_scattered.c # BAD: Scattered linked list +│ ├── list_sequential.c # MEDIUM: Sequential linked list +│ └── array_sum.c # GOOD: Contiguous array ├── scenario5-debug-symbols/ │ ├── README.md │ ├── Makefile @@ -372,7 +374,6 @@ cat README.md ### Tools to Explore Later - `bpftrace` - High-level tracing language - `eBPF` - In-kernel programmability -- `Valgrind` - Memory profiling - `gprof` - Traditional profiler --- diff --git a/nix/packages.nix b/nix/packages.nix index 21ef4ae..1dc2b59 100644 --- a/nix/packages.nix +++ b/nix/packages.nix @@ -22,9 +22,8 @@ with pkgs; [ ])) py-spy - # Benchmarking and debugging + # Benchmarking and visualization hyperfine - valgrind flamegraph # USDT/SDT support (provides sys/sdt.h) diff --git a/scenario3-syscall-storm/README.md b/scenario3-syscall-storm/README.md index c71f855..07b1d39 100644 --- a/scenario3-syscall-storm/README.md +++ b/scenario3-syscall-storm/README.md @@ -134,6 +134,24 @@ Look at: - `cpu-migrations` - `instructions per cycle` +## Exercise 6: Benchmarking with hyperfine + +Use `hyperfine` for proper statistical benchmarking with warmup runs: + +```bash +hyperfine --warmup 1 './read_slow testfile' './read_fast testfile' +``` + +This gives you: +- Mean execution time with standard deviation +- Min/max times +- Direct comparison between implementations + +For all three implementations: +```bash +hyperfine --warmup 1 './read_slow testfile' './read_stdio testfile' './read_fast testfile' +``` + ## Further Exploration 1. What happens with `read(fd, buf, 4096)` vs `read(fd, buf, 65536)`?