rust-analyzer icon indicating copy to clipboard operation
rust-analyzer copied to clipboard

Continuous high CPU usage of rust-analyzer-mac triggered by something in vscode.

Open staninprague opened this issue 6 years ago • 17 comments

Thank you for the great tooling for rust!

I'm still trying to find out what triggers the high CPU usage of rust-analyzer-mac (99.9%). When it happens, only closing vscode helps. After it happens the performance of code-editing degrades and "Saving/formatting" popup shows up for some period of time when a file is (auto) saved.

My current gut feeling is that it happens when new files are added to the workspace, but I'm not sure at all.

Here is the backtrace:

(lldb > bt all)
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
  * frame #0: 0x00007fff6c2cf882 libsystem_kernel.dylib`__psynch_cvwait + 10
    frame #1: 0x00007fff6c390425 libsystem_pthread.dylib`_pthread_cond_wait + 698
    frame #2: 0x0000000110dc8782 rust-analyzer-mac`std::thread::park::hdd0300c4816f7cee + 258
    frame #3: 0x000000011062fba5 rust-analyzer-mac`crossbeam_channel::context::Context::wait_until::hd755da274093ee79 + 325
    frame #4: 0x000000011062f835 rust-analyzer-mac`crossbeam_channel::context::Context::with::_$u7b$$u7b$closure$u7d$$u7d$::hf29a118d6e010372 + 485
    frame #5: 0x000000011062fdb8 rust-analyzer-mac`crossbeam_channel::select::run_select::h93301fb7062b5a44 + 408
    frame #6: 0x000000010ff97f70 rust-analyzer-mac`rust_analyzer::main_loop::_$LT$impl$u20$rust_analyzer..global_state..GlobalState$GT$::run::h38c113371460db85 + 2496
    frame #7: 0x000000010fed894d rust-analyzer-mac`rust_analyzer::main_loop::main_loop::h9c3393783470f905 + 349
    frame #8: 0x000000010fd03ab6 rust-analyzer-mac`rust_analyzer::main::h085b8d53c194f9df + 7830
    frame #9: 0x000000010fcfe3a6 rust-analyzer-mac`std::rt::lang_start::_$u7b$$u7b$closure$u7d$$u7d$::hc324d3613d01ff55 + 6
    frame #10: 0x0000000110dd81c9 rust-analyzer-mac`std::rt::lang_start_internal::h795af50241e12334 + 441
    frame #11: 0x000000010fd045e9 rust-analyzer-mac`main + 41
    frame #12: 0x00007fff6c18bcc9 libdyld.dylib`start + 1
    frame #13: 0x00007fff6c18bcc9 libdyld.dylib`start + 1
  thread #2
    frame #0: 0x00007fff6c2cf882 libsystem_kernel.dylib`__psynch_cvwait + 10
    frame #1: 0x00007fff6c390425 libsystem_pthread.dylib`_pthread_cond_wait + 698
    frame #2: 0x0000000110dc8782 rust-analyzer-mac`std::thread::park::hdd0300c4816f7cee + 258
    frame #3: 0x00000001100f8071 rust-analyzer-mac`crossbeam_channel::context::Context::wait_until::hd755da274093ee79 + 225
    frame #4: 0x00000001100f8209 rust-analyzer-mac`crossbeam_channel::context::Context::with::_$u7b$$u7b$closure$u7d$$u7d$::h91e9d8e843ad12a5 + 313
    frame #5: 0x00000001100f96cd rust-analyzer-mac`crossbeam_channel::flavors::zero::Channel$LT$T$GT$::recv::hbacbdcc42d691a18 + 1117
    frame #6: 0x00000001100f6525 rust-analyzer-mac`crossbeam_channel::channel::Receiver$LT$T$GT$::recv::h5dc2432b1d8b5519 + 245
    frame #7: 0x00000001100fa08c rust-analyzer-mac`std::sys_common::backtrace::__rust_begin_short_backtrace::h6f4c2b6fbd0d8f30 + 124
    frame #8: 0x00000001100e90bf rust-analyzer-mac`core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::hdbcff41b3e54894d + 79
    frame #9: 0x0000000110dde98d rust-analyzer-mac`std::sys::unix::thread::Thread::new::thread_start::hcced3d366a7ed1a7 + 45
    frame #10: 0x00007fff6c390109 libsystem_pthread.dylib`_pthread_start + 148
    frame #11: 0x00007fff6c38bb8b libsystem_pthread.dylib`thread_start + 15
  thread #3
    frame #0: 0x00007fff6c2cd81e libsystem_kernel.dylib`read + 10
    frame #1: 0x0000000110dcdc24 rust-analyzer-mac`_$LT$std..io..stdio..StdinLock$u20$as$u20$std..io..BufRead$GT$::fill_buf::h6554f2d3de0f8406 + 68
    frame #2: 0x00000001100e856a rust-analyzer-mac`std::io::append_to_string::h07fc88c72033190d + 58
    frame #3: 0x00000001100e3375 rust-analyzer-mac`lsp_server::msg::Message::read::ha5e03b314d8633d9 + 133
    frame #4: 0x00000001100f9e2c rust-analyzer-mac`std::sys_common::backtrace::__rust_begin_short_backtrace::h14c10f58895015b1 + 108
    frame #5: 0x00000001100e929f rust-analyzer-mac`core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::hedc1abff9cef8c7f + 79
    frame #6: 0x0000000110dde98d rust-analyzer-mac`std::sys::unix::thread::Thread::new::thread_start::hcced3d366a7ed1a7 + 45
    frame #7: 0x00007fff6c390109 libsystem_pthread.dylib`_pthread_start + 148
    frame #8: 0x00007fff6c38bb8b libsystem_pthread.dylib`thread_start + 15
  thread #4
    frame #0: 0x00007fff6c2cf882 libsystem_kernel.dylib`__psynch_cvwait + 10
    frame #1: 0x00007fff6c390425 libsystem_pthread.dylib`_pthread_cond_wait + 698
    frame #2: 0x0000000110dc8782 rust-analyzer-mac`std::thread::park::hdd0300c4816f7cee + 258
    frame #3: 0x000000011062fba5 rust-analyzer-mac`crossbeam_channel::context::Context::wait_until::hd755da274093ee79 + 325
    frame #4: 0x000000011062f835 rust-analyzer-mac`crossbeam_channel::context::Context::with::_$u7b$$u7b$closure$u7d$$u7d$::hf29a118d6e010372 + 485
    frame #5: 0x000000011062fdb8 rust-analyzer-mac`crossbeam_channel::select::run_select::h93301fb7062b5a44 + 408
    frame #6: 0x00000001100997bb rust-analyzer-mac`vfs_notify::NotifyActor::run::h30742495b1d997de + 283
    frame #7: 0x00000001100a0f23 rust-analyzer-mac`std::sys_common::backtrace::__rust_begin_short_backtrace::hb79e3a0a55277ba3 + 67
    frame #8: 0x000000011009ddb5 rust-analyzer-mac`core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::hb56f5a83cb3aebb5 + 117
    frame #9: 0x0000000110dde98d rust-analyzer-mac`std::sys::unix::thread::Thread::new::thread_start::hcced3d366a7ed1a7 + 45
    frame #10: 0x00007fff6c390109 libsystem_pthread.dylib`_pthread_start + 148
    frame #11: 0x00007fff6c38bb8b libsystem_pthread.dylib`thread_start + 15
  thread #5
    frame #0: 0x00007fff6c2cf062 libsystem_kernel.dylib`__psynch_mutexwait + 10
    frame #1: 0x00007fff6c38d917 libsystem_pthread.dylib`_pthread_mutex_firstfit_lock_wait + 83
    frame #2: 0x00007fff6c38b937 libsystem_pthread.dylib`_pthread_mutex_firstfit_lock_slow + 222
    frame #3: 0x000000011009100a rust-analyzer-mac`std::sys_common::backtrace::__rust_begin_short_backtrace::h7629632dd4c7acf2 + 74
    frame #4: 0x0000000110091458 rust-analyzer-mac`core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::ha5acbe5d771c1b33 + 72
    frame #5: 0x0000000110dde98d rust-analyzer-mac`std::sys::unix::thread::Thread::new::thread_start::hcced3d366a7ed1a7 + 45
    frame #6: 0x00007fff6c390109 libsystem_pthread.dylib`_pthread_start + 148
    frame #7: 0x00007fff6c38bb8b libsystem_pthread.dylib`thread_start + 15
  thread #6
    frame #0: 0x00007fff6c2cf062 libsystem_kernel.dylib`__psynch_mutexwait + 10
    frame #1: 0x00007fff6c38d917 libsystem_pthread.dylib`_pthread_mutex_firstfit_lock_wait + 83
    frame #2: 0x00007fff6c38b937 libsystem_pthread.dylib`_pthread_mutex_firstfit_lock_slow + 222
    frame #3: 0x000000011009100a rust-analyzer-mac`std::sys_common::backtrace::__rust_begin_short_backtrace::h7629632dd4c7acf2 + 74
    frame #4: 0x0000000110091458 rust-analyzer-mac`core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::ha5acbe5d771c1b33 + 72
    frame #5: 0x0000000110dde98d rust-analyzer-mac`std::sys::unix::thread::Thread::new::thread_start::hcced3d366a7ed1a7 + 45
    frame #6: 0x00007fff6c390109 libsystem_pthread.dylib`_pthread_start + 148
    frame #7: 0x00007fff6c38bb8b libsystem_pthread.dylib`thread_start + 15
  thread #7
    frame #0: 0x00007fff6c2cf062 libsystem_kernel.dylib`__psynch_mutexwait + 10
    frame #1: 0x00007fff6c38d917 libsystem_pthread.dylib`_pthread_mutex_firstfit_lock_wait + 83
    frame #2: 0x00007fff6c38b937 libsystem_pthread.dylib`_pthread_mutex_firstfit_lock_slow + 222
    frame #3: 0x000000011009100a rust-analyzer-mac`std::sys_common::backtrace::__rust_begin_short_backtrace::h7629632dd4c7acf2 + 74
    frame #4: 0x0000000110091458 rust-analyzer-mac`core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::ha5acbe5d771c1b33 + 72
    frame #5: 0x0000000110dde98d rust-analyzer-mac`std::sys::unix::thread::Thread::new::thread_start::hcced3d366a7ed1a7 + 45
    frame #6: 0x00007fff6c390109 libsystem_pthread.dylib`_pthread_start + 148
    frame #7: 0x00007fff6c38bb8b libsystem_pthread.dylib`thread_start + 15
  thread #8
    frame #0: 0x00007fff6c2cf062 libsystem_kernel.dylib`__psynch_mutexwait + 10
    frame #1: 0x00007fff6c38d917 libsystem_pthread.dylib`_pthread_mutex_firstfit_lock_wait + 83
    frame #2: 0x00007fff6c38b937 libsystem_pthread.dylib`_pthread_mutex_firstfit_lock_slow + 222
    frame #3: 0x000000011009100a rust-analyzer-mac`std::sys_common::backtrace::__rust_begin_short_backtrace::h7629632dd4c7acf2 + 74
    frame #4: 0x0000000110091458 rust-analyzer-mac`core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::ha5acbe5d771c1b33 + 72
    frame #5: 0x0000000110dde98d rust-analyzer-mac`std::sys::unix::thread::Thread::new::thread_start::hcced3d366a7ed1a7 + 45
    frame #6: 0x00007fff6c390109 libsystem_pthread.dylib`_pthread_start + 148
    frame #7: 0x00007fff6c38bb8b libsystem_pthread.dylib`thread_start + 15
  thread #9
    frame #0: 0x00007fff6c2cf062 libsystem_kernel.dylib`__psynch_mutexwait + 10
    frame #1: 0x00007fff6c38d917 libsystem_pthread.dylib`_pthread_mutex_firstfit_lock_wait + 83
    frame #2: 0x00007fff6c38b937 libsystem_pthread.dylib`_pthread_mutex_firstfit_lock_slow + 222
    frame #3: 0x000000011009100a rust-analyzer-mac`std::sys_common::backtrace::__rust_begin_short_backtrace::h7629632dd4c7acf2 + 74
    frame #4: 0x0000000110091458 rust-analyzer-mac`core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::ha5acbe5d771c1b33 + 72
    frame #5: 0x0000000110dde98d rust-analyzer-mac`std::sys::unix::thread::Thread::new::thread_start::hcced3d366a7ed1a7 + 45
    frame #6: 0x00007fff6c390109 libsystem_pthread.dylib`_pthread_start + 148
    frame #7: 0x00007fff6c38bb8b libsystem_pthread.dylib`thread_start + 15
  thread #10
    frame #0: 0x00007fff6c2cf062 libsystem_kernel.dylib`__psynch_mutexwait + 10
    frame #1: 0x00007fff6c38d917 libsystem_pthread.dylib`_pthread_mutex_firstfit_lock_wait + 83
    frame #2: 0x00007fff6c38b937 libsystem_pthread.dylib`_pthread_mutex_firstfit_lock_slow + 222
    frame #3: 0x000000011009100a rust-analyzer-mac`std::sys_common::backtrace::__rust_begin_short_backtrace::h7629632dd4c7acf2 + 74
    frame #4: 0x0000000110091458 rust-analyzer-mac`core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::ha5acbe5d771c1b33 + 72
    frame #5: 0x0000000110dde98d rust-analyzer-mac`std::sys::unix::thread::Thread::new::thread_start::hcced3d366a7ed1a7 + 45
    frame #6: 0x00007fff6c390109 libsystem_pthread.dylib`_pthread_start + 148
    frame #7: 0x00007fff6c38bb8b libsystem_pthread.dylib`thread_start + 15
  thread #11
    frame #0: 0x00007fff6c347336 libsystem_malloc.dylib`tiny_free_no_lock + 1207
    frame #1: 0x00007fff6c346d8b libsystem_malloc.dylib`free_tiny + 459
    frame #2: 0x0000000110ac8ad9 rust-analyzer-mac`core::ptr::drop_in_place::h204c1bdf9c519b39 + 121
    frame #3: 0x0000000110b98e3a rust-analyzer-mac`core::ptr::drop_in_place::h261b14a5fb629f99 + 74
    frame #4: 0x0000000110b937c2 rust-analyzer-mac`chalk_solve::recursive::fulfill::Fulfill$LT$I$C$Solver$C$Infer$GT$::solve::h1e6f8646a015bc6e + 3218
    frame #5: 0x0000000110a40204 rust-analyzer-mac`chalk_solve::recursive::solve::SolveIteration::solve_iteration::hc96428a897241cb0 + 8020
    frame #6: 0x0000000110a3bcba rust-analyzer-mac`_$LT$chalk_solve..recursive..Solver$LT$I$GT$$u20$as$u20$chalk_solve..recursive..solve..SolveDatabase$LT$I$GT$$GT$::solve_goal::hbddae22451e29a01 + 5930
    frame #7: 0x0000000110b928d0 rust-analyzer-mac`chalk_solve::recursive::fulfill::Fulfill$LT$I$C$Solver$C$Infer$GT$::prove::h1430c080789c56dd + 560
    frame #8: 0x0000000110b93392 rust-analyzer-mac`chalk_solve::recursive::fulfill::Fulfill$LT$I$C$Solver$C$Infer$GT$::solve::h1e6f8646a015bc6e + 2146
    frame #9: 0x0000000110a40204 rust-analyzer-mac`chalk_solve::recursive::solve::SolveIteration::solve_iteration::hc96428a897241cb0 + 8020
    frame #10: 0x0000000110a3bcba rust-analyzer-mac`_$LT$chalk_solve..recursive..Solver$LT$I$GT$$u20$as$u20$chalk_solve..recursive..solve..SolveDatabase$LT$I$GT$$GT$::solve_goal::hbddae22451e29a01 + 5930
    frame #11: 0x0000000110b928d0 rust-analyzer-mac`chalk_solve::recursive::fulfill::Fulfill$LT$I$C$Solver$C$Infer$GT$::prove::h1430c080789c56dd + 560
    frame #12: 0x0000000110b93392 rust-analyzer-mac`chalk_solve::recursive::fulfill::Fulfill$LT$I$C$Solver$C$Infer$GT$::solve::h1e6f8646a015bc6e + 2146
    frame #13: 0x0000000110a40204 rust-analyzer-mac`chalk_solve::recursive::solve::SolveIteration::solve_iteration::hc96428a897241cb0 + 8020
    frame #14: 0x0000000110a3bcba rust-analyzer-mac`_$LT$chalk_solve..recursive..Solver$LT$I$GT$$u20$as$u20$chalk_solve..recursive..solve..SolveDatabase$LT$I$GT$$GT$::solve_goal::hbddae22451e29a01 + 5930
    frame #15: 0x0000000110b928d0 rust-analyzer-mac`chalk_solve::recursive::fulfill::Fulfill$LT$I$C$Solver$C$Infer$GT$::prove::h1430c080789c56dd + 560
    frame #16: 0x0000000110b93392 rust-analyzer-mac`chalk_solve::recursive::fulfill::Fulfill$LT$I$C$Solver$C$Infer$GT$::solve::h1e6f8646a015bc6e + 2146
    frame #17: 0x0000000110a40204 rust-analyzer-mac`chalk_solve::recursive::solve::SolveIteration::solve_iteration::hc96428a897241cb0 + 8020
    frame #18: 0x0000000110a3bcba rust-analyzer-mac`_$LT$chalk_solve..recursive..Solver$LT$I$GT$$u20$as$u20$chalk_solve..recursive..solve..SolveDatabase$LT$I$GT$$GT$::solve_goal::hbddae22451e29a01 + 5930
    frame #19: 0x0000000110b928d0 rust-analyzer-mac`chalk_solve::recursive::fulfill::Fulfill$LT$I$C$Solver$C$Infer$GT$::prove::h1430c080789c56dd + 560
    frame #20: 0x0000000110b93392 rust-analyzer-mac`chalk_solve::recursive::fulfill::Fulfill$LT$I$C$Solver$C$Infer$GT$::solve::h1e6f8646a015bc6e + 2146
    frame #21: 0x0000000110a40204 rust-analyzer-mac`chalk_solve::recursive::solve::SolveIteration::solve_iteration::hc96428a897241cb0 + 8020
    frame #22: 0x0000000110a3bcba rust-analyzer-mac`_$LT$chalk_solve..recursive..Solver$LT$I$GT$$u20$as$u20$chalk_solve..recursive..solve..SolveDatabase$LT$I$GT$$GT$::solve_goal::hbddae22451e29a01 + 5930
    frame #23: 0x0000000110b928d0 rust-analyzer-mac`chalk_solve::recursive::fulfill::Fulfill$LT$I$C$Solver$C$Infer$GT$::prove::h1430c080789c56dd + 560
    frame #24: 0x0000000110b93392 rust-analyzer-mac`chalk_solve::recursive::fulfill::Fulfill$LT$I$C$Solver$C$Infer$GT$::solve::h1e6f8646a015bc6e + 2146
    frame #25: 0x0000000110a40204 rust-analyzer-mac`chalk_solve::recursive::solve::SolveIteration::solve_iteration::hc96428a897241cb0 + 8020
    frame #26: 0x0000000110a3bcba rust-analyzer-mac`_$LT$chalk_solve..recursive..Solver$LT$I$GT$$u20$as$u20$chalk_solve..recursive..solve..SolveDatabase$LT$I$GT$$GT$::solve_goal::hbddae22451e29a01 + 5930
    frame #27: 0x0000000110b928d0 rust-analyzer-mac`chalk_solve::recursive::fulfill::Fulfill$LT$I$C$Solver$C$Infer$GT$::prove::h1430c080789c56dd + 560
    frame #28: 0x0000000110b93392 rust-analyzer-mac`chalk_solve::recursive::fulfill::Fulfill$LT$I$C$Solver$C$Infer$GT$::solve::h1e6f8646a015bc6e + 2146
    frame #29: 0x0000000110a40204 rust-analyzer-mac`chalk_solve::recursive::solve::SolveIteration::solve_iteration::hc96428a897241cb0 + 8020
    frame #30: 0x0000000110a3bcba rust-analyzer-mac`_$LT$chalk_solve..recursive..Solver$LT$I$GT$$u20$as$u20$chalk_solve..recursive..solve..SolveDatabase$LT$I$GT$$GT$::solve_goal::hbddae22451e29a01 + 5930
    frame #31: 0x0000000110b928d0 rust-analyzer-mac`chalk_solve::recursive::fulfill::Fulfill$LT$I$C$Solver$C$Infer$GT$::prove::h1430c080789c56dd + 560
    frame #32: 0x0000000110b93392 rust-analyzer-mac`chalk_solve::recursive::fulfill::Fulfill$LT$I$C$Solver$C$Infer$GT$::solve::h1e6f8646a015bc6e + 2146
    frame #33: 0x0000000110a40204 rust-analyzer-mac`chalk_solve::recursive::solve::SolveIteration::solve_iteration::hc96428a897241cb0 + 8020
    frame #34: 0x0000000110a3bcba rust-analyzer-mac`_$LT$chalk_solve..recursive..Solver$LT$I$GT$$u20$as$u20$chalk_solve..recursive..solve..SolveDatabase$LT$I$GT$$GT$::solve_goal::hbddae22451e29a01 + 5930
    frame #35: 0x0000000110b928d0 rust-analyzer-mac`chalk_solve::recursive::fulfill::Fulfill$LT$I$C$Solver$C$Infer$GT$::prove::h1430c080789c56dd + 560
    frame #36: 0x0000000110b93392 rust-analyzer-mac`chalk_solve::recursive::fulfill::Fulfill$LT$I$C$Solver$C$Infer$GT$::solve::h1e6f8646a015bc6e + 2146
    frame #37: 0x0000000110a40204 rust-analyzer-mac`chalk_solve::recursive::solve::SolveIteration::solve_iteration::hc96428a897241cb0 + 8020
    frame #38: 0x0000000110a3bcba rust-analyzer-mac`_$LT$chalk_solve..recursive..Solver$LT$I$GT$$u20$as$u20$chalk_solve..recursive..solve..SolveDatabase$LT$I$GT$$GT$::solve_goal::hbddae22451e29a01 + 5930
    frame #39: 0x0000000110b928d0 rust-analyzer-mac`chalk_solve::recursive::fulfill::Fulfill$LT$I$C$Solver$C$Infer$GT$::prove::h1430c080789c56dd + 560
    frame #40: 0x0000000110b93392 rust-analyzer-mac`chalk_solve::recursive::fulfill::Fulfill$LT$I$C$Solver$C$Infer$GT$::solve::h1e6f8646a015bc6e + 2146
    frame #41: 0x0000000110a40204 rust-analyzer-mac`chalk_solve::recursive::solve::SolveIteration::solve_iteration::hc96428a897241cb0 + 8020
    frame #42: 0x0000000110a3bcba rust-analyzer-mac`_$LT$chalk_solve..recursive..Solver$LT$I$GT$$u20$as$u20$chalk_solve..recursive..solve..SolveDatabase$LT$I$GT$$GT$::solve_goal::hbddae22451e29a01 + 5930
    frame #43: 0x0000000110a3e1df rust-analyzer-mac`chalk_solve::recursive::Solver$LT$I$GT$::solve_root_goal::had0abea6db3f0a7c + 1103
    frame #44: 0x0000000110b7c0cc rust-analyzer-mac`chalk_solve::solve::Solver$LT$I$GT$::solve_limited::h05cbe55f10e688a0 + 76
    frame #45: 0x0000000110ac018e rust-analyzer-mac`ra_hir_ty::traits::trait_solve_query::h4a2a2cabdd10f70d + 1166
    frame #46: 0x00000001102e7748 rust-analyzer-mac`salsa::runtime::Runtime$LT$DB$GT$::execute_query_implementation::h9731686dff6f0545 + 408
    frame #47: 0x000000011024a5ec rust-analyzer-mac`salsa::derived::slot::Slot$LT$DB$C$Q$C$MP$GT$::read_upgrade::h4875d64537838a5f + 1980
    frame #48: 0x00000001102a9cd6 rust-analyzer-mac`salsa::derived::slot::Slot$LT$DB$C$Q$C$MP$GT$::read::hb3a54f533d6732df + 614
    frame #49: 0x00000001103340d5 rust-analyzer-mac`_$LT$salsa..derived..DerivedStorage$LT$DB$C$Q$C$MP$GT$$u20$as$u20$salsa..plumbing..QueryStorageOps$LT$DB$C$Q$GT$$GT$::try_fetch::hf893961820e50dda + 1573
    frame #50: 0x00000001103f6bfa rust-analyzer-mac`salsa::QueryTable$LT$DB$C$Q$GT$::get::h9471007c79bb3803 + 58
    frame #51: 0x00000001103660b5 rust-analyzer-mac`_$LT$T$u20$as$u20$ra_hir_ty..db..HirDatabase$GT$::trait_solve::h71c2c0a771611a4b + 101
    frame #52: 0x0000000110b37382 rust-analyzer-mac`ra_hir_ty::method_resolution::iterate_trait_method_candidates::hd2360e0e06ed79e7 + 2194
    frame #53: 0x0000000110b36a7c rust-analyzer-mac`ra_hir_ty::method_resolution::iterate_method_candidates_by_receiver::ha475425d49cd1ba7 + 332
    frame #54: 0x0000000110b35f9b rust-analyzer-mac`ra_hir_ty::method_resolution::iterate_method_candidates_impl::h2d4d1b3c0431d36b + 1147
    frame #55: 0x0000000110b11cca rust-analyzer-mac`ra_hir_ty::infer::expr::_$LT$impl$u20$ra_hir_ty..infer..InferenceContext$GT$::infer_method_call::hd748fe7e84bb307f + 858
    frame #56: 0x0000000110b03568 rust-analyzer-mac`ra_hir_ty::infer::expr::_$LT$impl$u20$ra_hir_ty..infer..InferenceContext$GT$::infer_expr_inner::h09ff912611c730ce + 6088
    frame #57: 0x0000000110b015a0 rust-analyzer-mac`ra_hir_ty::infer::expr::_$LT$impl$u20$ra_hir_ty..infer..InferenceContext$GT$::infer_expr_coerce::hd2626cbb2d105cb1 + 48
    frame #58: 0x0000000110b0399c rust-analyzer-mac`ra_hir_ty::infer::expr::_$LT$impl$u20$ra_hir_ty..infer..InferenceContext$GT$::infer_expr_inner::h09ff912611c730ce + 7164
    frame #59: 0x0000000110b015a0 rust-analyzer-mac`ra_hir_ty::infer::expr::_$LT$impl$u20$ra_hir_ty..infer..InferenceContext$GT$::infer_expr_coerce::hd2626cbb2d105cb1 + 48
    frame #60: 0x0000000110b1cd3c rust-analyzer-mac`ra_hir_ty::infer::infer_query::hacb968c5dff326fe + 4140
    frame #61: 0x00000001102e7de7 rust-analyzer-mac`salsa::runtime::Runtime$LT$DB$GT$::execute_query_implementation::ha65c91af6784c517 + 359
    frame #62: 0x00000001102385f6 rust-analyzer-mac`salsa::derived::slot::Slot$LT$DB$C$Q$C$MP$GT$::read_upgrade::h0ba7b66eb2bff73e + 2806
    frame #63: 0x00000001102b1ac6 rust-analyzer-mac`salsa::derived::slot::Slot$LT$DB$C$Q$C$MP$GT$::read::hec776519d5694f70 + 774
    frame #64: 0x00000001103285a3 rust-analyzer-mac`_$LT$salsa..derived..DerivedStorage$LT$DB$C$Q$C$MP$GT$$u20$as$u20$salsa..plumbing..QueryStorageOps$LT$DB$C$Q$GT$$GT$::try_fetch::h4957708518087239 + 883
    frame #65: 0x00000001103d94df rust-analyzer-mac`ra_hir_ty::db::infer_wait::h489d72debb12f199 + 127
    frame #66: 0x00000001109f3d54 rust-analyzer-mac`ra_hir::code_model::Function::diagnostics::h2d25a250ac179808 + 68
    frame #67: 0x00000001109f1444 rust-analyzer-mac`ra_hir::code_model::Module::diagnostics::h2268c3baffbb707b + 772
    frame #68: 0x00000001109f12e3 rust-analyzer-mac`ra_hir::code_model::Module::diagnostics::h2268c3baffbb707b + 419
    frame #69: 0x00000001103ebf82 rust-analyzer-mac`ra_ide::diagnostics::diagnostics::hc1336e1e6d3672d9 + 5634
    frame #70: 0x00000001103c6e19 rust-analyzer-mac`ra_ide::Analysis::diagnostics::ha67ebcccf0e8028c + 25
    frame #71: 0x000000010ffc519f rust-analyzer-mac`rust_analyzer::handlers::publish_diagnostics::h512215b8cdb108bf + 95
    frame #72: 0x000000010fec6cc7 rust-analyzer-mac`core::ops::function::impls::_$LT$impl$u20$core..ops..function..FnMut$LT$A$GT$$u20$for$u20$$RF$mut$u20$F$GT$::call_mut::h4d6d88f6ebfee512 + 39
    frame #73: 0x000000011006b74e rust-analyzer-mac`_$LT$alloc..vec..Vec$LT$T$GT$$u20$as$u20$alloc..vec..SpecExtend$LT$T$C$I$GT$$GT$::from_iter::ha168ad85269d2bd4 + 462
    frame #74: 0x000000010fec4ec2 rust-analyzer-mac`_$LT$F$u20$as$u20$threadpool..FnBox$GT$::call_box::hcd0050ef1c688063 + 146
    frame #75: 0x0000000110091075 rust-analyzer-mac`std::sys_common::backtrace::__rust_begin_short_backtrace::h7629632dd4c7acf2 + 181
    frame #76: 0x0000000110091458 rust-analyzer-mac`core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::ha5acbe5d771c1b33 + 72
    frame #77: 0x0000000110dde98d rust-analyzer-mac`std::sys::unix::thread::Thread::new::thread_start::hcced3d366a7ed1a7 + 45
    frame #78: 0x00007fff6c390109 libsystem_pthread.dylib`_pthread_start + 148
    frame #79: 0x00007fff6c38bb8b libsystem_pthread.dylib`thread_start + 15
  thread #12
    frame #0: 0x00007fff6c2cf062 libsystem_kernel.dylib`__psynch_mutexwait + 10
    frame #1: 0x00007fff6c38d917 libsystem_pthread.dylib`_pthread_mutex_firstfit_lock_wait + 83
    frame #2: 0x00007fff6c38b937 libsystem_pthread.dylib`_pthread_mutex_firstfit_lock_slow + 222
    frame #3: 0x000000011009100a rust-analyzer-mac`std::sys_common::backtrace::__rust_begin_short_backtrace::h7629632dd4c7acf2 + 74
    frame #4: 0x0000000110091458 rust-analyzer-mac`core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::ha5acbe5d771c1b33 + 72
    frame #5: 0x0000000110dde98d rust-analyzer-mac`std::sys::unix::thread::Thread::new::thread_start::hcced3d366a7ed1a7 + 45
    frame #6: 0x00007fff6c390109 libsystem_pthread.dylib`_pthread_start + 148
    frame #7: 0x00007fff6c38bb8b libsystem_pthread.dylib`thread_start + 15
  thread #13
    frame #0: 0x00007fff6c2cf882 libsystem_kernel.dylib`__psynch_cvwait + 10
    frame #1: 0x00007fff6c390425 libsystem_pthread.dylib`_pthread_cond_wait + 698
    frame #2: 0x0000000110dc8782 rust-analyzer-mac`std::thread::park::hdd0300c4816f7cee + 258
    frame #3: 0x0000000110dd48f5 rust-analyzer-mac`std::sync::mpsc::blocking::WaitToken::wait::hc52a4283b8966cd9 + 37
    frame #4: 0x000000011008fc2b rust-analyzer-mac`std::sync::mpsc::stream::Packet$LT$T$GT$::recv::h5cb1d8ace71ae69b + 651
    frame #5: 0x00000001100934c6 rust-analyzer-mac`std::sync::mpsc::Receiver$LT$T$GT$::recv::h4895a3cd7666a0fa + 214
    frame #6: 0x0000000110091035 rust-analyzer-mac`std::sys_common::backtrace::__rust_begin_short_backtrace::h7629632dd4c7acf2 + 117
    frame #7: 0x0000000110091458 rust-analyzer-mac`core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::ha5acbe5d771c1b33 + 72
    frame #8: 0x0000000110dde98d rust-analyzer-mac`std::sys::unix::thread::Thread::new::thread_start::hcced3d366a7ed1a7 + 45
    frame #9: 0x00007fff6c390109 libsystem_pthread.dylib`_pthread_start + 148
    frame #10: 0x00007fff6c38bb8b libsystem_pthread.dylib`thread_start + 15
  thread #14
    frame #0: 0x00007fff6c2cf062 libsystem_kernel.dylib`__psynch_mutexwait + 10
    frame #1: 0x00007fff6c38d917 libsystem_pthread.dylib`_pthread_mutex_firstfit_lock_wait + 83
    frame #2: 0x00007fff6c38b937 libsystem_pthread.dylib`_pthread_mutex_firstfit_lock_slow + 222
    frame #3: 0x000000011009100a rust-analyzer-mac`std::sys_common::backtrace::__rust_begin_short_backtrace::h7629632dd4c7acf2 + 74
    frame #4: 0x0000000110091458 rust-analyzer-mac`core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::ha5acbe5d771c1b33 + 72
    frame #5: 0x0000000110dde98d rust-analyzer-mac`std::sys::unix::thread::Thread::new::thread_start::hcced3d366a7ed1a7 + 45
    frame #6: 0x00007fff6c390109 libsystem_pthread.dylib`_pthread_start + 148
    frame #7: 0x00007fff6c38bb8b libsystem_pthread.dylib`thread_start + 15
  thread #15
    frame #0: 0x00007fff6c2cf062 libsystem_kernel.dylib`__psynch_mutexwait + 10
    frame #1: 0x00007fff6c38d917 libsystem_pthread.dylib`_pthread_mutex_firstfit_lock_wait + 83
    frame #2: 0x00007fff6c38b937 libsystem_pthread.dylib`_pthread_mutex_firstfit_lock_slow + 222
    frame #3: 0x000000011009100a rust-analyzer-mac`std::sys_common::backtrace::__rust_begin_short_backtrace::h7629632dd4c7acf2 + 74
    frame #4: 0x0000000110091458 rust-analyzer-mac`core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::ha5acbe5d771c1b33 + 72
    frame #5: 0x0000000110dde98d rust-analyzer-mac`std::sys::unix::thread::Thread::new::thread_start::hcced3d366a7ed1a7 + 45
    frame #6: 0x00007fff6c390109 libsystem_pthread.dylib`_pthread_start + 148
    frame #7: 0x00007fff6c38bb8b libsystem_pthread.dylib`thread_start + 15
  thread #16
    frame #0: 0x00007fff6c2cf062 libsystem_kernel.dylib`__psynch_mutexwait + 10
    frame #1: 0x00007fff6c38d917 libsystem_pthread.dylib`_pthread_mutex_firstfit_lock_wait + 83
    frame #2: 0x00007fff6c38b937 libsystem_pthread.dylib`_pthread_mutex_firstfit_lock_slow + 222
    frame #3: 0x000000011009100a rust-analyzer-mac`std::sys_common::backtrace::__rust_begin_short_backtrace::h7629632dd4c7acf2 + 74
    frame #4: 0x0000000110091458 rust-analyzer-mac`core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::ha5acbe5d771c1b33 + 72
    frame #5: 0x0000000110dde98d rust-analyzer-mac`std::sys::unix::thread::Thread::new::thread_start::hcced3d366a7ed1a7 + 45
    frame #6: 0x00007fff6c390109 libsystem_pthread.dylib`_pthread_start + 148
    frame #7: 0x00007fff6c38bb8b libsystem_pthread.dylib`thread_start + 15
  thread #17
    frame #0: 0x00007fff6c2cf062 libsystem_kernel.dylib`__psynch_mutexwait + 10
    frame #1: 0x00007fff6c38d917 libsystem_pthread.dylib`_pthread_mutex_firstfit_lock_wait + 83
    frame #2: 0x00007fff6c38b937 libsystem_pthread.dylib`_pthread_mutex_firstfit_lock_slow + 222
    frame #3: 0x000000011009100a rust-analyzer-mac`std::sys_common::backtrace::__rust_begin_short_backtrace::h7629632dd4c7acf2 + 74
    frame #4: 0x0000000110091458 rust-analyzer-mac`core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::ha5acbe5d771c1b33 + 72
    frame #5: 0x0000000110dde98d rust-analyzer-mac`std::sys::unix::thread::Thread::new::thread_start::hcced3d366a7ed1a7 + 45
    frame #6: 0x00007fff6c390109 libsystem_pthread.dylib`_pthread_start + 148
    frame #7: 0x00007fff6c38bb8b libsystem_pthread.dylib`thread_start + 15
  thread #18
    frame #0: 0x00007fff6c2cf062 libsystem_kernel.dylib`__psynch_mutexwait + 10
    frame #1: 0x00007fff6c38d917 libsystem_pthread.dylib`_pthread_mutex_firstfit_lock_wait + 83
    frame #2: 0x00007fff6c38b937 libsystem_pthread.dylib`_pthread_mutex_firstfit_lock_slow + 222
    frame #3: 0x000000011009100a rust-analyzer-mac`std::sys_common::backtrace::__rust_begin_short_backtrace::h7629632dd4c7acf2 + 74
    frame #4: 0x0000000110091458 rust-analyzer-mac`core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::ha5acbe5d771c1b33 + 72
    frame #5: 0x0000000110dde98d rust-analyzer-mac`std::sys::unix::thread::Thread::new::thread_start::hcced3d366a7ed1a7 + 45
    frame #6: 0x00007fff6c390109 libsystem_pthread.dylib`_pthread_start + 148
    frame #7: 0x00007fff6c38bb8b libsystem_pthread.dylib`thread_start + 15
  thread #19
    frame #0: 0x00007fff6c2cf062 libsystem_kernel.dylib`__psynch_mutexwait + 10
    frame #1: 0x00007fff6c38d917 libsystem_pthread.dylib`_pthread_mutex_firstfit_lock_wait + 83
    frame #2: 0x00007fff6c38b937 libsystem_pthread.dylib`_pthread_mutex_firstfit_lock_slow + 222
    frame #3: 0x000000011009100a rust-analyzer-mac`std::sys_common::backtrace::__rust_begin_short_backtrace::h7629632dd4c7acf2 + 74
    frame #4: 0x0000000110091458 rust-analyzer-mac`core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::ha5acbe5d771c1b33 + 72
    frame #5: 0x0000000110dde98d rust-analyzer-mac`std::sys::unix::thread::Thread::new::thread_start::hcced3d366a7ed1a7 + 45
    frame #6: 0x00007fff6c390109 libsystem_pthread.dylib`_pthread_start + 148
    frame #7: 0x00007fff6c38bb8b libsystem_pthread.dylib`thread_start + 15
  thread #20
    frame #0: 0x00007fff6c2cf062 libsystem_kernel.dylib`__psynch_mutexwait + 10
    frame #1: 0x00007fff6c38d917 libsystem_pthread.dylib`_pthread_mutex_firstfit_lock_wait + 83
    frame #2: 0x00007fff6c38b937 libsystem_pthread.dylib`_pthread_mutex_firstfit_lock_slow + 222
    frame #3: 0x000000011009100a rust-analyzer-mac`std::sys_common::backtrace::__rust_begin_short_backtrace::h7629632dd4c7acf2 + 74
    frame #4: 0x0000000110091458 rust-analyzer-mac`core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::ha5acbe5d771c1b33 + 72
    frame #5: 0x0000000110dde98d rust-analyzer-mac`std::sys::unix::thread::Thread::new::thread_start::hcced3d366a7ed1a7 + 45
    frame #6: 0x00007fff6c390109 libsystem_pthread.dylib`_pthread_start + 148
    frame #7: 0x00007fff6c38bb8b libsystem_pthread.dylib`thread_start + 15
  thread #21
    frame #0: 0x00007fff6c2cf882 libsystem_kernel.dylib`__psynch_cvwait + 10
    frame #1: 0x00007fff6c390425 libsystem_pthread.dylib`_pthread_cond_wait + 698
    frame #2: 0x0000000110dc8782 rust-analyzer-mac`std::thread::park::hdd0300c4816f7cee + 258
    frame #3: 0x000000011062fba5 rust-analyzer-mac`crossbeam_channel::context::Context::wait_until::hd755da274093ee79 + 325
    frame #4: 0x000000011062f835 rust-analyzer-mac`crossbeam_channel::context::Context::with::_$u7b$$u7b$closure$u7d$$u7d$::hf29a118d6e010372 + 485
    frame #5: 0x000000011062fdb8 rust-analyzer-mac`crossbeam_channel::select::run_select::h93301fb7062b5a44 + 408
    frame #6: 0x000000011013320e rust-analyzer-mac`flycheck::FlycheckActor::run::h0985f5dedef8d1a7 + 430
    frame #7: 0x000000011013d6d3 rust-analyzer-mac`std::sys_common::backtrace::__rust_begin_short_backtrace::h0afe1ae6a451dc76 + 67
    frame #8: 0x000000011014f145 rust-analyzer-mac`core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::h33312c6fbc815c0e + 117
    frame #9: 0x0000000110dde98d rust-analyzer-mac`std::sys::unix::thread::Thread::new::thread_start::hcced3d366a7ed1a7 + 45
    frame #10: 0x00007fff6c390109 libsystem_pthread.dylib`_pthread_start + 148
    frame #11: 0x00007fff6c38bb8b libsystem_pthread.dylib`thread_start + 15

