File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed
crates/base/src/rt_worker Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,13 @@ pub static SUPERVISOR_RT: Lazy<tokio::runtime::Runtime> = Lazy::new(|| {
8
8
. unwrap ( )
9
9
} ) ;
10
10
11
- pub static WORKER_RT : Lazy < tokio_util:: task:: LocalPoolHandle > = Lazy :: new ( || {
11
+ // NOTE: This pool is for the main and event workers. The reason why they should
12
+ // separate from the user worker pool is they can starve them if user workers
13
+ // are saturated.
14
+ pub static PRIMARY_WORKER_RT : Lazy < tokio_util:: task:: LocalPoolHandle > =
15
+ Lazy :: new ( || tokio_util:: task:: LocalPoolHandle :: new ( 2 ) ) ;
16
+
17
+ pub static USER_WORKER_RT : Lazy < tokio_util:: task:: LocalPoolHandle > = Lazy :: new ( || {
12
18
let maybe_pool_size = std:: env:: var ( "EDGE_RUNTIME_WORKER_POOL_SIZE" )
13
19
. ok ( )
14
20
. and_then ( |it| it. parse :: < usize > ( ) . ok ( ) ) ;
Original file line number Diff line number Diff line change @@ -98,8 +98,13 @@ impl Worker {
98
98
let is_user_worker = opts. conf . is_user_worker ( ) ;
99
99
100
100
let cancel = self . cancel . clone ( ) ;
101
+ let rt = if is_user_worker {
102
+ & rt:: USER_WORKER_RT
103
+ } else {
104
+ & rt:: PRIMARY_WORKER_RT
105
+ } ;
101
106
102
- let _worker_handle = rt:: WORKER_RT . spawn_pinned ( move || {
107
+ let _worker_handle = rt. spawn_pinned ( move || {
103
108
tokio:: task:: spawn_local ( async move {
104
109
let ( maybe_cpu_usage_metrics_tx, maybe_cpu_usage_metrics_rx) = is_user_worker
105
110
. then ( unbounded_channel :: < CPUUsageMetrics > )
You can’t perform that action at this time.
0 commit comments