diff options
-rw-r--r-- | crates/ra_hir_ty/src/infer.rs | 5 | ||||
-rw-r--r-- | crates/ra_ide/src/completion.rs | 1 | ||||
-rw-r--r-- | crates/ra_prof/Cargo.toml | 2 | ||||
-rw-r--r-- | crates/ra_prof/src/lib.rs | 7 |
4 files changed, 13 insertions, 2 deletions
diff --git a/crates/ra_hir_ty/src/infer.rs b/crates/ra_hir_ty/src/infer.rs index 5c56c2eb0..d8888e050 100644 --- a/crates/ra_hir_ty/src/infer.rs +++ b/crates/ra_hir_ty/src/infer.rs | |||
@@ -65,6 +65,11 @@ mod coerce; | |||
65 | /// The entry point of type inference. | 65 | /// The entry point of type inference. |
66 | pub(crate) fn infer_query(db: &dyn HirDatabase, def: DefWithBodyId) -> Arc<InferenceResult> { | 66 | pub(crate) fn infer_query(db: &dyn HirDatabase, def: DefWithBodyId) -> Arc<InferenceResult> { |
67 | let _p = profile("infer_query"); | 67 | let _p = profile("infer_query"); |
68 | let _cpu_profieler; | ||
69 | if ra_prof::Scope::is_active() { | ||
70 | _cpu_profieler = ra_prof::cpu_profiler(); | ||
71 | } | ||
72 | |||
68 | let resolver = def.resolver(db.upcast()); | 73 | let resolver = def.resolver(db.upcast()); |
69 | let mut ctx = InferenceContext::new(db, def, resolver); | 74 | let mut ctx = InferenceContext::new(db, def, resolver); |
70 | 75 | ||
diff --git a/crates/ra_ide/src/completion.rs b/crates/ra_ide/src/completion.rs index f3a5e9573..2a285718e 100644 --- a/crates/ra_ide/src/completion.rs +++ b/crates/ra_ide/src/completion.rs | |||
@@ -106,6 +106,7 @@ pub(crate) fn completions( | |||
106 | config: &CompletionConfig, | 106 | config: &CompletionConfig, |
107 | position: FilePosition, | 107 | position: FilePosition, |
108 | ) -> Option<Completions> { | 108 | ) -> Option<Completions> { |
109 | let _s = ra_prof::Scope::enter(); | ||
109 | let ctx = CompletionContext::new(db, position, config)?; | 110 | let ctx = CompletionContext::new(db, position, config)?; |
110 | 111 | ||
111 | let mut acc = Completions::default(); | 112 | let mut acc = Completions::default(); |
diff --git a/crates/ra_prof/Cargo.toml b/crates/ra_prof/Cargo.toml index eabfcebb0..db9b59ed6 100644 --- a/crates/ra_prof/Cargo.toml +++ b/crates/ra_prof/Cargo.toml | |||
@@ -24,4 +24,4 @@ cpu_profiler = [] | |||
24 | # Uncomment to enable for the whole crate graph | 24 | # Uncomment to enable for the whole crate graph |
25 | # default = [ "backtrace" ] | 25 | # default = [ "backtrace" ] |
26 | # default = [ "jemalloc" ] | 26 | # default = [ "jemalloc" ] |
27 | # default = [ "cpu_profiler" ] | 27 | default = [ "cpu_profiler" ] |
diff --git a/crates/ra_prof/src/lib.rs b/crates/ra_prof/src/lib.rs index 0fb468375..7163a8424 100644 --- a/crates/ra_prof/src/lib.rs +++ b/crates/ra_prof/src/lib.rs | |||
@@ -66,7 +66,8 @@ impl Drop for Scope { | |||
66 | /// 2. Build with `cpu_profiler` feature. | 66 | /// 2. Build with `cpu_profiler` feature. |
67 | /// 3. Tun the code, the *raw* output would be in the `./out.profile` file. | 67 | /// 3. Tun the code, the *raw* output would be in the `./out.profile` file. |
68 | /// 4. Install pprof for visualization (https://github.com/google/pprof). | 68 | /// 4. Install pprof for visualization (https://github.com/google/pprof). |
69 | /// 5. Use something like `pprof -svg target/release/rust-analyzer ./out.profile` to see the results. | 69 | /// 5. Bump sampling frequency to once per ms: `export CPUPROFILE_FREQUENCY=1000` |
70 | /// 6. Use something like `pprof -svg target/release/rust-analyzer ./out.profile` to see the results. | ||
70 | /// | 71 | /// |
71 | /// For example, here's how I run profiling on NixOS: | 72 | /// For example, here's how I run profiling on NixOS: |
72 | /// | 73 | /// |
@@ -74,6 +75,10 @@ impl Drop for Scope { | |||
74 | /// $ nix-shell -p gperftools --run \ | 75 | /// $ nix-shell -p gperftools --run \ |
75 | /// 'cargo run --release -p rust-analyzer -- parse < ~/projects/rustbench/parser.rs > /dev/null' | 76 | /// 'cargo run --release -p rust-analyzer -- parse < ~/projects/rustbench/parser.rs > /dev/null' |
76 | /// ``` | 77 | /// ``` |
78 | /// | ||
79 | /// See this diff for how to profile completions: | ||
80 | /// | ||
81 | /// https://github.com/rust-analyzer/rust-analyzer/pull/5306 | ||
77 | #[derive(Debug)] | 82 | #[derive(Debug)] |
78 | pub struct CpuProfiler { | 83 | pub struct CpuProfiler { |
79 | _private: (), | 84 | _private: (), |