Flip T3 to substrate-initiated actuator commands

This commit is contained in:
Valère Plantevin
2026-05-13 15:03:23 -04:00
parent 272d3b3c59
commit baa075fe0f
22 changed files with 1003 additions and 749 deletions

View File

@@ -112,7 +112,7 @@ ENTITIES_LIST=(10000 50000 100000 200000)
LOSS_LIST=(0 1 5)
for entities in "${ENTITIES_LIST[@]}"; do
devices=$(( entities / 5 ))
devices=$(( entities / 7 ))
for loss in "${LOSS_LIST[@]}"; do
# Apply tc netem loss

View File

@@ -8,10 +8,11 @@
# throughput ceiling on this host and where the lossy-tier kicks in.
# Output: data/local/scaling.csv
#
# 2. Cross-tier isolation. Set T3_RATE_HZ=<N> to run a constant T3 baseline
# in parallel with the T1 sweep. The CSV gains substrate-side T3 latency
# columns. If T3 P99 stays flat as T1 climbs orders of magnitude, the
# paper's composition thesis is supported.
# 2. Cross-tier isolation. Set T3_RATE_HZ=<N> to enable the substrate's
# synthetic T3 driver (server-initiated Relay commands to every
# connected device at that rate) in parallel with the T1 sweep. The CSV
# gains substrate-side T3 latency columns. If T3 P99 stays flat as T1
# climbs orders of magnitude, the paper's composition thesis is supported.
# Output: data/local/cross_tier.csv
#
# Holds:
@@ -19,7 +20,6 @@
# - device count $DEVICES (default 100, single-sensor profile)
# - window $WINDOW_S (default 20s steady-state per rate)
# - T3 baseline $T3_RATE_HZ (default 0 = disabled)
# - T3 timeout $T3_TIMEOUT_MS (default 2000ms)
# - build profile $BUILD (release | debug; default release)
#
# Sweeps:
@@ -48,7 +48,6 @@ TICK_RATE_HZ="${TICK_RATE_HZ:-1000}"
WARMUP_S="${WARMUP_S:-3}"
WINDOW_S="${WINDOW_S:-20}"
T3_RATE_HZ="${T3_RATE_HZ:-0}"
T3_TIMEOUT_MS="${T3_TIMEOUT_MS:-2000}"
BUILD="${BUILD:-release}"
RATES=("${@}")
if [[ ${#RATES[@]} -eq 0 ]]; then
@@ -101,8 +100,10 @@ mkdir -p "$LOG_DIR"
SUB_LOG="$LOG_DIR/substrate.log"
: > "$SUB_LOG"
step "Starting substrate (tick_rate_hz=$TICK_RATE_HZ, log: $SUB_LOG)"
APP_SIMULATION__TICK_RATE_HZ="$TICK_RATE_HZ" RUST_LOG=warn "$SUBSTRATE" >"$SUB_LOG" 2>&1 &
step "Starting substrate (tick_rate_hz=$TICK_RATE_HZ, synthetic_t3=$T3_RATE_HZ Hz, log: $SUB_LOG)"
APP_SIMULATION__TICK_RATE_HZ="$TICK_RATE_HZ" \
APP_NETWORK__SYNTHETIC_T3_RATE_HZ="$T3_RATE_HZ" \
RUST_LOG=warn "$SUBSTRATE" >"$SUB_LOG" 2>&1 &
SUBSTRATE_PID=$!
# Wait for /metrics
@@ -132,7 +133,7 @@ get_value() {
# --- sweep ---
mkdir -p "$(dirname "$OUT_CSV")"
echo "rate_hz,t3_rate_hz,devices,tick_rate_hz,window_s,t1_received,t1_dropped,t1_p50_us,t1_p99_us,t1_p999_us,t3_received,t3_no_handler,t3_p50_us,t3_p99_us,t3_p999_us,tick_hz,rss_mb,channel_depth_max" > "$OUT_CSV"
echo "rate_hz,t3_rate_hz,devices,tick_rate_hz,window_s,t1_received,t1_dropped,t1_p50_us,t1_p99_us,t1_p999_us,t3_received,t3_no_route,t3_p50_us,t3_p99_us,t3_p999_us,tick_hz,rss_mb,channel_depth_max" > "$OUT_CSV"
if [[ "$CROSS_TIER" == "1" ]]; then
step "Sweeping T1 + holding T3 at ${T3_RATE_HZ} Hz (warmup ${WARMUP_S}s, window ${WINDOW_S}s, devices=$DEVICES)"
@@ -172,8 +173,9 @@ peak_depth() {
}
for rate in "${RATES[@]}"; do
# Launch simulator in background. In cross-tier mode it drives both T1
# and T3 on the same connection; otherwise just T1.
# Launch simulator: T1 sweep only. In cross-tier mode the substrate's
# synthetic_t3 driver (enabled via env at startup) generates the T3
# traffic; the simulator just keeps the connection alive and pushes T1.
sim_args=(
--profile single
--sensor-type generic
@@ -181,9 +183,6 @@ for rate in "${RATES[@]}"; do
--count 0
--devices "$DEVICES"
)
if [[ "$CROSS_TIER" == "1" ]]; then
sim_args+=(--t3-rate-hz "$T3_RATE_HZ" --t3-timeout-ms "$T3_TIMEOUT_MS")
fi
RUST_LOG=warn "$SIMULATOR" "${sim_args[@]}" >"$LOG_DIR/sim_${rate}.log" 2>&1 &
SIM_PID=$!
@@ -193,7 +192,7 @@ for rate in "${RATES[@]}"; do
rec_before=$(get_value "$BEFORE" 'substrate_received_total\{tier="t1"\}')
drop_before=$(get_value "$BEFORE" 'substrate_dropped_total\{tier="t1"\}')
t3_rec_before=$(get_value "$BEFORE" 'substrate_received_total\{tier="t3"\}')
t3_nh_before=$(get_value "$BEFORE" 'substrate_t3_no_handler_total')
t3_nr_before=$(get_value "$BEFORE" 'substrate_t3_outbound_no_route_total')
depth_max=$(peak_depth t1)
@@ -209,7 +208,7 @@ for rate in "${RATES[@]}"; do
p999=$(get_value "$AFTER" 'substrate_latency_us\{tier="t1",quantile="0.999"\}')
t3_rec_after=$(get_value "$AFTER" 'substrate_received_total\{tier="t3"\}')
t3_nh_after=$(get_value "$AFTER" 'substrate_t3_no_handler_total')
t3_nr_after=$(get_value "$AFTER" 'substrate_t3_outbound_no_route_total')
t3_p50=$(get_value "$AFTER" 'substrate_latency_us\{tier="t3",quantile="0.5"\}')
t3_p99=$(get_value "$AFTER" 'substrate_latency_us\{tier="t3",quantile="0.99"\}')
t3_p999=$(get_value "$AFTER" 'substrate_latency_us\{tier="t3",quantile="0.999"\}')
@@ -221,7 +220,7 @@ for rate in "${RATES[@]}"; do
received=$(awk -v a="$rec_after" -v b="$rec_before" 'BEGIN { printf "%d", a-b }')
dropped=$(awk -v a="$drop_after" -v b="$drop_before" 'BEGIN { printf "%d", a-b }')
t3_received=$(awk -v a="$t3_rec_after" -v b="$t3_rec_before" 'BEGIN { printf "%d", a-b }')
t3_no_handler=$(awk -v a="$t3_nh_after" -v b="$t3_nh_before" 'BEGIN { printf "%d", a-b }')
t3_no_route=$(awk -v a="$t3_nr_after" -v b="$t3_nr_before" 'BEGIN { printf "%d", a-b }')
rss_mb=$(awk -v r="$rss" 'BEGIN { printf "%.1f", r/1048576 }')
tick_hz_fmt=$(awk -v t="$tick_hz" 'BEGIN { printf "%.1f", t }')
@@ -237,7 +236,7 @@ for rate in "${RATES[@]}"; do
"$tick_hz_fmt" "$rss_mb"
fi
echo "$rate,$T3_RATE_HZ,$DEVICES,$TICK_RATE_HZ,$WINDOW_S,$received,$dropped,${p50:-0},${p99:-0},${p999:-0},$t3_received,$t3_no_handler,${t3_p50:-0},${t3_p99:-0},${t3_p999:-0},$tick_hz_fmt,$rss_mb,$depth_max" >> "$OUT_CSV"
echo "$rate,$T3_RATE_HZ,$DEVICES,$TICK_RATE_HZ,$WINDOW_S,$received,$dropped,${p50:-0},${p99:-0},${p999:-0},$t3_received,$t3_no_route,${t3_p50:-0},${t3_p99:-0},${t3_p999:-0},$tick_hz_fmt,$rss_mb,$depth_max" >> "$OUT_CSV"
# Tiny breather between rate points so the substrate's summary window
# doesn't carry over.