Last active
April 7, 2026 18:59
-
-
Save Frando/685efc8a883fad12aeb2daef19c8570a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # Debug relay transfer performance across different relay servers. | |
| # | |
| # Runs a provide+fetch pair for each relay, with full trace logging. | |
| # Results go into ./logs/relay-debug-<timestamp>/. | |
| set -euo pipefail | |
| RELAYS=( | |
| "euc1-1.relay.n0.iroh-canary.iroh.link" | |
| "use1-1.relay.n0.iroh-canary.iroh.link" | |
| ) | |
| SIZE="${SIZE:-1m}" | |
| MODE="${MODE:-bidi}" | |
| if [ -n "${TRANSFER:-}" ]; then | |
| : | |
| else | |
| target_dir=$(cargo metadata --format-version 1 --no-deps 2>/dev/null | jq -r '.target_directory') | |
| candidate="${target_dir}/release/examples/transfer" | |
| if [ -x "$candidate" ]; then | |
| TRANSFER="$candidate" | |
| else | |
| echo "ERROR: release transfer example not found at ${candidate}" | |
| echo "Build it first: cargo build --release --example transfer --all-features" | |
| echo "or set path to transfer binary with TRANSFER=/path/to/transfer" | |
| exit 1 | |
| fi | |
| fi | |
| ts=$(date +%y%m%d-%H%M%S) | |
| OUTDIR="./logs/relay-debug-${ts}" | |
| mkdir -p "$OUTDIR" | |
| export RUST_LOG="${RUST_LOG:-iroh=trace,noq=trace}" | |
| for relay_host in "${RELAYS[@]}"; do | |
| relay_url="https://${relay_host}" | |
| label="${relay_host%%.*}" | |
| echo "=== ${label} (${relay_url}) ===" | |
| ping -c 2 -W 2 "$relay_host" 2>&1 | tee "${OUTDIR}/${label}-ping.txt" || true | |
| echo "" | |
| # Start provide in background | |
| "$TRANSFER" provide \ | |
| --relay-only \ | |
| --relay-url "$relay_url" \ | |
| --output json \ | |
| 2>"${OUTDIR}/${label}-provide.log" \ | |
| >"${OUTDIR}/${label}-provide.json" & | |
| provide_pid=$! | |
| # Wait for the endpoint id to appear in the JSON output | |
| endpoint_id="" | |
| for i in $(seq 1 30); do | |
| sleep 0.5 | |
| if [ -f "${OUTDIR}/${label}-provide.json" ]; then | |
| endpoint_id=$(grep -o '"endpoint_id":"[^"]*"' "${OUTDIR}/${label}-provide.json" 2>/dev/null | head -1 | cut -d'"' -f4 || true) | |
| if [ -n "$endpoint_id" ]; then | |
| break | |
| fi | |
| fi | |
| done | |
| if [ -z "$endpoint_id" ]; then | |
| echo "ERROR: could not get endpoint_id from provide after 15s" | |
| kill "$provide_pid" 2>/dev/null || true | |
| wait "$provide_pid" 2>/dev/null || true | |
| continue | |
| fi | |
| echo "endpoint_id: ${endpoint_id}" | |
| if ! kill -0 "$provide_pid" 2>/dev/null; then | |
| echo "ERROR: provide died before fetch could start. Check ${OUTDIR}/${label}-provide.log" | |
| wait "$provide_pid" 2>/dev/null || true | |
| continue | |
| fi | |
| echo "fetching..." | |
| # Run fetch. Trace logs go to file, text output to terminal + file. | |
| "$TRANSFER" fetch "$endpoint_id" \ | |
| --relay-only \ | |
| --relay-url "$relay_url" \ | |
| --remote-relay-url "$relay_url" \ | |
| ${SIZE:+--size "$SIZE"} \ | |
| --mode "$MODE" \ | |
| --output text \ | |
| 2>"${OUTDIR}/${label}-fetch.log" | | |
| tee "${OUTDIR}/${label}-fetch.txt" || | |
| echo "fetch exited with $?" | |
| # Stop provide | |
| kill "$provide_pid" 2>/dev/null || true | |
| wait "$provide_pid" 2>/dev/null || true | |
| echo "" | |
| done | |
| echo "--- Summary ---" | |
| for relay_host in "${RELAYS[@]}"; do | |
| label="${relay_host%%.*}" | |
| echo "" | |
| echo "=== ${label} ===" | |
| grep "MiB in\|KiB in\|GiB in" "${OUTDIR}/${label}-fetch.txt" 2>/dev/null || echo "(no results)" | |
| grep "time=" "${OUTDIR}/${label}-ping.txt" 2>/dev/null | tail -1 || true | |
| done | |
| echo "" | |
| echo "Logs in: ${OUTDIR}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment