|
| 1 | +# Speed and memory benchmark |
| 2 | + |
| 3 | +`bench-full` records timing and peak resident memory in the same JSON result for |
| 4 | +every implementation run. Memory collection is always on; no additional flag is |
| 5 | +required. |
| 6 | + |
| 7 | +Each passed item in `results` contains a `memory` block with: |
| 8 | + |
| 9 | +- `rss_self_kb`: peak RSS of the benchmark's Python process. For Rustwright, |
| 10 | + this includes the in-process Rust client. For `playwright-python`, it includes |
| 11 | + the Python client but not its Node driver. |
| 12 | +- `rss_tree_kb`: peak summed RSS of that Python process and all descendants, |
| 13 | + including the driver and Chromium process tree. |
| 14 | +- sampling provenance, interval, availability, and sample count. |
| 15 | + |
| 16 | +The sampler uses the same method as `benchmarks/async_concurrency_load.py`: it |
| 17 | +walks parent/child PIDs with `ps`, reads RSS in KiB, samples every 50 ms, and |
| 18 | +retains the independent peak for the root and whole tree. It takes one baseline |
| 19 | +before entering the implementation run, then samples on a daemon background |
| 20 | +thread; case timers continue to wrap only the operation under test, so `ps` |
| 21 | +calls are not executed on the latency hot path. If `ps`, the tree walk, or an |
| 22 | +individual RSS read is unavailable, the corresponding value is `null` and the |
| 23 | +benchmark continues. |
| 24 | + |
| 25 | +Whole-tree RSS is normally Chromium-dominated. Report `rss_tree_kb` for the |
| 26 | +actual end-to-end process cost and `rss_self_kb` alongside it as the available |
| 27 | +library-host portion. The latter is not perfectly symmetric: |
| 28 | +`playwright-python` puts additional client logic in its Node child, while |
| 29 | +Rustwright keeps its client in the measured Python process. The harness does not |
| 30 | +attempt to classify driver children separately from Chromium, because command |
| 31 | +names and process layouts vary by browser build and platform. |
| 32 | + |
| 33 | +For repeated runs, the raw peak remains in every `results` item and `aggregate` |
| 34 | +contains distribution summaries for both RSS fields. Benchmark output belongs |
| 35 | +under the ignored `.benchmark-data/` directory; do not commit raw result JSON, |
| 36 | +terminal logs, or generated reports. |
| 37 | + |
| 38 | +## Exact Testbox dispatch |
| 39 | + |
| 40 | +From the repository root, this command warms a Blacksmith Testbox, builds the |
| 41 | +benchmark image, runs only Rustwright and `playwright-python`, downloads the |
| 42 | +ignored JSON artifact, and records strict-suite speed plus memory together: |
| 43 | + |
| 44 | +```bash |
| 45 | +RUSTWRIGHT_TESTBOX_DOWNLOAD_RESULTS=1 tools/run_benchmark_testbox.sh -- 'set -euo pipefail; mkdir -p .benchmark-data/results; timestamp="$(date -u +%Y%m%dT%H%M%SZ)"; BENCHMARK_FULL_ITERATIONS=10 TEST_DOCKER_MEMORY_LIMIT=8g RUSTWRIGHT_DOCKER_IMAGE=rustwright-verify-testbox tools/docker_test.sh bench-full --impl rustwright --impl playwright --suite strict --lifecycle warm-browser --repetitions 3 --output ".benchmark-data/results/bench-full-strict-speed-memory-${timestamp}.json" --json' |
| 46 | +``` |
| 47 | + |
| 48 | +For a local Docker preflight using an already-built image, run: |
| 49 | + |
| 50 | +```bash |
| 51 | +BENCHMARK_FULL_ITERATIONS=10 TEST_DOCKER_MEMORY_LIMIT=8g tools/docker_test.sh bench-full --impl rustwright --impl playwright --suite strict --lifecycle warm-browser --repetitions 3 --output .benchmark-data/results/bench-full-strict-speed-memory.json --json |
| 52 | +``` |
0 commit comments