@@ -290,21 +290,25 @@ impl GlobalState {
290
290
291
291
pub ( crate ) fn process_changes ( & mut self ) -> bool {
292
292
let _p = span ! ( Level :: INFO , "GlobalState::process_changes" ) . entered ( ) ;
293
-
294
293
// We cannot directly resolve a change in a ratoml file to a format
295
294
// that can be used by the config module because config talks
296
295
// in `SourceRootId`s instead of `FileId`s and `FileId` -> `SourceRootId`
297
296
// mapping is not ready until `AnalysisHost::apply_changes` has been called.
298
297
let mut modified_ratoml_files: FxHashMap < FileId , ( ChangeKind , vfs:: VfsPath ) > =
299
298
FxHashMap :: default ( ) ;
300
299
301
- let ( change, modified_rust_files, workspace_structure_change) = {
302
- let mut change = ChangeWithProcMacros :: default ( ) ;
303
- let mut guard = self . vfs . write ( ) ;
304
- let changed_files = guard. 0 . take_changes ( ) ;
305
- if changed_files. is_empty ( ) {
306
- return false ;
307
- }
300
+ let mut change = ChangeWithProcMacros :: default ( ) ;
301
+ let mut guard = self . vfs . write ( ) ;
302
+ let changed_files = guard. 0 . take_changes ( ) ;
303
+ if changed_files. is_empty ( ) {
304
+ return false ;
305
+ }
306
+
307
+ let ( change, modified_rust_files, workspace_structure_change) = std:: thread:: scope ( |s| {
308
+ // start cancellation in parallel, this will kick off lru eviction
309
+ // allowing us to do meaningful work while waiting
310
+ // FIXME: We should have a long living thread for this purpose instead of re-spawning.
311
+ s. spawn ( || self . analysis_host . request_cancellation ( ) ) ;
308
312
309
313
// downgrade to read lock to allow more readers while we are normalizing text
310
314
let guard = RwLockWriteGuard :: downgrade_to_upgradable ( guard) ;
@@ -387,9 +391,8 @@ impl GlobalState {
387
391
change. set_roots ( roots) ;
388
392
}
389
393
( change, modified_rust_files, workspace_structure_change)
390
- } ;
394
+ } ) ;
391
395
392
- let _p = span ! ( Level :: INFO , "GlobalState::process_changes/apply_change" ) . entered ( ) ;
393
396
self . analysis_host . apply_change ( change) ;
394
397
if !modified_ratoml_files. is_empty ( )
395
398
|| !self . config . same_source_root_parent_map ( & self . local_roots_parent_map )
0 commit comments