Skip to content

[Fusion] Run the plan executor inline outside the thread pool with two socket engines per processor - #10890

Merged
michaelstaib merged 3 commits into
mainfrom
perf/inline-executor-wake
Nov 12, 2026
Merged

michaelstaib merged 3 commits into
mainfrom
perf/inline-executor-wake

Conversation

@michaelstaib

Copy link
Copy Markdown
Member

With inline socket completions, which the official benchmark uses, subgraph responses complete on socket threads, and waking the plan executor through the thread pool cost about 1 ms per request on the critical path. The executor now continues directly on the socket thread that delivered the response, but only when DOTNET_SYSTEM_NET_SOCKETS_THREAD_COUNT configures at least two socket threads per processor, so other connections do not queue behind it. Without that setting the executor is woken through the thread pool as before. To get the gain, the benchmark needs DOTNET_SYSTEM_NET_SOCKETS_THREAD_COUNT=8, which belongs in the benchmark configuration, not in this PR.

Metric Before Optimization After Optimization After Optimization, 8 socket engines
Constant-latency req/s, AOT 3,343 3,338 (-0.2%) 3,436 (+2.8%)
Constant-latency p50 / p95 ms, AOT 13.90 / 19.42 13.94 / 19.45 13.53 / 18.85
Constant-latency req/s, JIT 3,408 3,396 (-0.4%) 3,491 (+2.4%)
Constant-latency p50 / p95 ms, JIT 13.66 / 19.08 13.70 / 19.22 13.30 / 18.66
Constant req/s, AOT 4,770 4,820 (+1.1%) 4,888 (+2.5%)
Constant req/s, JIT 5,015 4,961 (-1.1%) 5,159 (+2.9%)
CPU ms/req, constant-latency, AOT 0.786 0.797 0.750 (-4.5%)
CPU ms/req, constant, AOT 0.770 0.765 0.752 (-2.4%)
Allocated KiB/req, constant-latency, JIT 26.5 26.5 26.3
RSS avg / max MB, constant-latency, AOT 97.7 / 102.3 97.7 / 99.9 97.9 / 103.8
RSS avg / max MB, constant, AOT 91.4 / 98.7 92.2 / 100.3 91.8 / 98.2
Idle RSS MB, AOT 50.1 50.2 50.6
Startup ms, AOT 76 77 75
Executor wake on the critical path, us, AOT (probe build) 1,052 not probed (same code path as before) 3

Measured on the benchmark twin with the official 16.7.0 subgraphs and the official gateway settings (alias batching, inline scheduling and inline socket completions), before is #10852 on the main of that time (572aa98), after is this PR at the default engine count (gate off) and with 8 engines (gate on), means of 2-3 interleaved rounds with 40 s warm-up and 45 s measured, responses byte-identical.

…he thread pool

When a plan node completes on a thread that is not a thread pool thread, such as a
socket engine thread with DOTNET_SYSTEM_NET_SOCKETS_INLINE_COMPLETIONS=1, the executor's
wake-up signal now runs the executor continuation on that thread instead of queuing it
to the thread pool's global queue. Completions on thread pool threads still queue it.
…r processor

The executor wake-up now runs the continuation on a thread that is not a thread
pool thread only when DOTNET_SYSTEM_NET_SOCKETS_THREAD_COUNT configures at least
twice Environment.ProcessorCount socket engines. The value is read once at startup
and parsed as the runtime's socket engine parses it. Otherwise the continuation is
queued to the thread pool as before.
Copilot AI balanced review requested due to automatic review settings November 12, 2026 20:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@michaelstaib
michaelstaib merged commit 543aca9 into main Nov 12, 2026
157 checks passed
@michaelstaib
michaelstaib deleted the perf/inline-executor-wake branch November 12, 2026 21:58
@github-actions

Copy link
Copy Markdown
Contributor

Patch coverage

100.0% of changed lines covered (28/28)

File Covered Changed Patch %
…/Fusion/src/Fusion.Execution/Execution/AsyncAutoResetEvent.cs 28 28 100.0% 🟢

Project coverage: 59.8% (327059/546605 lines)

This was referenced Nov 17, 2026
This was referenced Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants