Skip to content

Fix missing weight due to JITted code#41

Merged
jhpohovey merged 15 commits into
mainfrom
user/johnpohovey/missing-jit
Mar 25, 2026
Merged

Fix missing weight due to JITted code#41
jhpohovey merged 15 commits into
mainfrom
user/johnpohovey/missing-jit

Conversation

@jhpohovey

@jhpohovey jhpohovey commented Mar 17, 2026

Copy link
Copy Markdown
Member

previously when there was JITted code (either from e.g., Java, Lua, or from Prism emulation of x64 exe on arm64 device, the cpu time would be missing function pane, as discussed in profile-explorer/issues/31

Now, shows up as something like:
image

Tested on traces containing toy .EXEs with Java JIT, Lua JIT, and x64 .EXE running under emulation on an Arm64 device. The naming scheme is [JIT () ], where StartModule is the module containing the thread's entry point, and ThreadName is the OS-assigned name of the thread where unmapped samples were observed. These names reflect the host thread identity, not the names of individual JITted functions being executed.

@jhpohovey jhpohovey changed the title User/johnpohovey/missing jit Fix missing weight due to JITted code Mar 17, 2026
@jhpohovey jhpohovey marked this pull request as ready for review March 18, 2026 15:33
Copilot AI review requested due to automatic review settings March 18, 2026 15:33
@jhpohovey jhpohovey enabled auto-merge (squash) March 18, 2026 15:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses missing CPU weight in the Functions pane when samples’ instruction pointers don’t resolve to any loaded module (common with JITted/unmapped code such as Java/Lua JIT or emulation scenarios). It introduces a synthetic module/function attribution path so those samples remain visible and navigable in the UI.

Changes:

  • Add a synthetic [Unknown Module] per profiled process and attribute unresolved stack frames to per-thread synthetic functions (named [JIT <ThreadName> (<ThreadId>) <StartModule>]).
  • Capture Win32StartAddr for threads from ETW so the synthetic function name can include the thread’s start module.
  • Keep RawProfileData.imagesMap_ alive after event processing so synthetic images can be added post-LoadingCompleted().

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/ProfileExplorerCore/Profile/ETW/ETWProfileDataProvider.cs Creates/uses synthetic unknown module state and attributes unresolved stack frames + PMC attribution to it.
src/ProfileExplorerCore/Profile/ETW/ETWEventProcessor.cs Records Win32StartAddr on ProfileThread from ETW thread start events.
src/ProfileExplorerCore/Profile/Data/RawProfileModel.cs Adds Win32StartAddr to ProfileThread protobuf model.
src/ProfileExplorerCore/Profile/Data/RawProfileData.cs Stops clearing imagesMap_ during LoadingCompleted() to allow adding synthetic images after ETW processing.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/ProfileExplorerCore/Profile/ETW/ETWProfileDataProvider.cs Outdated
Comment thread src/ProfileExplorerCore/Profile/Data/RawProfileData.cs Outdated
Comment thread src/ProfileExplorerCore/Profile/ETW/ETWProfileDataProvider.cs Outdated
@jhpohovey jhpohovey marked this pull request as draft March 18, 2026 16:14
auto-merge was automatically disabled March 18, 2026 16:14

Pull request was converted to draft

@jhpohovey jhpohovey force-pushed the user/johnpohovey/missing-jit branch from c32b148 to be58ecc Compare March 18, 2026 17:39
@jhpohovey jhpohovey requested a review from Copilot March 19, 2026 19:02

This comment was marked as duplicate.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/ProfileExplorerCore/Profile/ETW/ETWProfileDataProvider.cs Outdated
Comment thread src/ProfileExplorerCore/Profile/ETW/ETWProfileDataProvider.cs
Comment thread src/ProfileExplorerCore/Profile/Data/RawProfileData.cs

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/ProfileExplorerCore/Profile/ETW/ETWProfileDataProvider.cs Outdated
Comment thread src/ProfileExplorerCore/Profile/ETW/ETWProfileDataProvider.cs Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

src/ProfileExplorerCore/Profile/ETW/ETWProfileDataProvider.cs:1545

  • When a PMC event maps to the synthetic unknown module, this still calls GetModuleBuilder(...), which can be relatively expensive and will always early-exit later due to missing debug info. For traces with lots of unmapped/JIT PMC samples, this becomes avoidable overhead. Consider short-circuiting when frameImage.ModuleName == "[Unknown Module]" (or frameImage == unknownModuleImage_) so only module-level counters are recorded without creating a module builder.
      if (frameImage != null) {
        profileData_.AddModuleCounter(frameImage.ModuleName, counter.CounterId, 1);
        var profileModuleBuilder = GetModuleBuilder(rawProfile, frameImage, context.ProcessId, symbolSettings);

        if (profileModuleBuilder == null) {
          continue;
        }

        if (!profileModuleBuilder.HasDebugInfo) {
          continue;
        }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/ProfileExplorerCore/Profile/ETW/ETWProfileDataProvider.cs
Comment thread src/ProfileExplorerCore/Profile/ETW/ETWProfileDataProvider.cs Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/ProfileExplorerCore/Profile/ETW/ETWProfileDataProvider.cs
Comment thread src/ProfileExplorerCore/Profile/ETW/ETWProfileDataProvider.cs Outdated
Comment thread src/ProfileExplorerCore/Profile/ETW/ETWProfileDataProvider.cs
Comment thread src/ProfileExplorerCore/Profile/ETW/ETWProfileDataProvider.cs

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/ProfileExplorerCore/Profile/ETW/ETWProfileDataProvider.cs Outdated
Comment thread src/ProfileExplorerCore/Profile/ETW/ETWProfileDataProvider.cs Outdated
Comment thread src/ProfileExplorerCore/Profile/ETW/ETWProfileDataProvider.cs
Comment thread src/ProfileExplorerCore/Profile/ETW/ETWProfileDataProvider.cs Outdated
Comment thread src/ProfileExplorerCore/Profile/ETW/ETWProfileDataProvider.cs

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/ProfileExplorerCore/Profile/ETW/ETWProfileDataProvider.cs
Comment thread src/ProfileExplorerCoreTests/ETWUnmappedFrameResolutionTests.cs Outdated
@jhpohovey jhpohovey marked this pull request as ready for review March 24, 2026 23:30
@jhpohovey jhpohovey enabled auto-merge (squash) March 24, 2026 23:30
@jhpohovey jhpohovey disabled auto-merge March 24, 2026 23:30
@jhpohovey jhpohovey enabled auto-merge (squash) March 24, 2026 23:31
@jhpohovey jhpohovey assigned jhpohovey and ivberg and unassigned jhpohovey Mar 24, 2026
@jhpohovey jhpohovey merged commit dd32a51 into main Mar 25, 2026
6 checks passed
@jhpohovey jhpohovey deleted the user/johnpohovey/missing-jit branch March 25, 2026 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants