Struct ra_ap_profile::CpuSpan
source · [−]pub struct CpuSpan { /* private fields */ }
Expand description
A wrapper around google_cpu_profiler.
Usage:
- Install gpref_tools (https://github.com/gperftools/gperftools), probably packaged with your Linux distro.
- Build with
cpu_profiler
feature. - Run the code, the raw output would be in the
./out.profile
file. - Install pprof for visualization (https://github.com/google/pprof).
- Bump sampling frequency to once per ms:
export CPUPROFILE_FREQUENCY=1000
- Use something like
pprof -svg target/release/rust-analyzer ./out.profile
to see the results.
For example, here’s how I run profiling on NixOS:
$ bat -p shell.nix
with import <nixpkgs> {};
mkShell {
buildInputs = [ gperftools ];
shellHook = ''
export LD_LIBRARY_PATH="${gperftools}/lib:"
'';
}
$ set -x CPUPROFILE_FREQUENCY 1000
$ nix-shell --run 'cargo test --release --package rust-analyzer --lib -- benchmarks::benchmark_integrated_highlighting --exact --nocapture'
$ pprof -svg target/release/deps/rust_analyzer-8739592dc93d63cb crates/rust-analyzer/out.profile > profile.svg
See this diff for how to profile completions:
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for CpuSpan
impl Send for CpuSpan
impl Sync for CpuSpan
impl Unpin for CpuSpan
impl UnwindSafe for CpuSpan
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more