Skip to content

minima-ws: enable reactor-thread short-circuit (RCA fast path)#823

Merged
MDA2AV merged 2 commits into
mainfrom
minima-ws-shortcircuit
Jun 6, 2026
Merged

minima-ws: enable reactor-thread short-circuit (RCA fast path)#823
MDA2AV merged 2 commits into
mainfrom
minima-ws-shortcircuit

Conversation

@MDA2AV
Copy link
Copy Markdown
Owner

@MDA2AV MDA2AV commented Jun 6, 2026

Description

minima-ws (merged in #816) vendored Minima's Reactor.cs with the inline fast paths in EnqueueReturnQ / EnqueueFlush / EnqueueRecycle commented out — so every buffer return / flush / recycle went through the cross-thread MPSC queue + an eventfd wake.

Since minima-ws runs with RunContinuationsAsynchronously = false, the handler resumes inline on the reactor thread. That means the caller of Enqueue{Return,Flush,Recycle} is already the reactor thread, so it can hit the ring directly (ReturnBufferDirect / SubmitSend / Recycle) instead of enqueuing + waking. This uncomments the three fast paths to match the current Minima engine (and the new minima H1 entry).

Pure perf fix — 6 lines, no behavior change for the WS echo contract. Builds clean.

…path)

minima-ws vendored Minima's Reactor.cs with the inline fast paths in
EnqueueReturnQ / EnqueueFlush / EnqueueRecycle commented out, so buffer
return / flush / recycle went through the cross-thread MPSC queue + eventfd
wake. With RCA=false the handler resumes inline on the reactor thread, so
those callers are already on the reactor thread and can return the buffer,
submit the send, or recycle directly on the ring. Uncomment the three fast
paths to match the current Minima engine.
@MDA2AV
Copy link
Copy Markdown
Owner Author

MDA2AV commented Jun 6, 2026

/benchmark -f minima-ws --save

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 6, 2026

👋 /benchmark request received. A collaborator will review and approve the run.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 6, 2026

Benchmark Results

Framework: minima-ws | Test: all tests

Test Conn RPS CPU Mem Δ RPS Δ Mem
echo-ws 512 4,145,985 6167.3% 442MiB NEW NEW
echo-ws 4096 4,263,272 6197.1% 542MiB NEW NEW
echo-ws 16384 3,987,143 6393.2% 749MiB NEW NEW
echo-ws-pipeline 512 62,333,664 6245.8% 408MiB NEW NEW
echo-ws-pipeline 4096 63,975,814 6445.7% 511MiB NEW NEW
echo-ws-pipeline 16384 59,426,656 6388.0% 814MiB NEW NEW
Full log
  Thread Stats   Avg      p50      p90      p99    p99.9
    Latency    132us    120us    204us    320us    561us

  307772896 frames sent in 5.00s, 307772896 frames received
  Throughput: 61.53M req/s
  Bandwidth:  410.78MB/s
  WS upgrades: 512
  WS frames:   307772896
  Latency samples: 307771852 / 307772896 responses (100.0%)
[info] CPU 6296.0% | Mem 408MiB

[run 3/3]
gcannon v0.5.3 [WS]
  Target:    localhost:8080/ws
  Threads:   64
  Conns:     512 (8/thread)
  Pipeline:  16
  Req/conn:  unlimited (keep-alive)
  Expected:  200
  Duration:  5s


  Thread Stats   Avg      p50      p90      p99    p99.9
    Latency    130us    124us    190us    294us    563us

  311668320 frames sent in 5.00s, 311668320 frames received
  Throughput: 62.32M req/s
  Bandwidth:  416.00MB/s
  WS upgrades: 512
  WS frames:   311668320
  Latency samples: 311667456 / 311668320 responses (100.0%)
[info] CPU 6245.8% | Mem 408MiB

=== Best: 62333664 req/s (CPU: 6245.8%, Mem: 408MiB) ===
[info] saved results/echo-ws-pipeline/512/minima-ws.json
httparena-bench-minima-ws
httparena-bench-minima-ws

==============================================
=== minima-ws / echo-ws-pipeline / 4096c (tool=gcannon) ===
==============================================
[info] ws-only framework — skipping HTTP probe (sleep 2s for startup)

[run 1/3]
gcannon v0.5.3 [WS]
  Target:    localhost:8080/ws
  Threads:   64
  Conns:     4096 (64/thread)
  Pipeline:  16
  Req/conn:  unlimited (keep-alive)
  Expected:  200
  Duration:  5s


  Thread Stats   Avg      p50      p90      p99    p99.9
    Latency   1.07ms   1.02ms   1.28ms   2.12ms   5.46ms

  302162272 frames sent in 5.00s, 302099808 frames received
  Throughput: 60.40M req/s
  Bandwidth:  403.33MB/s
  WS upgrades: 4096
  WS frames:   302099808
  Latency samples: 302099808 / 302099808 responses (100.0%)
[info] CPU 6041.1% | Mem 474MiB

