Skip to content

Commit 8bc3c5e

Browse files
attend to comments
1 parent 57af39a commit 8bc3c5e

5 files changed

Lines changed: 82 additions & 86 deletions

File tree

perfkitbenchmarker/data/k8s_agents/README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ k8s_agents/
2323
| |-- snapshot-crds.yaml.j2 # PodSnapshot StorageConfig + Policy
2424
| +-- snapshot-sandbox-template.yaml.j2 # Snapshot-specific SandboxTemplate
2525
+-- workloads/ # Benchmark workload scripts
26-
+-- vibe_coding/ # Startup scripts for snapshot benchmarks
26+
+-- startup_scripts/ # Startup scripts for snapshot benchmarks
2727
|-- README.md
28-
|-- startup_pip_fastapi.sh
29-
+-- startup_npm_vite.sh
28+
|-- pip_fastapi.sh
29+
+-- npm_vite.sh
3030
```
3131

3232
## Manifests
@@ -42,3 +42,7 @@ Each variant YAML contains all 7 benchmark keys with cluster and
4242
node pool specifications. See `variants/variant_reference_guide.md`
4343
for detailed descriptions of what each variant tests and its expected
4444
impact on each benchmark.
45+
46+
## Startup Scripts
47+
48+
The `workloads/startup_scripts/` directory contains pluggable bash scripts used exclusively by the Pod Snapshot benchmark. They simulate an AI agent initializing a fresh environment (installing dependencies, starting servers) before a snapshot is taken. Users select which script to run via the `--k8s_snapshot_preload_mode` flag to test different memory and I/O footprints (e.g., lightweight Python vs. heavyweight Node.js).
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Agent Startup Scripts
2+
3+
Pluggable startup scripts for the snapshot saturation harness. Each script simulates a realistic sandbox cold-start — the kind of environment setup that happens when an AI coding agent provisions a new sandbox for a user.
4+
5+
## How It Works
6+
7+
These scripts are exclusively used by the Pod Snapshot benchmark. They are not run simultaneously; rather, the user selects *one* of these scripts via the `--k8s_snapshot_preload_mode=script:<path>` flag. The benchmark uses the selected script to prepare the environment before taking a snapshot.
8+
9+
1. The script is read from disk and embedded into the pod's container entrypoint.
10+
2. The pod runs the script to completion (installs packages, starts services, etc.).
11+
3. After the script exits 0, the harness prints `SCRIPT_READY` and starts a counter loop.
12+
4. **TTFE** (Time To First Execution) is measured as the total time from SandboxClaim creation to `SCRIPT_READY`.
13+
14+
This allows you to compare cold-start TTFE (full script execution) against snapshot/restore TTFE (resuming from a pre-snapshotted state where the script already ran).
15+
16+
## Scripts
17+
18+
These scripts are provided as distinct options to test different workload characteristics (lightweight vs. heavyweight initialization).
19+
20+
### pip_fastapi.sh
21+
22+
**Lightweight Python variant.** Runs natively in the `python:3.11-slim` base image.
23+
Simulates an agent setting up a Python API. Steps: `pip install fastapi uvicorn` → create app → start uvicorn → wait for first HTTP response.
24+
25+
Typical cold-start: ~5–8s on GKE with fast network.
26+
27+
```bash
28+
# Cold-start only
29+
python sweeps/snapshot_saturation_search.py \
30+
--skip_snapshot \
31+
--k8s_snapshot_preload_mode=script:workloads/startup_scripts/pip_fastapi.sh \
32+
--burst_size=3
33+
```
34+
35+
### npm_vite.sh
36+
37+
**Heavier Node.js variant.**
38+
Simulates an agent setting up a frontend web project. Installs Node.js + npm from apt, then npm-installs Vite and starts a dev server.
39+
40+
Typical cold-start: ~30–60s (apt + npm on cold cache).
41+
42+
```bash
43+
python sweeps/snapshot_saturation_search.py \
44+
--k8s_snapshot_preload_mode=script:workloads/startup_scripts/npm_vite.sh \
45+
--burst_size=3
46+
```
47+
48+
## Writing Your Own Script
49+
50+
Requirements:
51+
- Must be a bash script (runs via `bash -c` in a `python:3.11-slim` container)
52+
- Must exit 0 on success (use `set -e` for fail-fast)
53+
- Should print progress to stdout (visible in pod logs for debugging)
54+
- The harness appends `SCRIPT_READY` + counter loop after your script — don't add your own
55+
56+
The `PRELOAD_MB` env var is available but unused by these scripts. The sweep varies it to test different memory request levels on the pod.

perfkitbenchmarker/data/k8s_agents/workloads/vibe_coding/startup_npm_vite.sh renamed to perfkitbenchmarker/data/k8s_agents/workloads/startup_scripts/npm_vite.sh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
# Vibe Coding Startup Script — npm + Vite dev server
2+
# Agent Startup Script — npm + Vite dev server
33
#
44
# Simulates a typical agentic sandbox "vibe coding" cold-start:
55
# 1. Install Node.js dependencies (bun/npm)
@@ -13,14 +13,14 @@
1313
# Usage (cold-start only):
1414
# python sweeps/snapshot_saturation_search.py \
1515
# --skip_snapshot \
16-
# --preload_mode=script:workloads/vibe_coding/startup_npm_vite.sh \
16+
# --preload_mode=script:workloads/startup_scripts/npm_vite.sh \
1717
# --burst_size=3 \
1818
# --search_mode=binary --search_min=10 --search_max=30 \
1919
# --ttfe_threshold_s=120
2020
#
2121
# Usage (with snapshot/restore):
2222
# python sweeps/snapshot_saturation_search.py \
23-
# --preload_mode=script:workloads/vibe_coding/startup_npm_vite.sh \
23+
# --preload_mode=script:workloads/startup_scripts/npm_vite.sh \
2424
# --burst_size=3 \
2525
# --search_mode=binary --search_min=10 --search_max=30 \
2626
# --ttfe_threshold_s=120 --restore_threshold_s=10
@@ -31,10 +31,10 @@
3131

3232
set -e
3333

34-
echo "[vibe-coding] Installing Node.js..."
34+
echo "[agent-startup] Installing Node.js..."
3535
apt-get update -qq && apt-get install -y -qq nodejs npm > /dev/null 2>&1
3636

37-
echo "[vibe-coding] Creating project scaffold..."
37+
echo "[agent-startup] Creating project scaffold..."
3838
mkdir -p /tmp/vibe-project && cd /tmp/vibe-project
3939

4040
# Create a minimal package.json with Vite
@@ -59,26 +59,26 @@ cat > index.html << 'EOF'
5959
</html>
6060
EOF
6161

62-
echo "[vibe-coding] Installing npm dependencies..."
62+
echo "[agent-startup] Installing npm dependencies..."
6363
npm install --prefer-offline 2>&1 | tail -5
6464

65-
echo "[vibe-coding] Starting Vite dev server..."
65+
echo "[agent-startup] Starting Vite dev server..."
6666
npx vite --host 0.0.0.0 --port 5173 &
6767
VITE_PID=$!
6868

69-
echo "[vibe-coding] Waiting for server to be ready..."
69+
echo "[agent-startup] Waiting for server to be ready..."
7070
MAX_WAIT=60
7171
ELAPSED=0
7272
while ! curl -s http://localhost:5173 > /dev/null 2>&1; do
7373
sleep 1
7474
ELAPSED=$((ELAPSED + 1))
7575
if [ $ELAPSED -ge $MAX_WAIT ]; then
76-
echo "[vibe-coding] ERROR: Server did not start within ${MAX_WAIT}s"
76+
echo "[agent-startup] ERROR: Server did not start within ${MAX_WAIT}s"
7777
exit 1
7878
fi
7979
done
8080

81-
echo "[vibe-coding] First page served successfully (${ELAPSED}s)"
81+
echo "[agent-startup] First page served successfully (${ELAPSED}s)"
8282

8383
# Kill the vite server — we only needed to measure startup time
8484
kill $VITE_PID 2>/dev/null || true

perfkitbenchmarker/data/k8s_agents/workloads/vibe_coding/startup_pip_fastapi.sh renamed to perfkitbenchmarker/data/k8s_agents/workloads/startup_scripts/pip_fastapi.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
# Lightweight Vibe Coding Startup Script — pip install + FastAPI
2+
# Lightweight Agent Startup Script — pip install + FastAPI
33
#
44
# Simulates a Python-based agentic sandbox cold-start:
55
# 1. Install Python packages (FastAPI + uvicorn)
@@ -12,14 +12,14 @@
1212
# Usage (cold-start only):
1313
# python sweeps/snapshot_saturation_search.py \
1414
# --skip_snapshot \
15-
# --preload_mode=script:workloads/vibe_coding/startup_pip_fastapi.sh \
15+
# --preload_mode=script:workloads/startup_scripts/pip_fastapi.sh \
1616
# --burst_size=3 \
1717
# --search_mode=binary --search_min=10 --search_max=30 \
1818
# --ttfe_threshold_s=20
1919
#
2020
# Usage (with snapshot/restore):
2121
# python sweeps/snapshot_saturation_search.py \
22-
# --preload_mode=script:workloads/vibe_coding/startup_pip_fastapi.sh \
22+
# --preload_mode=script:workloads/startup_scripts/pip_fastapi.sh \
2323
# --burst_size=3 \
2424
# --search_mode=binary --search_min=10 --search_max=30 \
2525
# --ttfe_threshold_s=20 --restore_threshold_s=10
@@ -30,10 +30,10 @@
3030

3131
set -e
3232

33-
echo "[vibe-coding] Installing Python packages..."
33+
echo "[agent-startup] Installing Python packages..."
3434
pip install --quiet fastapi uvicorn 2>&1 | tail -3
3535

36-
echo "[vibe-coding] Creating app..."
36+
echo "[agent-startup] Creating app..."
3737
cat > /tmp/app.py << 'EOF'
3838
from fastapi import FastAPI
3939
app = FastAPI()
@@ -43,23 +43,23 @@ def root():
4343
return {"status": "ready"}
4444
EOF
4545

46-
echo "[vibe-coding] Starting uvicorn server..."
46+
echo "[agent-startup] Starting uvicorn server..."
4747
python -m uvicorn app:app --host 0.0.0.0 --port 8000 --app-dir /tmp &
4848
SERVER_PID=$!
4949

50-
echo "[vibe-coding] Waiting for server to be ready..."
50+
echo "[agent-startup] Waiting for server to be ready..."
5151
MAX_WAIT=30
5252
ELAPSED=0
5353
while ! python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/')" 2>/dev/null; do
5454
sleep 1
5555
ELAPSED=$((ELAPSED + 1))
5656
if [ $ELAPSED -ge $MAX_WAIT ]; then
57-
echo "[vibe-coding] ERROR: Server did not start within ${MAX_WAIT}s"
57+
echo "[agent-startup] ERROR: Server did not start within ${MAX_WAIT}s"
5858
exit 1
5959
fi
6060
done
6161

62-
echo "[vibe-coding] First request served successfully (${ELAPSED}s)"
62+
echo "[agent-startup] First request served successfully (${ELAPSED}s)"
6363

6464
# Kill the server — we only needed to measure startup time
6565
kill $SERVER_PID 2>/dev/null || true

perfkitbenchmarker/data/k8s_agents/workloads/vibe_coding/README.md

Lines changed: 0 additions & 64 deletions
This file was deleted.

0 commit comments

Comments
 (0)