File tree Expand file tree Collapse file tree 2 files changed +16
-5
lines changed
Expand file tree Collapse file tree 2 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -1816,7 +1816,9 @@ fn build_async_runtime() -> Runtime {
18161816 // We want to minimize noise from the runtime
18171817 builder
18181818 . worker_threads ( 1 )
1819- . max_blocking_threads ( 1 )
1819+ . max_blocking_threads ( 8 )
1820+ // Do not keep blocking threads alive for long
1821+ . thread_keep_alive ( Duration :: from_secs ( 1 ) )
18201822 . enable_time ( )
18211823 . enable_io ( ) ;
18221824 builder. build ( ) . expect ( "built runtime" )
Original file line number Diff line number Diff line change @@ -202,10 +202,19 @@ impl SelfProfileStorage for S3SelfProfileStorage {
202202 data. len( )
203203 ) ;
204204 let start = Instant :: now ( ) ;
205- let mut data = snap:: read:: FrameEncoder :: new ( & data[ ..] ) ;
206- let mut compressed = Vec :: new ( ) ;
207- data. read_to_end ( & mut compressed)
208- . context ( "cannot compress self-profile data" ) ?;
205+
206+ // This is synchronous and blocks the event loop, so we should do it on a
207+ // worker thread
208+ let compressed = tokio:: task:: spawn_blocking ( move || {
209+ let mut data = snap:: read:: FrameEncoder :: new ( & data[ ..] ) ;
210+ let mut compressed = Vec :: new ( ) ;
211+
212+ data. read_to_end ( & mut compressed)
213+ . context ( "cannot compress self-profile data" ) ?;
214+ anyhow:: Ok ( compressed)
215+ } )
216+ . await ??;
217+
209218 log:: trace!(
210219 "Compress self-profile duration: {}, size: {}" ,
211220 start. elapsed( ) . as_secs_f64( ) ,
You can’t perform that action at this time.
0 commit comments