Will be happy to help to dig deeper, but would need more hints.

staninprague avatar Jul 13 '20 14:07 staninprague

It is busy in chalk. What project is this on?

bjorn3 avatar Jul 13 '20 15:07 bjorn3

Can some user based action be taken to quit this "busy in chalk" loop? It's an actix-web/diesel project of mine, not that big. Looks to me that every time new entities are added into schema.rs table! macros - this starts to happen. Actually, it happened also 2 times that rust-analyzer-mac doesn't exit when vscode exits and stays on these ~99% of cpu. If more logs are needed, I'll happy to provide. Please just tell how to gain them.

staninprague avatar Jul 13 '20 15:07 staninprague

Quoting @flodiebold (https://github.com/rust-analyzer/rust-analyzer/issues/4800#issuecomment-640780363)

Can you try running rust-analyzer analysis-stats . in the project, to see if that reproduces the crash? You should also see the last function it was working on when it crashes, so then you could run rust-analyzer analysis-stats -o that_function . to only check that function, and then run it with CHALK_DEBUG=1 or maybe 2 and RA_LOG=ra_hir_ty::traits=debug. If the function is too big, it might help to reduce it a bit first though.

bjorn3 avatar Jul 13 '20 16:07 bjorn3

It says "Error: Invalid flags" when I run "path_to/rust-analyzer-mac" analysis-stats from the project folder. The only option that works for me is "path_to/rust-analyzer-mac" analysis-stats -h. I tried a few others like -v, still "Error: Invalid flags".

staninprague avatar Jul 13 '20 16:07 staninprague

The command is path_to/rust-analyzer-mac analysis-stats . including the dot.

bjorn3 avatar Jul 13 '20 16:07 bjorn3

Thank you! When I run "path_to/rust-analyzer-mac" analysis-stats . It is getting stuck consistently in one function:

Crates in this dir: 10
Total modules found: 151
Total declarations: 5320
Total functions: 1727
Item Collection: 25.260290326s, 0b allocated 0b resident
629/1727 94% processing: db::members::update_status

On different runs it comes to this function differently, but when it comes to it, it is stuck.

Though when I run it only for this function like you suggested:

CHALK_DEBUG=2;RA_LOG=ra_hir_ty::traits=debug; "path_to/rust-analyzer-mac" analysis-stats . -o db::members::update_status

It is stuck in:

Database loaded 504.830744ms
Crates in this dir: 10
Total modules found: 151
Total declarations: 5320
Total functions: 1727
Item Collection: 24.811177535s, 0b allocated 0b resident
0/1727 0% processing: db::members::update_status

And no further output is provided. Am I missing something again? Sorry for being a noob. I waited for a few minutes and several times to be sure that it is stuck. What could be my next steps?

The function it is stuck in is very short:

pub fn update_status(
	member_uuid: &Uuid,
	new_status: i32,
	connection: &DbConnection,
) -> Result<(), diesel::result::Error> {
	let _count = diesel::update(members.filter(id.eq(member_uuid)))
		.set(status.eq(new_status))
		.execute(connection)?;

	Ok(())
}

staninprague avatar Jul 13 '20 17:07 staninprague

I'll experiment more, but if I simply remove line with:

diesel::update(members.filter(id.eq(member_uuid)))
		.set(status.eq(new_status))
		.execute(connection)?;

Then analysis-stats . -o db::members::update_status is not stuck in this method.

Thank you a lot for the pointers! If I can help in any way to find where the culprit is, please let me know.

staninprague avatar Jul 13 '20 17:07 staninprague

CC https://github.com/rust-analyzer/rust-analyzer/issues/4186, although it's not necessarily the same issue.

By the way, weren't we using fuel for the chalk queries?

lnicola avatar Jul 13 '20 17:07 lnicola

If I rewrite the method in the following way:

pub fn update_status(
	member_uuid: &Uuid,
	new_status: i32,
	connection: &DbConnection,
) -> Result<(), diesel::result::Error> {

	let member_update = &UpdateMemberStatus{id: member_uuid.clone(), status: new_status};

	diesel::update(member_update).set(member_update).execute(connection)?;

	Ok(())
}

To avoid usage of:

members.filter(id.eq(member_uuid)))
		.set(status.eq(new_status))

