зеркало из https://github.com/microsoft/msquic.git
Update DocFx after documentation changes.
This commit is contained in:
Родитель
5f02166af9
Коммит
a7a1361481
|
@ -170,11 +170,7 @@
|
|||
</ul>
|
||||
<p>The <strong>PATCH</strong> version <strong>only changes</strong> when a servicing fix is made to an existing release.</p>
|
||||
<h2 id="execution-mode">Execution Mode</h2>
|
||||
<p>In general, MsQuic uses a callback model for all asynchronous events up to the app. This includes things like connection state changes, new streams being created, stream data being received, and stream sends completing. All these events are indicated to the app via the callback handler, on a thread owned by MsQuic.</p>
|
||||
<p>Generally, MsQuic creates multiple threads to parallelize work, and therefore will make parallel/overlapping upcalls to the application, but not for the same connection. All upcalls to the app for a single connection and all child streams are always delivered serially. This is not to say, though, it will always be on the same thread. MsQuic does support the ability to shuffle connections around to better balance the load.</p>
|
||||
<p>Apps are expected to keep any execution time in the callback <strong>to a minimum</strong>. MsQuic does not use separate threads for the protocol execution and upcalls to the app. Therefore, any significant delays on the callback <strong>will delay the protocol</strong>. Any significant time or work needed to be completed by the app must happen on its own thread.</p>
|
||||
<p>This doesn't mean the app isn't allowed to do any work in the callback. In fact, many things are expressly designed to be most efficient when the app does them on the callback. For instance, closing a handle to a connection or stream is ideally implemented in the "shutdown complete" indications.</p>
|
||||
<p>One important aspect of this design is that all blocking calls invoked on a callback always happen inline (to prevent deadlocks), and will supercede any calls in progress or queued from a separate thread.</p>
|
||||
<p>MsQuic has a very different execution model than classic BSD-style sockets. Please see <a href="Execution.html">Execution</a> for more details on how threads and upcalls are handled inside of MsQuic.</p>
|
||||
<h2 id="settings-and-configuration">Settings and Configuration</h2>
|
||||
<p>MsQuic supports a variety of configuration options available to both application developers and administrators deploying MsQuic. See <a href="Settings.html">Settings</a> for a detailed explanation of these settings and configuration options.</p>
|
||||
<h1 id="api-objects">API Objects</h1>
|
||||
|
|
|
@ -0,0 +1,207 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Execution </title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="title" content="Execution ">
|
||||
|
||||
|
||||
<link rel="icon" href="../favicon.ico">
|
||||
<link rel="stylesheet" href="../public/docfx.min.css">
|
||||
<link rel="stylesheet" href="../public/main.css">
|
||||
<meta name="docfx:navrel" content="../toc.html">
|
||||
<meta name="docfx:tocrel" content="toc.html">
|
||||
|
||||
<meta name="docfx:rel" content="../">
|
||||
|
||||
|
||||
<meta name="docfx:docurl" content="https://github.com/microsoft/msquic/blob/main/docs/Execution.md/#L1">
|
||||
<meta name="loc:inThisArticle" content="In this article">
|
||||
<meta name="loc:searchResultsCount" content="{count} results for "{query}"">
|
||||
<meta name="loc:searchNoResults" content="No results for "{query}"">
|
||||
<meta name="loc:tocFilter" content="Filter by title">
|
||||
<meta name="loc:nextArticle" content="Next">
|
||||
<meta name="loc:prevArticle" content="Previous">
|
||||
<meta name="loc:themeLight" content="Light">
|
||||
<meta name="loc:themeDark" content="Dark">
|
||||
<meta name="loc:themeAuto" content="Auto">
|
||||
<meta name="loc:changeTheme" content="Change theme">
|
||||
<meta name="loc:copy" content="Copy">
|
||||
<meta name="loc:downloadPdf" content="Download PDF">
|
||||
|
||||
<script type="module" src="./../public/docfx.min.js"></script>
|
||||
|
||||
<script>
|
||||
const theme = localStorage.getItem('theme') || 'auto'
|
||||
document.documentElement.setAttribute('data-bs-theme', theme === 'auto' ? (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light') : theme)
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
||||
<body class="tex2jax_ignore" data-layout="" data-yaml-mime="">
|
||||
<header class="bg-body border-bottom">
|
||||
<nav id="autocollapse" class="navbar navbar-expand-md" role="navigation">
|
||||
<div class="container-xxl flex-nowrap">
|
||||
<a class="navbar-brand" href="../index.html">
|
||||
<img id="logo" class="svg" src="../logo.svg" alt="">
|
||||
|
||||
</a>
|
||||
<button class="btn btn-lg d-md-none border-0" type="button" data-bs-toggle="collapse" data-bs-target="#navpanel" aria-controls="navpanel" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<i class="bi bi-three-dots"></i>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navpanel">
|
||||
<div id="navbar">
|
||||
<form class="search" role="search" id="search">
|
||||
<i class="bi bi-search"></i>
|
||||
<input class="form-control" id="search-query" type="search" disabled="" placeholder="Search" autocomplete="off" aria-label="Search">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main class="container-xxl">
|
||||
<div class="toc-offcanvas">
|
||||
<div class="offcanvas-md offcanvas-start" tabindex="-1" id="tocOffcanvas" aria-labelledby="tocOffcanvasLabel">
|
||||
<div class="offcanvas-header">
|
||||
<h5 class="offcanvas-title" id="tocOffcanvasLabel">Table of Contents</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" data-bs-target="#tocOffcanvas" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="offcanvas-body">
|
||||
<nav class="toc" id="toc"></nav>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
<div class="actionbar">
|
||||
<button class="btn btn-lg border-0 d-md-none" type="button" data-bs-toggle="offcanvas" data-bs-target="#tocOffcanvas" aria-controls="tocOffcanvas" aria-expanded="false" aria-label="Show table of contents">
|
||||
<i class="bi bi-list"></i>
|
||||
</button>
|
||||
|
||||
<nav id="breadcrumb"></nav>
|
||||
</div>
|
||||
|
||||
<article data-uid="">
|
||||
<h1 id="execution">Execution</h1>
|
||||
|
||||
<p>The MsQuic API uses a different execution model compared to BSD-style sockets and most other networking libraries built on them.
|
||||
The sections below detail the designs MsQuic uses and the reasons behind these choices.</p>
|
||||
<h2 id="event-model">Event Model</h2>
|
||||
<p>In the MsQuic API, all asynchronous state changes and notifications are indicated directly to the application via a callback.
|
||||
This includes connection state changes, new streams being created, stream data being received, and stream sends completing.</p>
|
||||
<pre><code class="lang-c">typedef struct QUIC_LISTENER_EVENT {
|
||||
QUIC_LISTENER_EVENT_TYPE Type;
|
||||
union {
|
||||
struct { ... } NEW_CONNECTION;
|
||||
struct { ... } STOP_COMPLETE;
|
||||
};
|
||||
} QUIC_LISTENER_EVENT;
|
||||
|
||||
typedef
|
||||
_IRQL_requires_max_(PASSIVE_LEVEL)
|
||||
_Function_class_(QUIC_LISTENER_CALLBACK)
|
||||
QUIC_STATUS
|
||||
(QUIC_API QUIC_LISTENER_CALLBACK)(
|
||||
_In_ HQUIC Listener,
|
||||
_In_opt_ void* Context,
|
||||
_Inout_ QUIC_LISTENER_EVENT* Event
|
||||
);
|
||||
</code></pre>
|
||||
<p>Above is an example of a callback delivered to the listener interface.
|
||||
The application must register a per-object callback handler to manage all events MsQuic may indicate for that object, returning a status to show if it was successfully handled or not.</p>
|
||||
<p>This approach differs significantly from sockets and most networking libraries, where the application must make a call (e.g., <code>send</code> or <code>recv</code>) to determine if something happened.
|
||||
This design choice was made for several reasons:</p>
|
||||
<ul>
|
||||
<li><p>The MsQuic API <strong>runs in-process</strong>, eliminating the need for a kernel to user mode boundary switch to notify the application layer. This makes the callback-based design more practical compared to sockets.</p>
|
||||
</li>
|
||||
<li><p>MsQuic, due to the QUIC protocol, has numerous event types. Applications may have hundreds of objects with potential state changes. The callback model allows the application to avoid managing pending calls on each object.</p>
|
||||
</li>
|
||||
<li><p>Writing correct, scalable code on top of the socket interfaces has proven challenging. By offloading the threading to MsQuic it enables MsQuic to abstract much complexity from applications, making things "just work" out of the box.</p>
|
||||
</li>
|
||||
<li><p>It simplifies MsQuic's logic by eliminating the need for a queue or cached state to indicate to the application. In the socket model, the networking stack must wait for a top-down call from the application before indicating completion, increasing code size, complexity, and memory usage.</p>
|
||||
</li>
|
||||
</ul>
|
||||
<h3 id="writing-event-handlers">Writing Event Handlers</h3>
|
||||
<p>Event handlers are <strong>essential</strong> for all objects that support them, as much of the MsQuic API operates through these callbacks.
|
||||
Critical events, such as "shutdown complete" notifications, provide vital information necessary for the application to function correctly.
|
||||
Without these events, the application cannot determine when it is safe to clean up objects.</p>
|
||||
<p>Applications should keep the execution time within callbacks <strong>to a minimum</strong>.
|
||||
MsQuic does not use separate threads for protocol execution and upcalls to the application.
|
||||
Therefore, any significant delays in the callback <strong>will delay the protocol</strong>.
|
||||
Any substantial work required by the application should be performed on its own thread.</p>
|
||||
<p>This does not mean the application cannot perform any work in the callback handler.
|
||||
In fact, many operations are designed to be most efficient when executed within the callback.
|
||||
For example, closing a handle to a connection or stream is ideally done during the "shutdown complete" indication.</p>
|
||||
<p>A crucial aspect of this design is that all blocking API (down) calls invoked within a callback always occur inline (to prevent deadlocks) and will take precedence over any calls in progress or queued from a separate thread.
|
||||
It's also worth noting that MsQuic will not invoke a recursive callback to the application by default in these cases.
|
||||
The one exception to this rule is if the application opts in via the <code>QUIC_STREAM_SHUTDOWN_FLAG_INLINE</code> flag when calling <code>StreamShudown</code> on a callback.</p>
|
||||
<h2 id="threading">Threading</h2>
|
||||
<p>By default, MsQuic creates its own threads to manage the execution of its logic.
|
||||
The number and configuration of these threads depend on the settings passed to <a href="api/RegistrationOpen.html">RegistrationOpen</a> or <code>QUIC_PARAM_GLOBAL_EXECUTION_CONFIG</code>.</p>
|
||||
<p>Typically, MsQuic creates dedicated threads for each processor, which are hard-affinitized to a specific NUMA node and soft-affinitized (set as 'ideal processor') to a specific processor.
|
||||
These threads handle both the datapath (i.e., UDP) and QUIC layers.
|
||||
By default both layers are handled by a single thread (per-processor), but QUIC may be configured to run these layers on separate threads.
|
||||
By using the same thread MsQuic can achieve lower latency, but by using separate threads it can achieve higher throughput.
|
||||
MsQuic aligns its processing logic with the rest of the networking stack (including hardware RSS) to ensure that all processing stays on the same NUMA node, and ideally, the same processor.</p>
|
||||
<p>The complexity of aligning processing across various threads and processors is why MsQuic manages its own threading by default.
|
||||
This abstraction simplifies the development process for applications built on top of MsQuic, ensuring that things "just work" for QUIC out of the box.</p>
|
||||
<p>Each thread manages the execution of one or more connections.
|
||||
Connections are distributed across threads based on their RSS alignment, which should evenly distribute traffic based on different UDP tuples.
|
||||
Each connection and its derived state (i.e., streams) are managed and executed by a single thread at a time, but may move across threads to align with any RSS changes.
|
||||
This ensures that each connection and its streams are effectively single-threaded, including all upcalls to the application layer.
|
||||
MsQuic will <strong>never</strong> make upcalls for a single connection or any of its streams in parallel.</p>
|
||||
<p>For listeners, the application callback will be called in parallel for new connections, allowing server applications to scale efficiently with the number of processors.</p>
|
||||
<pre><code class="lang-mermaid">graph TD
|
||||
subgraph Kernel
|
||||
NIC-Queue1[NIC Queue]
|
||||
NIC-Queue2[NIC Queue]
|
||||
NIC-Queue1 -->|RSS Receive| UDP1[IP/UDP]
|
||||
NIC-Queue2 -->|RSS Receive| UDP2[IP/UDP]
|
||||
end
|
||||
subgraph MsQuic Process
|
||||
UDP1 -.-> Processor1
|
||||
UDP2 -.-> Processor2
|
||||
subgraph Processor1[Processor 0]
|
||||
Thread1[Thread]
|
||||
Thread1 -->|Manages| Connection1[Connection 1]
|
||||
Thread1 -->|Manages| Connection2[Connection 2]
|
||||
Connection1 -->|Delivers Event| ApplicationCallback1[App Callback]
|
||||
Connection2 -->|Delivers Event| ApplicationCallback2[App Callback]
|
||||
end
|
||||
subgraph Processor2[Processor 1]
|
||||
Thread2[Thread]
|
||||
Thread2 -->|Manages| Connection3[Connection 3]
|
||||
Connection3 -->|Delivers Event| ApplicationCallback3[App Callback]
|
||||
end
|
||||
end
|
||||
</code></pre>
|
||||
|
||||
</article>
|
||||
|
||||
<div class="contribution d-print-none">
|
||||
<a href="https://github.com/microsoft/msquic/blob/main/docs/Execution.md/#L1" class="edit-link">Edit this page</a>
|
||||
</div>
|
||||
|
||||
<div class="next-article d-print-none border-top" id="nextArticle"></div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="affix">
|
||||
<nav id="affix"></nav>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<div class="container-xxl search-results" id="search-results"></div>
|
||||
|
||||
<footer class="border-top text-secondary">
|
||||
<div class="container-xxl">
|
||||
<div class="flex-fill">
|
||||
<span>Made with <a href="https://dotnet.github.io/docfx">docfx</a></span>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
|
@ -33,6 +33,9 @@
|
|||
<li>
|
||||
<a href="Diagnostics.html" name="" title="Diagnostics">Diagnostics</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Execution.html" name="" title="Execution">Execution</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="FAQ.html" name="" title="FAQ">FAQ</a>
|
||||
</li>
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
|
||||
{"items":[{"name":"API","href":"API.html","topicHref":"API.html"},{"name":"Architecture","href":"Architecture.html","topicHref":"Architecture.html"},{"name":"BUILD","href":"BUILD.html","topicHref":"BUILD.html"},{"name":"CredScan","href":"CredScan.html","topicHref":"CredScan.html"},{"name":"Deployment","href":"Deployment.html","topicHref":"Deployment.html"},{"name":"Development","href":"Development.html","topicHref":"Development.html"},{"name":"Diagnostics","href":"Diagnostics.html","topicHref":"Diagnostics.html"},{"name":"FAQ","href":"FAQ.html","topicHref":"FAQ.html"},{"name":"FIPS","href":"FIPS.html","topicHref":"FIPS.html"},{"name":"InteropServerSetup","href":"InteropServerSetup.html","topicHref":"InteropServerSetup.html"},{"name":"PGO","href":"PGO.html","topicHref":"PGO.html"},{"name":"Platforms","href":"Platforms.html","topicHref":"Platforms.html"},{"name":"Release","href":"Release.html","topicHref":"Release.html"},{"name":"Sample","href":"Sample.html","topicHref":"Sample.html"},{"name":"Settings","href":"Settings.html","topicHref":"Settings.html"},{"name":"Streams","href":"Streams.html","topicHref":"Streams.html"},{"name":"TEST","href":"TEST.html","topicHref":"TEST.html"},{"name":"ThreatModel","href":"ThreatModel.html","topicHref":"ThreatModel.html"},{"name":"TLS","href":"TLS.html","topicHref":"TLS.html"},{"name":"TSG","href":"TSG.html","topicHref":"TSG.html"},{"name":"Versions","href":"Versions.html","topicHref":"Versions.html"}]}
|
||||
{"items":[{"name":"API","href":"API.html","topicHref":"API.html"},{"name":"Architecture","href":"Architecture.html","topicHref":"Architecture.html"},{"name":"BUILD","href":"BUILD.html","topicHref":"BUILD.html"},{"name":"CredScan","href":"CredScan.html","topicHref":"CredScan.html"},{"name":"Deployment","href":"Deployment.html","topicHref":"Deployment.html"},{"name":"Development","href":"Development.html","topicHref":"Development.html"},{"name":"Diagnostics","href":"Diagnostics.html","topicHref":"Diagnostics.html"},{"name":"Execution","href":"Execution.html","topicHref":"Execution.html"},{"name":"FAQ","href":"FAQ.html","topicHref":"FAQ.html"},{"name":"FIPS","href":"FIPS.html","topicHref":"FIPS.html"},{"name":"InteropServerSetup","href":"InteropServerSetup.html","topicHref":"InteropServerSetup.html"},{"name":"PGO","href":"PGO.html","topicHref":"PGO.html"},{"name":"Platforms","href":"Platforms.html","topicHref":"Platforms.html"},{"name":"Release","href":"Release.html","topicHref":"Release.html"},{"name":"Sample","href":"Sample.html","topicHref":"Sample.html"},{"name":"Settings","href":"Settings.html","topicHref":"Settings.html"},{"name":"Streams","href":"Streams.html","topicHref":"Streams.html"},{"name":"TEST","href":"TEST.html","topicHref":"TEST.html"},{"name":"ThreatModel","href":"ThreatModel.html","topicHref":"ThreatModel.html"},{"name":"TLS","href":"TLS.html","topicHref":"TLS.html"},{"name":"TSG","href":"TSG.html","topicHref":"TSG.html"},{"name":"Versions","href":"Versions.html","topicHref":"Versions.html"}]}
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -90,6 +90,16 @@
|
|||
},
|
||||
"version": ""
|
||||
},
|
||||
{
|
||||
"type": "Conceptual",
|
||||
"source_relative_path": "docs/Execution.md",
|
||||
"output": {
|
||||
".html": {
|
||||
"relative_path": "docs/Execution.html"
|
||||
}
|
||||
},
|
||||
"version": ""
|
||||
},
|
||||
{
|
||||
"type": "Conceptual",
|
||||
"source_relative_path": "docs/FAQ.md",
|
||||
|
|
Загрузка…
Ссылка в новой задаче