Struct ra_ap_profile::CpuSpan

source ·
pub struct CpuSpan { /* private fields */ }
Expand description

A wrapper around google_cpu_profiler.

Usage:

  1. Install gpref_tools (https://github.com/gperftools/gperftools), probably packaged with your Linux distro.
  2. Build with cpu_profiler feature.
  3. Run the code, the raw output would be in the ./out.profile file.
  4. Install pprof for visualization (https://github.com/google/pprof).
  5. Bump sampling frequency to once per ms: export CPUPROFILE_FREQUENCY=1000
  6. 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:

https://github.com/rust-lang/rust-analyzer/pull/5306

Trait Implementations§

source§

impl Debug for CpuSpan

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Drop for CpuSpan

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.