Then analysis-stats . -o db::members::update_status is not stuck anymore.

And yes, rust-analyzer-mac takes longer to chew everything at the start of vscode. But this issue seems to be a "stuck completely" case.

staninprague avatar Jul 13 '20 18:07 staninprague

Hello! I am experiencing the same issues but on linux. Latest version does not like diesel filter/set and ramping cpu to 100% and getting stuck there.

Randomly picked an older version - 2020-06-15 release. Then everything works correctly. Currently I don't have time to experiment with other versions.

sanderkukk avatar Jul 15 '20 08:07 sanderkukk

Running into this on Linux with version 0.2.240, similarly also using Diesel. Metadata from rust-analyzer gets extremely slow or non-existent, and then hangs almost completely on format on save. Similarly this was working in some previous version (likely ~1 month ago? haven't tried to use on this project in recent weeks).

Running the analysis stats command from above gives a similar state where it gets stuck on a particular method which is using similar methods as reported above (column.eq(...)). I've left it for upwards of 5+ minutes

> ~/.vscode-server/data/User/globalStorage/matklad.rust-analyzer/rust-analyzer-linux analysis-stats .
Database loaded 430.66915ms
Crates in this dir: 23
Total modules found: 223
Total declarations: 5587
Total functions: 2728
Item Collection: 23.89613302s, 0b allocated 0b resident
129/2728 4% processing: db::pg::clear_subscription_sync    

Running with CHALK_DEBUG=2 RA_LOG=ra_hir_ty::traits=debug quickly gives repeating:

[DEBUG ra_hir_ty::traits::chalk] impls_for_trait Insertable
[DEBUG ra_hir_ty::traits::chalk] impls_for_trait returned 1 impls

Attached a 'full' log: ra-debug.txt (truncated after a reasonable amount of repetition)

The method in question has a call amounting to:

use schema::organisations::{self, dsl as organisation};

fn clear_subscription_sync(conn: &Conn, account_id: Uuid) -> DbResult<()> {
    diesel::update(organisations::table)
        .filter(organisation::account_id.eq(account_id))
        .set(organisation::user_limit.eq(None::<i32>))
        .execute(conn)?;
    ...
}

Stubbing out the diesel::update() and re-running analysis lets it get past that method. I do though have quite a lot of existing methods similar to this so this has made rust-analyzer basically unusable. Are there any extra diagnostics I can provide that would assist?

EDIT:

I've created a basic reproduction at https://github.com/c-spencer/ra-diesel-slowness. This seems to just be slowness with Diesel, so might be the same root cause as #4186? A single table! statement usually works and completes okay, with the 10 it's extremely slow (to the point ~~I've not seen it complete once it gets slow~~ it takes 30+ minutes to do the save).

Making simple changes seems to be quick once it's completed, until certain changes, e.g. removing the semi-colon is okay, but commenting out the .filter(...) line then puts it back on the slow path.

c-spencer avatar Jul 17 '20 17:07 c-spencer

Running the above reproduction resulted in a lot (many thousands) of these:

[DEBUG ra_hir_ty::traits::chalk] impls_for_trait QueryFragment
[DEBUG ra_hir_ty::traits::chalk] Unrestricted search for TraitId(268) impls...
[DEBUG ra_hir_ty::traits::chalk] impls_for_trait returned 182 impls
[DEBUG ra_hir_ty::traits::chalk] impls_for_trait QueryFragment
[DEBUG ra_hir_ty::traits::chalk] Unrestricted search for TraitId(268) impls...
[DEBUG ra_hir_ty::traits::chalk] impls_for_trait returned 182 impls

That's 182 impls for 10 table! calls, and 185 impls for 11 table! calls, so it's not like the number of impls is growing that hard...

Looking at cargo expand output (which I highly recommend to debug stuff like this), this generates something like this for every table! call:

mod testable {
    pub struct star;
    impl<DB: Backend> QueryFragment<DB> for star
    where
        <table as QuerySource>::FromClause: QueryFragment<DB>,
    {
        fn walk_ast(&self, mut out: AstPass<DB>) -> QueryResult<()> {
            table.from_clause().walk_ast(out.reborrow())?;
            out.push_sql(".*");
            Ok(())
        }
    }
}

detrumi avatar Jul 19 '20 12:07 detrumi

These unrestricted searches happen because the self type is an associated type projection, and Chalk doesn't first normalize it. This should get fixed by the syntactic equality work, which sadly seems a bit stalled...

flodiebold avatar Jul 19 '20 15:07 flodiebold

Hello! I am experiencing the same issues but on linux. Latest version does not like diesel filter/set and ramping cpu to 100% and getting stuck there.

Randomly picked an older version - 2020-06-15 release. Then everything works correctly. Currently I don't have time to experiment with other versions.

I tested version 08-31, 08-24, 07-06 and 06-22, they all get stuck on some diesel method. So maybe currently 06-15 is the latest working version for diesel project? Interestingly, version 06-15 process items in dependent crate first, 06-22 and later versions process items in current crate first.

sify21 avatar Sep 01 '20 08:09 sify21

@staninprague did this get better?

lnicola avatar Dec 19 '20 07:12 lnicola

@staninprague did this get better?

For me, certainly. I'm still avoiding use of the diesel code construct that caused the issue, but issues when diesel schema regeneration and subsequent updates to diesel related code were causing 100% and long CPU spikes - they are not present for me anymore. Huge thanks to rust-analyzer team members!

staninprague avatar Dec 19 '20 08:12 staninprague

I was asking because the syntactic equality changes that @flodiebold mentioned have landed in chalk.

Anyone else, please file different issues, preferably with code that reproduced the problem.

lnicola avatar Dec 19 '20 08:12 lnicola