Skip to content

Commit b157f5d

Browse files
authored
runtime: add guide for choosing between runtime types (#7635)
Signed-off-by: ADD-SP <[email protected]>
1 parent 35470bf commit b157f5d

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

spellcheck.dic

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
307
1+
308
22
&
33
+
44
<
@@ -190,6 +190,7 @@ nonblocking
190190
nondecreasing
191191
noop
192192
ntasks
193+
NUMA
193194
ok
194195
oneshot
195196
ORed

tokio/src/runtime/mod.rs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,52 @@
1313
//! not required to configure a [`Runtime`] manually, and a user may just use the
1414
//! [`tokio::main`] attribute macro, which creates a [`Runtime`] under the hood.
1515
//!
16+
//! # Choose your runtime
17+
//!
18+
//! Here is the rules of thumb to choose the right runtime for your application.
19+
//!
20+
//! ```plaintext
21+
//! +------------------------------------------------------+
22+
//! | Do you want work-stealing or multi-thread scheduler? |
23+
//! +------------------------------------------------------+
24+
//! | Yes | No
25+
//! | |
26+
//! | |
27+
//! v |
28+
//! +------------------------+ |
29+
//! | Multi-threaded Runtime | |
30+
//! +------------------------+ |
31+
//! |
32+
//! V
33+
//! +--------------------------------+
34+
//! | Do you execute `!Send` Future? |
35+
//! +--------------------------------+
36+
//! | Yes | No
37+
//! | |
38+
//! V |
39+
//! +--------------------------+ |
40+
//! | Local Runtime (unstable) | |
41+
//! +--------------------------+ |
42+
//! |
43+
//! v
44+
//! +------------------------+
45+
//! | Current-thread Runtime |
46+
//! +------------------------+
47+
//! ```
48+
//!
49+
//! The above decision tree is not exhaustive. there are other factors that
50+
//! may influence your decision.
51+
//!
52+
//! ## Bridging with sync code
53+
//!
54+
//! See <https://tokio.rs/tokio/topics/bridging> for details.
55+
//!
56+
//! ## NUMA awareness
57+
//!
58+
//! The tokio runtime is not NUMA (Non-Uniform Memory Access) aware.
59+
//! You may want to start multiple runtimes instead of a single runtime
60+
//! for better performance on NUMA systems.
61+
//!
1662
//! # Usage
1763
//!
1864
//! When no fine tuning is required, the [`tokio::main`] attribute macro can be

0 commit comments

Comments
 (0)