From de0460012567f41202d1f27599b862234b7acbf1 Mon Sep 17 00:00:00 2001 From: Kaiwei Tu Date: Tue, 1 Dec 2026 11:05:57 -0800 Subject: [PATCH 1/2] Install cmake and git before building DynamoRIO Differential Revision: D135200579 --- packages/common/dr_trace/install_dynamorio.sh | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/packages/common/dr_trace/install_dynamorio.sh b/packages/common/dr_trace/install_dynamorio.sh index 8184d9884..672c4baa1 100644 --- a/packages/common/dr_trace/install_dynamorio.sh +++ b/packages/common/dr_trace/install_dynamorio.sh @@ -12,8 +12,8 @@ # # Prerequisites: # - BUILD_DIR must be set to the benchmark's build directory -# - cmake, git, and a C/C++ compiler must be available -# - sudo access (to install system dependencies) +# - a C/C++ compiler must be available +# - sudo access (to install system dependencies, including cmake and git) # # After sourcing: # - DR_INSTALL is exported, pointing to the DynamoRIO install prefix @@ -34,17 +34,6 @@ if [ ! -d "${BUILD_DIR}" ]; then fail "BUILD_DIR='${BUILD_DIR}' does not exist." fi -for cmd in cmake git; do - if ! command -v "${cmd}" >/dev/null 2>&1; then - fail "'${cmd}' is not installed or not in PATH." - fi -done - -# Check for a working C++ compiler (cmake will fail late with a cryptic error) -if ! command -v c++ >/dev/null 2>&1 && ! command -v g++ >/dev/null 2>&1 && ! command -v clang++ >/dev/null 2>&1; then - fail "No C++ compiler found (need c++, g++, or clang++ in PATH)." -fi - # ---- Build configuration ---- # Pinned DynamoRIO version (cronbuild tag from GitHub) @@ -68,9 +57,20 @@ echo "[DR_TRACE] Building DynamoRIO ${DR_VERSION} from source..." # Install system dependencies for DynamoRIO and dr_trace echo "[DR_TRACE] Installing system dependencies..." if command -v apt-get >/dev/null 2>&1; then - sudo apt-get install -y -qq libelf-dev zlib1g-dev liblz4-dev libsnappy-dev + sudo apt-get install -y -qq cmake git libelf-dev zlib1g-dev liblz4-dev libsnappy-dev elif command -v dnf >/dev/null 2>&1; then - sudo dnf install -y -q elfutils-libelf-devel zlib-devel lz4-devel snappy-devel + sudo dnf install -y -q cmake git elfutils-libelf-devel zlib-devel lz4-devel snappy-devel +fi + +for cmd in cmake git; do + if ! command -v "${cmd}" >/dev/null 2>&1; then + fail "'${cmd}' is not installed or not in PATH." + fi +done + +# Check for a working C++ compiler +if ! command -v c++ >/dev/null 2>&1 && ! command -v g++ >/dev/null 2>&1 && ! command -v clang++ >/dev/null 2>&1; then + fail "No C++ compiler found (need c++, g++, or clang++ in PATH)." fi # Clone with submodules (elfutils is a submodule required by drsyms) From 7c0c07dc470ab4d35f9e730a97979b5021a9782c Mon Sep 17 00:00:00 2001 From: Kaiwei Tu Date: Tue, 1 Dec 2026 11:05:57 -0800 Subject: [PATCH 2/2] Document DynamoRIO tracing Differential Revision: D135200583 --- README.md | 9 +++++ packages/feedsim/README.md | 83 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+) diff --git a/README.md b/README.md index c208ed997..6ce2339b8 100644 --- a/README.md +++ b/README.md @@ -697,6 +697,15 @@ DCPERF_PERF_RECORD=1 ./benchpress_cli.py run oss_performance_mediawiki_mlp After the benchmark finishes, the profile `perf.data` will be available in the `benchmark_metrics_` folder. (`benchmark_metrics_/work` for SparkBench) +### Tracing + +FeedSim can record an instruction and memory trace of its server with DynamoRIO +during the final measurement window. Install with `ENABLE_DR_TRACE=1` and run +with `DCPERF_DR_TRACE=1`; see +[Tracing with DynamoRIO](packages/feedsim/README.md#tracing-with-dynamorio). +To add tracing to another benchmark, see the +[`dr_trace` library](packages/common/dr_trace/README.md). + ### Expected CPU Utilization Below is a table of our expectation on CPU utilization of these benchmarks. diff --git a/packages/feedsim/README.md b/packages/feedsim/README.md index db257f61f..d0b24475e 100644 --- a/packages/feedsim/README.md +++ b/packages/feedsim/README.md @@ -376,6 +376,89 @@ Runner-level parameters (can be passed via `extra_args` parameter): For the full list of runner flags, see `./benchmarks/feedsim/run.sh -h`. +## Tracing with DynamoRIO + +FeedSim can record an instruction and memory trace of `LeafNodeRank` with the +[DynamoRIO](https://dynamorio.org/) `drmemtrace` client during the final +measurement window. DynamoRIO is linked into `LeafNodeRank` only when enabled +at install time; a default install is unchanged. + +### Install + +```bash +ENABLE_DR_TRACE=1 ./benchpress_cli.py install feedsim_dlrm -f +``` + +This builds DynamoRIO (`cronbuild-11.90.20482`) into +`benchmarks/feedsim/third_party/dynamorio` and links it statically into +`LeafNodeRank`. Pass `-f` to rebuild an existing install without tracing. The +same build serves both `feedsim_dlrm` and `feedsim_autoscale_dlrm`. + +### Collect a trace + +Multi-instance (`feedsim_autoscale_dlrm`, traces only the instance on port +`21212`; `FEEDSIM_ADAPTIVE_DEPTH_MAX=1` caps driver depth at 1 so tracing +stays within the 700 ms SLA): + +```bash +FEEDSIM_ADAPTIVE_DEPTH_MAX=1 DCPERF_DR_TRACE=1 DR_TRACE_OUTDIR=/path/to/trace \ + ./benchpress_cli.py run feedsim_autoscale_dlrm +``` + +Single-instance (`feedsim_dlrm`): + +```bash +DCPERF_DR_TRACE=1 DR_TRACE_OUTDIR=/path/to/trace ./benchpress_cli.py run feedsim_dlrm +``` + +The runner creates `DR_TRACE_OUTDIR` automatically. During the final +measurement window, `LeafNodeRank` waits on `$DR_TRACE_OUTDIR/dr_trace_trigger`; +after `DR_TRACE_SETTLE_SECONDS`, the runner triggers tracing across all +`LeafNodeRank` threads for `DR_TRACE_DURATION_SECONDS`, then waits for the +output directory to finish flushing after the benchmark exits. Raw per-thread +files are written under +`$DR_TRACE_OUTDIR/drmemtrace.LeafNodeRank...dir/raw/`. + +| Variable | Default | Meaning | +|---|---|---| +| `DCPERF_DR_TRACE` | unset | Set to `1` to trace during the final window. | +| `DR_TRACE_OUTDIR` | `/tmp/drmemtrace_out` | Directory for the trigger pipe and output trace. | +| `DR_TRACE_SETTLE_SECONDS` | `30` | Delay from the start of the final window before triggering. | +| `DR_TRACE_DURATION_SECONDS` | `10` | Trace duration in seconds. | +| `DR_TRACE_PORT` | unset | Instance port to trace. Defaults to the sole instance, or port `21212` in multi-instance runs. | +| `DR_TRACE_TRIGGER` | `pipe` | `pipe` (runner-triggered), `delay` (10 s trace starting 15 s after server start), or `off`. | +| `DR_TRACE_FLUSH_TIMEOUT_SECONDS` | `300` | Maximum wait in seconds for trace files to finish flushing. | + +### Decode the trace + +Run `drraw2trace` on the host that collected the trace so it can read the +binaries listed in `raw/modules.log`: + +```bash +DR=./benchmarks/feedsim/third_party/dynamorio +D=/path/to/trace/drmemtrace.LeafNodeRank...dir +mkdir -p "$D/trace" +"$DR/tools/bin64/drraw2trace" -indir "$D/raw" -out "$D/trace" -jobs "$(nproc)" +``` + +Optional checks with `drcachesim`: + +```bash +"$DR/bin64/drrun" -t drcachesim -simulator_type invariant_checker -indir "$D" +"$DR/bin64/drrun" -t drcachesim -simulator_type basic_counts -indir "$D" +``` + +### Notes + +- **Disk space:** A 10 s trace can require tens of GB for raw and decoded + files combined; point `DR_TRACE_OUTDIR` to a filesystem with enough free + space. +- **Performance impact:** Tracing degrades benchmark performance compared to a + non-tracing run (it stalls `LeafNodeRank` during capture and flush). Do not + use a traced run's score as a performance result; the benchmark JSON marks + traced runs with `"dr_trace": 1`. +- **Unsupported jobs:** `feedsim_dlrm_mini` is not supported. + ## Legacy — `feedsim_autoscale` (v1) Again, due to the fundamental change in software architecture and threading model,