class Sampler

Defined at line 54 of file ../../src/performance/cpu_profiler/sampler.h

Protected Members

async_dispatcher_t * dispatcher_
TargetTree targets_
vector sample_specs_
vector inspecting_durations_
function sample_cb_
unordered_map process_watchers_
unordered_map job_watchers_
map contexts_
unordered_set pending_module_caches_

Public Methods

void Sampler (async_dispatcher_t * dispatcher, TargetTree targets, std::vector<fuchsia_cpu_profiler::SamplingConfig> sample_specs, SampleCallback sample_cb)

Defined at line 56 of file ../../src/performance/cpu_profiler/sampler.h

fxl::WeakPtr<Sampler> GetWeakPtr ()

Defined at line 70 of file ../../src/performance/cpu_profiler/sampler.h

std::optional<std::string_view> GetProcessName (zx_koid_t pid)

Defined at line 72 of file ../../src/performance/cpu_profiler/sampler.h

std::optional<std::string_view> GetThreadName (zx_koid_t tid)

Defined at line 75 of file ../../src/performance/cpu_profiler/sampler.h

std::vector<zx::ticks> SamplingDurations ()

Defined at line 78 of file ../../src/performance/cpu_profiler/sampler.h

void ~Sampler ()

Defined at line 80 of file ../../src/performance/cpu_profiler/sampler.h

zx::result<> Start (size_t buffer_size_mb)

Defined at line 236 of file ../../src/performance/cpu_profiler/sampler.cc

zx::result<> Stop ()

Defined at line 247 of file ../../src/performance/cpu_profiler/sampler.cc

zx::result<profiler::SymbolizationContext> GetContexts ()

Return the information needed to symbolize the samples

Defined at line 290 of file ../../src/performance/cpu_profiler/sampler.cc

zx::result<> AddTarget (JobTarget && target)

Defined at line 107 of file ../../src/performance/cpu_profiler/sampler.cc

Protected Methods

zx::result<> WatchTargets ()

Defined at line 180 of file ../../src/performance/cpu_profiler/sampler.cc

zx::result<> WatchTarget (const JobTarget & target)

Defined at line 116 of file ../../src/performance/cpu_profiler/sampler.cc

void AddThread (std::vector<zx_koid_t> job_path, zx_koid_t pid, zx_koid_t tid, zx::thread t)

Defined at line 312 of file ../../src/performance/cpu_profiler/sampler.cc

void RemoveThread (std::vector<zx_koid_t> job_path, zx_koid_t pid, zx_koid_t tid)

Defined at line 328 of file ../../src/performance/cpu_profiler/sampler.cc

void CollectSamples (async_dispatcher_t * dispatcher, async::TaskBase * task, zx_status_t status)

Defined at line 254 of file ../../src/performance/cpu_profiler/sampler.cc

void CacheModules (const ProcessTarget & p)

Defined at line 337 of file ../../src/performance/cpu_profiler/sampler.cc

void ScheduleCacheModules (std::vector<zx_koid_t> job_path, zx_koid_t pid)

Cache the modules of process `pid` from a separate dispatcher task.

Thread start exceptions keep the new thread paused until they are handled, and reading a

process's modules can be slow (e.g. for Starnix processes with large address spaces). Calling

this from a thread start handler instead of CacheModules lets the new thread, and any other

thread start/exit queued behind it, proceed without waiting on the module scan.

Defined at line 359 of file ../../src/performance/cpu_profiler/sampler.cc

void AddProcessesStartedSinceConfigure ()

The target tree is populated when the session is configured, which can take a long time for

large targets (e.g. the whole system), and processes and threads keep starting in the meantime.

These add the ones that started since then, so that they aren't silently left out of the

session.

Call AddProcessesStartedSinceConfigure after watching the target jobs, and

AddThreadsStartedSinceConfigure after watching `process`, so that anything starting later is

reported by the watchers instead.

Defined at line 381 of file ../../src/performance/cpu_profiler/sampler.cc

void AddThreadsStartedSinceConfigure (std::span<const zx_koid_t> job_path, const ProcessTarget & process)

Defined at line 482 of file ../../src/performance/cpu_profiler/sampler.cc