Skip to content

CoreCLR sample profiling seems expensive #83754

Open
@LakshanF

Description

@LakshanF

As part of exploring enabling the sample profiler in NativeAOT, I came across the CoreCLR implementation and that seems relatively expensive. We suspend managed execution, iterate over managed threads to get the stack information, and then resume execution.

Wrt NativeAOT, it might not be necessary for the runtime to provide this service and perhaps NativeAOT can get away with relying on platform profilers for this service.

Talking over this with @VSadov, it seems worthwhile to explore less expensive ways to do this in CoreCLR when large numbers of threads are involved.

Filing this issue to track the problem, relevant details of the call stack is copied in case its useful.

0:010> kn
Child-SP          RetAddr               Call Site
05 00000026`d707fba0 00007ffd`3d4baf1e     coreclr!ep_rt_coreclr_sample_profiler_write_sampling_event_for_threads+0x5c [runtime\src\coreclr\vm\eventing\eventpipe\ep-rt-coreclr.cpp @ 159] 
06 00000026`d707fbd0 00007ffd`3d4c4ac0     coreclr!ep_rt_sample_profiler_write_sampling_event_for_threads+0x1e [runtime\src\coreclr\vm\eventing\eventpipe\ep-rt-coreclr.h @ 565] 
07 00000026`d707fc00 00007ffd`3d4bb3f2     coreclr!sampling_thread+0xe0 [runtime\src\native\eventpipe\ep-sample-profiler.c @ 101] 
08 00000026`d707fcf0 00007ffd`ec0c26bd     coreclr!ep_rt_thread_coreclr_start_func+0x32 [runtime\src\coreclr\vm\eventing\eventpipe\ep-rt-coreclr.h @ 813] 
09 00000026`d707fd40 00007ffd`edd0a9f8     KERNEL32!BaseThreadInitThunk+0x1d
0a 00000026`d707fd70 00000000`00000000     ntdll!RtlUserThreadStart+0x28

Metadata

Metadata

Assignees

Labels

area-Tracing-coreclrenhancementProduct code improvement that does NOT require public API changes/additionsruntime-coreclrspecific to the CoreCLR runtime

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions