benches: baseline results

Two compile fixes:
- tokio_favored.rs bench_mpsc_smarm: consumer spawn closure returned u64 via
  bare 'count' tail expression; smarm::Runtime::run() requires FnOnce()->().
  Fixed to 'let _ = count;'. Same fix on the consumer.join() call site.
- smarm_favored.rs bench_unc_smarm: same pattern, same fix.

Baseline run: Intel Xeon @ 2.80GHz, 1 core, kernel 6.18.5, rustc 1.95.0,
smarm 0.3.0, no RUSTFLAGS. Single-CPU sandbox — N-thread rows identical to
1-thread; scaling sweep limited to 1 thread.

Notable findings:
- deep_recursion: tokio wins (22 vs 62 us); mmap stack alloc cost dominates
  for single-use actors at depth 500.
- yield_in_hot_loop: tokio wins (138 vs 182 ms); smarm mutex overhead on
  yield_now exceeds expected naked-switch advantage on 1 CPU.
- mpsc_contention/uncontended_channel/catch_unwind_panics: smarm wins as
  predicted.
- spawn_storm_busy: smarm 47x slower; global mutex saturated by bg yielders.
This commit is contained in:
Bench
2026-05-24 10:49:23 +00:00
committed by smarm
parent 4b348d12be
commit 6d1c59fb99
8 changed files with 1205 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
smarm general benchmarks
available parallelism: 1 threads
ITERS=15 (+1 warmup, discarded)
CHAIN_DEPTH=1000, YIELD_TASKS=200×1000, PRIME_N=400000/64 workers, PP_ROUNDS=1000
================================================================================
chained_spawn: depth 1000
================================================================================
runtime | result | median µs | min µs | max µs
--------------------------------------------------------------------------------
smarm 1-thread | 1000 | 7136 | 6929 | 8347
smarm 1-thread | 1000 | 6979 | 6790 | 7364
tokio current_thread | 1000 | 113 | 112 | 322
tokio multi-thread | 1000 | 176 | 170 | 355
================================================================================
yield_many: 200 tasks × 1000 yields
================================================================================
runtime | result | median µs | min µs | max µs
--------------------------------------------------------------------------------
smarm 1-thread | 200000 | 40079 | 39606 | 41913
smarm 1-thread | 200000 | 40073 | 39298 | 43173
tokio current_thread | 200000 | 14571 | 14430 | 14670
tokio multi-thread | 200000 | 14044 | 13306 | 14432
================================================================================
fan_out_compute: primes in [2, 400000) across 64
================================================================================
runtime | result | median µs | min µs | max µs
--------------------------------------------------------------------------------
smarm 1-thread | 33860 | 19347 | 19185 | 19703
smarm 1-thread | 33860 | 19461 | 19202 | 21172
tokio current_thread | 33860 | 18616 | 18553 | 18987
tokio multi-thread | 33860 | 18905 | 18755 | 19035
================================================================================
ping_pong_oneshot: 1000 rounds
================================================================================
runtime | result | median µs | min µs | max µs
--------------------------------------------------------------------------------
smarm 1-thread | 1000 | 13731 | 13555 | 15545
smarm 1-thread | 1000 | 14176 | 13870 | 14892
tokio current_thread | 1000 | 828 | 788 | 939
tokio multi-thread | 1000 | 3342 | 3233 | 3624

View File

@@ -0,0 +1,34 @@
smarm multi-scheduler benchmarks
available parallelism: 1 threads
PRIME_N=400000, WORKERS=64, PING_ROUNDS=10000, SPAWN_COUNT=1000
================================================================================
Fan-out/fan-in: count primes in [2, 400000) across 64 workers
================================================================================
runtime | result | median µs | min µs | max µs
--------------------------------------------------------------------------------
baseline (serial) | 33860 | 18581 | 18519 | 18905
smarm single-thread | 33860 | 19467 | 19354 | 22082
smarm 1-thread | 33860 | 19345 | 19287 | 19653
tokio current_thread | 33860 | 18681 | 18591 | 18982
tokio multi-thread | 33860 | 18948 | 18726 | 19212
================================================================================
Ping-pong: 10000 round-trips between two actors
================================================================================
runtime | result | median µs | min µs | max µs
--------------------------------------------------------------------------------
smarm single-thread | 10000 | 2547 | 2473 | 2841
smarm 1-thread | 10000 | 2546 | 2518 | 2702
tokio current_thread | 10000 | 1221 | 1168 | 1366
tokio multi-thread | 10000 | 1487 | 1316 | 2331
================================================================================
Spawn throughput: 1000 actors spawned and joined
================================================================================
runtime | result | median µs | min µs | max µs
--------------------------------------------------------------------------------
smarm single-thread | 1000 | 8934 | 8066 | 12204
smarm 1-thread | 1000 | 8102 | 8041 | 10849
tokio current_thread | 1000 | 212 | 210 | 331
tokio multi-thread | 1000 | 330 | 301 | 604

