python / python/cpython

Add ETW instrumentation to allow profilers to map JITed code to function names

Open
#137,022 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

OS-windows performance topic-JIT type-feature
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Feature or enhancement

Proposal:

For Linux and macOS, currently cpython has perf maps/jitdump support (macOS support is added in #136461)

In here, Jeff mentioned that Windows support is possible through ETW JSCRIPT9::MethodLoad events instead of jitdump: https://github.com/python/cpython/pull/136461#issuecomment-3104217608

This will allow samply and also Windows Performance Analyzer to read and inject these JITed function names.

Firefox and Chrome both emit these events for jitted JS code:
https://bugzilla.mozilla.org/show_bug.cgi?id=1765402
https://bugs.chromium.org/p/v8/issues/detail?id=11043

For more specifically, code for this is here:
https://searchfox.org/mozilla-central/rev/387160feb07b75ae76bfc12df035a10f58d25168/js/src/jit/PerfSpewer.cpp#643
https://chromium.googlesource.com/v8/v8/+/88926769783fecb3bd3b08a7a0cb702b037d9f85/src/diagnostics/system-jit-win.cc

Some more links that were mentioned in other bugs:
https://github.com/Zhentar/UnityEtwSymbols/blob/e3614341a9553b2c916c9ebb12ace4a0eb46291b/etwSymbols.c
https://github.com/chakra-core/ChakraCore/blob/1eae003b7a981b4b691928daef27b5254a49f5eb/lib/Runtime/Language/AsmJsEncoder.cpp#L246

Note: ETW stands for Event Tracing for Windows

cc @pablogsal

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

#136461.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the perf maps and jitdump documentation linked in the issue, then read the discussion in #136461 and compare the referenced Firefox, Chromium, UnityEtwSymbols, and ChakraCore implementations. Done means Windows ETW events expose JITed Python function names and addresses so samply and Windows Performance Analyzer can map them.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.