pub struct YingProfiler { /* private fields */ }Expand description
Ying is a memory profiling Allocator wrapper. Ying is the Chinese word for an eagle.
Implementations§
Source§impl YingProfiler
impl YingProfiler
Sourcepub const fn new(sampling_ratio: u32, single_alloc_limit: usize) -> Self
pub const fn new(sampling_ratio: u32, single_alloc_limit: usize) -> Self
sampling_ratio: number of allocations for every sampled allocation
pub const fn default() -> Self
Sourcepub fn start_profiling(&'static self) -> ProfilerRunner
pub fn start_profiling(&'static self) -> ProfilerRunner
Starts periodic memory reporting on a background thread and returns the ProfilerRunner
that was spawned. This is the one-line way to turn Ying on:
use ying_profiler::YingProfiler;
#[global_allocator]
static YING_ALLOC: YingProfiler = YingProfiler::default();
fn main() {
YING_ALLOC.start_profiling();
}This is a convenience only, and adds no capability of its own: it builds a
ProfilerRunner with a fixed set of values and calls ProfilerRunner::spawn. Those
values are a 5 minute DEFAULT_CHECK_INTERVAL_SECS check interval, a 10%
DEFAULT_PCT_CHANGE_TRIGGER change before a report is written, output to
DEFAULT_REPORTING_PATH (created if it does not exist), flamegraphs on, retained rather
than allocated memory, and inlined frames left unexpanded.
To change any of those, build the ProfilerRunner yourself with
ProfilerRunnerBuilder and call
spawn on it instead. The returned runner records the settings in
use, but the reporting thread has already been started with them; changing the returned
value has no effect.
Sourcepub fn total_retained_bytes() -> usize
pub fn total_retained_bytes() -> usize
Total outstanding retained bytes (not just sampled but all allocations)
Sourcepub fn profiled_bytes_allocated() -> usize
pub fn profiled_bytes_allocated() -> usize
Total bytes allocated for profiled allocations
Sourcepub fn profiled_bytes_retained() -> usize
pub fn profiled_bytes_retained() -> usize
Profiled bytes retained - retained memory usage amongst profiled allocations
pub fn symbol_map_size(&self) -> usize
Sourcepub fn num_outstanding_allocs(&self) -> usize
pub fn num_outstanding_allocs(&self) -> usize
Number of entries for outstanding sampled allocations map
Sourcepub fn num_stack_traces(&self) -> usize
pub fn num_stack_traces(&self) -> usize
Number of distinct stack traces that have been sampled
Sourcepub fn top_k_stacks_by_allocated(&self, k: usize) -> Vec<StackStats>
pub fn top_k_stacks_by_allocated(&self, k: usize) -> Vec<StackStats>
Get the top k stack traces by total profiled bytes allocated, in descending order. Note that “profiled bytes” refers to the bytes allocated during sampling by this profiler.
Sourcepub fn top_k_stacks_by_retained(&self, k: usize) -> Vec<StackStats>
pub fn top_k_stacks_by_retained(&self, k: usize) -> Vec<StackStats>
Get the top k stack traces by retained sampled memory, in descending order.
pub fn reset_state_for_testing_only(&self)
pub fn testing_only_guarantee_next_sample(&self)
Trait Implementations§
Source§impl GlobalAlloc for YingProfiler
impl GlobalAlloc for YingProfiler
Source§unsafe fn alloc(&self, layout: Layout) -> *mut u8
unsafe fn alloc(&self, layout: Layout) -> *mut u8
layout. Read more