View File

@@ -0,0 +1,7 @@
Counting primes in [2, 200000) across 16 workers, 5 iterations each
runtime | primes found | median | min | max
--------------------------------------------------------------------------------
baseline | primes: 17984 | median: 7244 µs | min: 7231 µs | max: 7509 µs
smarm | primes: 17984 | median: 7592 µs | min: 7505 µs | max: 8130 µs
tokio | primes: 17984 | median: 7263 µs | min: 7225 µs | max: 9067 µs

View File

@@ -0,0 +1,40 @@
smarm smarm-favored benchmarks
available parallelism: 1 threads
ITERS=15 (+1 warmup, discarded)
RECURSE_DEPTH=500, HOT_YIELDS=500000×2, UNCONT_MSGS=1000000, PANIC_TASKS=10000
================================================================================
deep_recursion: depth 500
================================================================================
runtime | result | median µs | min µs | max µs
--------------------------------------------------------------------------------
smarm 1-thread | 1 | 62 | 59 | 682
smarm 1-thread | 1 | 71 | 61 | 210
tokio current_thread | 1 | 22 | 22 | 23
tokio multi-thread | 1 | 44 | 38 | 79
================================================================================
yield_in_hot_loop: 2 actors × 500000 yields (single thread)
================================================================================
runtime | result | median µs | min µs | max µs
--------------------------------------------------------------------------------
smarm 1-thread | 1000000 | 182177 | 180380 | 184410
tokio current_thread | 1000000 | 138335 | 136097 | 141196
================================================================================
uncontended_channel: 1→1, 1000000 msgs (single thread)
================================================================================
runtime | result | median µs | min µs | max µs
--------------------------------------------------------------------------------
smarm 1-thread | 1000000 | 31473 | 28719 | 33113
tokio current_thread | 1000000 | 51925 | 51205 | 53043
================================================================================
catch_unwind_panics: 10000 tasks, 50% panic
================================================================================
runtime | result | median µs | min µs | max µs
--------------------------------------------------------------------------------
smarm 1-thread | 10000 | 112306 | 109702 | 119859
smarm 1-thread | 10000 | 114305 | 112030 | 121326
tokio current_thread | 10000 | 151443 | 150949 | 153800
tokio multi-thread | 10000 | 161344 | 160385 | 167573

View File

@@ -0,0 +1,42 @@
smarm tokio-favored benchmarks
available parallelism: 1 threads
ITERS=15 (+1 warmup, discarded)
STORM_BACKGROUND=8, STORM_SPAWN=10000, MPSC=32×10000, TIMER_ACTORS=10000 (110 ms), SCALING_N=400000/64
================================================================================
spawn_storm_busy: 8 bg yielders + 10000 zero-work spawns
================================================================================
runtime | result | median µs | min µs | max µs
--------------------------------------------------------------------------------
smarm 1-thread | 10000 | 105512 | 102322 | 120552
smarm 1-thread | 10000 | 107113 | 104048 | 112377
tokio current_thread | 10000 | 2222 | 2124 | 2506
tokio multi-thread | 10000 | 4546 | 3833 | 7305
================================================================================
mpsc_contention: 32 producers × 10000 msgs → 1 consumer
================================================================================
runtime | result | median µs | min µs | max µs
--------------------------------------------------------------------------------
smarm 1-thread | 320000 | 10456 | 10331 | 10639
smarm 1-thread | 320000 | 10395 | 9201 | 10549
tokio current_thread | 320000 | 17348 | 16639 | 19061
tokio multi-thread | 320000 | 18628 | 17499 | 19298
================================================================================
many_timers: 10000 actors sleeping 110 ms
================================================================================
runtime | result | median µs | min µs | max µs
--------------------------------------------------------------------------------
smarm 1-thread | 10000 | 120242 | 116239 | 127200
smarm 1-thread | 10000 | 121023 | 113997 | 127826
tokio current_thread | 10000 | 13581 | 13182 | 14415
tokio multi-thread | 10000 | 14266 | 14084 | 14843
================================================================================
multi_thread_scaling: primes in [2, 400000) across 64 workers
================================================================================
runtime | result | median µs | min µs | max µs
--------------------------------------------------------------------------------
smarm 1-thread | 33860 | 19852 | 19601 | 22679
tokio multi 1-thread | 33860 | 19638 | 18994 | 20102