mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 20:09:19 +00:00
Add tracing spans to macro generated database
This commit is contained in:
parent
52d8ae791d
commit
a3b6e891ea
12 changed files with 78 additions and 128 deletions
|
@ -235,13 +235,24 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream
|
|||
|
||||
queries_with_storage.push(fn_name);
|
||||
|
||||
let tracing = if let QueryStorage::Memoized = query.storage {
|
||||
let s = format!("{trait_name}::{fn_name}");
|
||||
Some(quote! {
|
||||
let _p = tracing::span!(tracing::Level::DEBUG, #s, #(#key_names = tracing::field::debug(&#key_names)),*).entered();
|
||||
})
|
||||
} else {
|
||||
None
|
||||
}
|
||||
.into_iter();
|
||||
|
||||
query_fn_definitions.extend(quote! {
|
||||
fn #fn_name(&self, #(#key_names: #keys),*) -> #value {
|
||||
#(#tracing),*
|
||||
// Create a shim to force the code to be monomorphized in the
|
||||
// query crate. Our experiments revealed that this makes a big
|
||||
// difference in total compilation time in rust-analyzer, though
|
||||
// it's not totally obvious why that should be.
|
||||
fn __shim(db: &(dyn #trait_name + '_), #(#key_names: #keys),*) -> #value {
|
||||
fn __shim(db: &(dyn #trait_name + '_), #(#key_names: #keys),*) -> #value {
|
||||
salsa::plumbing::get_query_table::<#qt>(db).get((#(#key_names),*))
|
||||
}
|
||||
__shim(self, #(#key_names),*)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue