summaryrefslogtreecommitdiff
path: root/docs/tutorial/scripts/workload.sh
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-06 09:42:43 +0300
committerPaul Buetow <paul@buetow.org>2026-05-06 09:42:43 +0300
commitd78a2530da91b76625b71c2aeaf3293abc6c3a4b (patch)
tree5d59a7a1014955564b9f2c30decaf6be257e61cf /docs/tutorial/scripts/workload.sh
parentfbb7c9a9ad8d03d5d095ac441a58b37537e0ab8d (diff)
move demo/ to docs/tutorial/, commit assets, consolidate TUI docs
- demo/ renamed to docs/tutorial/ (tapes, scripts, TUTORIAL.md) - docs/tutorial/assets/ added to git (51 MB of GIFs + PNGs); removed /demo/assets/ from .gitignore so images render on Codeberg - docs/tui-reference.md removed; its hotkey tables merged into a new "Hotkey Quick Reference" section at the end of TUTORIAL.md - TUTORIAL.md: updated install section (mage buildDocker, no GOTOOLCHAIN=auto), fixed README relative path (../../README.md), updated internal tapes/scripts/assets path prose - README.md: updated all demo/ image paths and links to docs/tutorial/; TUI and recording-modes links now point to TUTORIAL.md anchors - AGENTS.md: updated demo/ references to docs/tutorial/ - Magefile.go: updated demoDir/demoTapesDir/demoScriptsDir/demoRunTape/ demoSudoKeepers constants to docs/tutorial/ paths Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'docs/tutorial/scripts/workload.sh')
-rwxr-xr-xdocs/tutorial/scripts/workload.sh77
1 files changed, 77 insertions, 0 deletions
diff --git a/docs/tutorial/scripts/workload.sh b/docs/tutorial/scripts/workload.sh
new file mode 100755
index 0000000..ebbf58b
--- /dev/null
+++ b/docs/tutorial/scripts/workload.sh
@@ -0,0 +1,77 @@
+#!/usr/bin/env bash
+# Background workload for demo tapes. Generates a steady mix of file I/O
+# (open/read/close), big writes (fsync/dd), stat-heavy traffic, and ioworkload
+# scenarios so every TUI tab has something interesting to display.
+#
+# Designed to be killed via `kill $!` from the tape wrapper. All children are
+# placed in this script's process group so a single signal cleans them up.
+
+set -u
+
+ROOT="$(cd "$(dirname "$0")/.." && pwd)"
+IOWORKLOAD="${ROOT}/../ioworkload"
+SCRATCH="$(mktemp -d -t ior-demo-workload-XXXXXX)"
+trap 'rm -rf "$SCRATCH"' EXIT
+
+cleanup() {
+ trap - TERM INT
+ # Kill the entire process group so all background loops stop.
+ kill -- -$$ 2>/dev/null || true
+ exit 0
+}
+trap cleanup TERM INT
+
+# A) walk /usr and read first byte of each file: tons of openat/read/close + varied paths.
+(
+ while true; do
+ find /usr/share /usr/lib -maxdepth 4 -type f 2>/dev/null \
+ | shuf -n 800 \
+ | xargs -r -I{} sh -c 'head -c 1 "{}" >/dev/null 2>&1' || true
+ sleep 1
+ done
+) &
+
+# B) periodic large write with fsync via dd: fills the latency tab with slow writes.
+(
+ while true; do
+ dd if=/dev/zero of="${SCRATCH}/big.bin" bs=1M count=20 conv=fsync status=none 2>/dev/null || true
+ sleep 3
+ rm -f "${SCRATCH}/big.bin"
+ done
+) &
+
+# C) stat-heavy directory crawl: feeds the syscall tab with newfstatat/getdents.
+(
+ while true; do
+ find /etc /var/log -maxdepth 3 >/dev/null 2>&1 || true
+ sleep 2
+ done
+) &
+
+# D) ioworkload scenario rotation if the binary exists: gives us syscall variety
+# beyond what the shell utilities trigger (mmap, dup, fcntl, sync, rename, link).
+if [ -x "$IOWORKLOAD" ]; then
+ (
+ scenarios=(
+ open-basic
+ readwrite-basic
+ stat-basic
+ stat-statx
+ mmap-basic
+ sync-basic
+ dup-basic
+ fcntl-dupfd
+ rename-basic
+ link-basic
+ dir-basic
+ )
+ while true; do
+ for s in "${scenarios[@]}"; do
+ "$IOWORKLOAD" --scenario="$s" >/dev/null 2>&1 || true
+ done
+ done
+ ) &
+fi
+
+# Idle until killed.
+wait