MCPcopy Create free account
hub / github.com/async-profiler/async-profiler / recordExternalSample

Method recordExternalSample

src/profiler.cpp:487–512  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

485}
486
487void Profiler::recordExternalSample(u64 counter, int tid, EventType event_type, Event* event, int num_frames, ASGCT_CallFrame* frames) {
488 atomicInc(_total_samples);
489
490 if (_add_thread_frame) {
491 num_frames += makeFrame(frames + num_frames, BCI_THREAD_ID, tid);
492 }
493 if (_add_sched_frame) {
494 num_frames += makeFrame(frames + num_frames, BCI_ERROR, OS::schedPolicy(tid));
495 }
496
497 u32 call_trace_id = _call_trace_storage.put(num_frames, frames, counter);
498
499 u32 lock_index = getLockIndex(tid);
500 if (!_locks[lock_index].tryLock() &&
501 !_locks[lock_index = (lock_index + 1) % CONCURRENCY_LEVEL].tryLock() &&
502 !_locks[lock_index = (lock_index + 2) % CONCURRENCY_LEVEL].tryLock())
503 {
504 // Too many concurrent signals already
505 atomicInc(_failures[-ticks_skipped]);
506 return;
507 }
508
509 _jfr.recordEvent(lock_index, tid, call_trace_id, event_type, event);
510
511 _locks[lock_index].unlock();
512}
513
514void Profiler::recordExternalSamples(u64 samples, u64 counter, int tid, u32 call_trace_id, EventType event_type, Event* event) {
515 _call_trace_storage.add(call_trace_id, samples, counter);

Callers 2

timerLoopMethod · 0.80
timerLoopMethod · 0.80

Calls 6

atomicIncFunction · 0.85
makeFrameFunction · 0.85
putMethod · 0.45
tryLockMethod · 0.45
recordEventMethod · 0.45
unlockMethod · 0.45

Tested by

no test coverage detected