Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
Initial perf jitdump implementation (#26897)
Browse files Browse the repository at this point in the history
* Initial perf jitdump implementation

When COMPlus_PerfMapEnabled is enabled, generate jitdump file.

Usage:

export COMPlus_PerfMapEnabled=1
perf record -k 1 -g corerun helloworld.dll
perf --debug verbose=10 inject --input perf.data --jit --output perfjit.data
perf report --input perfjit.data

Works best with latest perf with patches:

Repo: git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 
Branch: perf/urgent
Patches:
- https://lkml.org/lkml/2019/10/2/875

cd tools/perf && make DEBUG=1
  • Loading branch information
sdmaclea committed Oct 7, 2019
1 parent 2ca2b2b commit 0868d20
Show file tree
Hide file tree
Showing 8 changed files with 489 additions and 11 deletions.
1 change: 1 addition & 0 deletions Documentation/project-docs/clr-configuration-knobs.md
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,7 @@ Name | Description | Type | Class | Default Value | Flags
`ETWEnabled` | This flag is used on OSes < Vista to enable/disable ETW. It is disabled by default | `DWORD` | `EXTERNAL` | `0` | REGUTIL_default
`MsBetweenAttachCheck` | | `DWORD` | `EXTERNAL` | `500` |
`PerfMapEnabled` | This flag is used on Linux to enable writing /tmp/perf-$pid.map. It is disabled by default | `DWORD` | `EXTERNAL` | `0` | REGUTIL_default
`PerfMapJitDumpPath` | Specifies a path to write the perf jitdump file. Defaults to GetTempPathA() | `STRING` | `EXTERNAL` | | REGUTIL_default
`PerfMapIgnoreSignal` | When perf map is enabled, this option will configure the specified signal to be accepted and ignored as a marker in the perf logs. It is disabled by default | `DWORD` | `EXTERNAL` | `0` | REGUTIL_default
`ProfAPI_AttachProfilerMinTimeoutInMs` | Timeout in ms for the minimum time out value of AttachProfiler | `DWORD` | `EXTERNAL` | `10*1000` |
`ProfAPI_DetachMaxSleepMs` | The maximum time, in milliseconds, the CLR will wait before checking whether a profiler that is in the process of detaching is ready to be unloaded. | `DWORD` | `EXTERNAL` | `0` |
Expand Down
1 change: 1 addition & 0 deletions src/inc/clrconfigvalues.h
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,7 @@ RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_ProfAPI_ValidateNGENInstrumentation, W("Pro

#ifdef FEATURE_PERFMAP
RETAIL_CONFIG_DWORD_INFO_EX(EXTERNAL_PerfMapEnabled, W("PerfMapEnabled"), 0, "This flag is used on Linux to enable writing /tmp/perf-$pid.map. It is disabled by default", CLRConfig::REGUTIL_default)
RETAIL_CONFIG_STRING_INFO_EX(EXTERNAL_PerfMapJitDumpPath, W("PerfMapJitDumpPath"), "Specifies a path to write the perf jitdump file. Defaults to GetTempPathA()", CLRConfig::REGUTIL_default)
RETAIL_CONFIG_DWORD_INFO_EX(EXTERNAL_PerfMapIgnoreSignal, W("PerfMapIgnoreSignal"), 0, "When perf map is enabled, this option will configure the specified signal to be accepted and ignored as a marker in the perf logs. It is disabled by default", CLRConfig::REGUTIL_default)
RETAIL_CONFIG_DWORD_INFO(EXTERNAL_PerfMapShowOptimizationTiers, W("PerfMapShowOptimizationTiers"), 1, "Shows optimization tiers in the perf map for methods, as part of the symbol name. Useful for seeing separate stack frames for different optimization tiers of each method.")
RETAIL_CONFIG_STRING_INFO(EXTERNAL_NativeImagePerfMapFormat, W("NativeImagePerfMapFormat"), "Specifies the format of native image perfmap files generated by crossgen. Valid options are RVA or OFFSET.")
Expand Down
18 changes: 18 additions & 0 deletions src/pal/inc/pal.h
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,24 @@ PAL_ProbeMemory(
DWORD cbBuffer,
BOOL fWriteAccess);

PALIMPORT
int
PALAPI
// Start the jitdump file
PAL_PerfJitDump_Start(const char* path);

PALIMPORT
int
PALAPI
// Log a method to the jitdump file.
PAL_PerfJitDump_LogMethod(void* pCode, size_t codeSize, const char* symbol, void* debugInfo, void* unwindInfo);

PALIMPORT
int
PALAPI
// Finish the jitdump file
PAL_PerfJitDump_Finish();

/******************* winuser.h Entrypoints *******************************/
PALIMPORT
LPSTR
Expand Down
1 change: 1 addition & 0 deletions src/pal/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ set(SOURCES
misc/jitsupport.cpp
misc/miscpalapi.cpp
misc/msgbox.cpp
misc/perfjitdump.cpp
misc/strutil.cpp
misc/sysinfo.cpp
misc/time.cpp
Expand Down
Loading

0 comments on commit 0868d20

Please sign in to comment.