File tree Expand file tree Collapse file tree 8 files changed +283
-81
lines changed Expand file tree Collapse file tree 8 files changed +283
-81
lines changed Original file line number Diff line number Diff line change 13
13
CARGO_TERM_COLOR : always
14
14
RUSTUP_MAX_RETRIES : 10
15
15
ORT_DYLIB_PATH : /tmp/onnxruntime/lib/libonnxruntime.so
16
- RUST_LOG : event_worker =trace
16
+ RUST_LOG : sb_event_worker =trace
17
17
18
18
jobs :
19
19
cargo-fmt :
Original file line number Diff line number Diff line change @@ -279,6 +279,7 @@ pub struct RuntimeState {
279
279
pub event_loop_completed : Arc < AtomicFlag > ,
280
280
pub terminated : Arc < AtomicFlag > ,
281
281
pub found_inspector_session : Arc < AtomicFlag > ,
282
+ pub mem_reached_half : Arc < AtomicFlag > ,
282
283
}
283
284
284
285
impl RuntimeState {
@@ -1324,6 +1325,14 @@ where
1324
1325
}
1325
1326
}
1326
1327
1328
+ if let Some ( limit) = mem_state. limit {
1329
+ if total_malloced_bytes >= limit / 2 {
1330
+ state. mem_reached_half . raise ( ) ;
1331
+ } else {
1332
+ state. mem_reached_half . lower ( ) ;
1333
+ }
1334
+ }
1335
+
1327
1336
if let Some ( threshold_bytes) = beforeunload_mem_threshold. load ( ) . as_deref ( ) . copied ( )
1328
1337
{
1329
1338
let total_malloced_bytes = total_malloced_bytes as u64 ;
Original file line number Diff line number Diff line change @@ -460,8 +460,6 @@ impl WorkerPool {
460
460
if tx. send ( Ok ( CreateUserWorkerResult { key : uuid } ) ) . is_err ( ) {
461
461
error ! ( "main worker receiver dropped" )
462
462
} ;
463
-
464
- status. demand . fetch_add ( 1 , Ordering :: Release ) ;
465
463
}
466
464
Err ( err) => {
467
465
error ! ( "{err:#}" ) ;
@@ -502,6 +500,8 @@ impl WorkerPool {
502
500
let cancel = worker. cancel . clone ( ) ;
503
501
let ( req_start_tx, req_end_tx) = profile. timing_tx_pair . clone ( ) ;
504
502
503
+ profile. status . demand . fetch_add ( 1 , Ordering :: Release ) ;
504
+
505
505
// Create a closure to handle the request and send the response
506
506
let request_handler = async move {
507
507
if !policy. is_per_worker ( ) {
@@ -648,15 +648,7 @@ impl WorkerPool {
648
648
. get ( & worker_uuid)
649
649
. map ( |it| it. status . is_retired . clone ( ) )
650
650
{
651
- Some ( is_retired) if !is_retired. is_raised ( ) => {
652
- self . user_workers
653
- . get ( & worker_uuid)
654
- . map ( |it| it. status . demand . as_ref ( ) )
655
- . unwrap ( )
656
- . fetch_add ( 1 , Ordering :: Release ) ;
657
-
658
- Some ( worker_uuid)
659
- }
651
+ Some ( is_retired) if !is_retired. is_raised ( ) => Some ( worker_uuid) ,
660
652
661
653
_ => {
662
654
self . retire ( & worker_uuid) ;
You can’t perform that action at this time.
0 commit comments