[run 2/3]
gcannon v0.5.3 [WS]
  Target:    localhost:8080/ws
  Threads:   64
  Conns:     4096 (64/thread)
  Pipeline:  16
  Req/conn:  unlimited (keep-alive)
  Expected:  200
  Duration:  5s


  Thread Stats   Avg      p50      p90      p99    p99.9
    Latency   1.02ms   1.01ms   1.26ms   1.43ms   1.83ms

  319879184 frames sent in 5.00s, 319879072 frames received
  Throughput: 63.96M req/s
  Bandwidth:  426.95MB/s
  WS upgrades: 4096
  WS frames:   319879072
  Latency samples: 319906494 / 319879072 responses (100.0%)
[info] CPU 6445.7% | Mem 511MiB

[run 3/3]
gcannon v0.5.3 [WS]
  Target:    localhost:8080/ws
  Threads:   64
  Conns:     4096 (64/thread)
  Pipeline:  16
  Req/conn:  unlimited (keep-alive)
  Expected:  200
  Duration:  5s


  Thread Stats   Avg      p50      p90      p99    p99.9
    Latency   1.03ms   1.03ms   1.21ms   1.39ms   4.00ms

  318506992 frames sent in 5.00s, 318506656 frames received
  Throughput: 63.68M req/s
  Bandwidth:  425.09MB/s
  WS upgrades: 4096
  WS frames:   318506656
  Latency samples: 318522272 / 318506656 responses (100.0%)
[info] CPU 6234.7% | Mem 538MiB

=== Best: 63975814 req/s (CPU: 6445.7%, Mem: 511MiB) ===
[info] saved results/echo-ws-pipeline/4096/minima-ws.json
httparena-bench-minima-ws
httparena-bench-minima-ws

==============================================
=== minima-ws / echo-ws-pipeline / 16384c (tool=gcannon) ===
==============================================
[info] ws-only framework — skipping HTTP probe (sleep 2s for startup)

[run 1/3]
gcannon v0.5.3 [WS]
  Target:    localhost:8080/ws
  Threads:   64
  Conns:     16384 (256/thread)
  Pipeline:  16
  Req/conn:  unlimited (keep-alive)
  Expected:  200
  Duration:  5s


  Thread Stats   Avg      p50      p90      p99    p99.9
    Latency   4.23ms   4.29ms   4.74ms   6.26ms   17.30ms

  272110592 frames sent in 5.00s, 271848448 frames received
  Throughput: 54.35M req/s
  Bandwidth:  363.21MB/s
  WS upgrades: 16384
  WS frames:   271848448
  Latency samples: 271848448 / 271848448 responses (100.0%)
[info] CPU 5686.6% | Mem 747MiB

[run 2/3]
gcannon v0.5.3 [WS]
  Target:    localhost:8080/ws
  Threads:   64
  Conns:     16384 (256/thread)
  Pipeline:  16
  Req/conn:  unlimited (keep-alive)
  Expected:  200
  Duration:  5s


  Thread Stats   Avg      p50      p90      p99    p99.9
    Latency   4.31ms   4.31ms   4.76ms   5.36ms   10.40ms

  297391313 frames sent in 5.00s, 297133281 frames received
  Throughput: 59.40M req/s
  Bandwidth:  396.96MB/s
  WS upgrades: 16383
  WS frames:   297133281
  Latency samples: 297133281 / 297133281 responses (100.0%)
[info] CPU 6388.0% | Mem 814MiB

[run 3/3]
gcannon v0.5.3 [WS]
  Target:    localhost:8080/ws
  Threads:   64
  Conns:     16384 (256/thread)
  Pipeline:  16
  Req/conn:  unlimited (keep-alive)
  Expected:  200
  Duration:  5s


  Thread Stats   Avg      p50      p90      p99    p99.9
    Latency   4.33ms   4.33ms   4.82ms   5.33ms   12.60ms

  296834544 frames sent in 5.00s, 296576512 frames received
  Throughput: 59.29M req/s
  Bandwidth:  396.18MB/s
  WS upgrades: 16383
  WS frames:   296576512
  Latency samples: 296576512 / 296576512 responses (100.0%)
[info] CPU 6112.0% | Mem 837MiB

=== Best: 59426656 req/s (CPU: 6388.0%, Mem: 814MiB) ===
[info] saved results/echo-ws-pipeline/16384/minima-ws.json
httparena-bench-minima-ws
httparena-bench-minima-ws
[info] rebuilding site/data/*.json
[updated] /home/diogo/actions-runner/_work/HttpArena/HttpArena/site/data/frameworks.json
[updated] /home/diogo/actions-runner/_work/HttpArena/HttpArena/site/data/echo-ws-16384.json
[updated] /home/diogo/actions-runner/_work/HttpArena/HttpArena/site/data/echo-ws-4096.json
[updated] /home/diogo/actions-runner/_work/HttpArena/HttpArena/site/data/echo-ws-512.json
[updated] /home/diogo/actions-runner/_work/HttpArena/HttpArena/site/data/echo-ws-pipeline-16384.json
[updated] /home/diogo/actions-runner/_work/HttpArena/HttpArena/site/data/echo-ws-pipeline-4096.json
[updated] /home/diogo/actions-runner/_work/HttpArena/HttpArena/site/data/echo-ws-pipeline-512.json
[updated] /home/diogo/actions-runner/_work/HttpArena/HttpArena/site/data/current.json
[info] done
[info] restoring loopback MTU to 65536

@MDA2AV MDA2AV merged commit 1417aec into main Jun 6, 2026
@MDA2AV MDA2AV deleted the minima-ws-shortcircuit branch June 7, 2026 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant