Skip to content

Improves how process weights are calculated and displayed in the profile loading UI. Default filter out Idle#43

Merged
ivberg merged 3 commits into
mainfrom
user/ivberg/ProcessMCP_Weight
Mar 30, 2026
Merged

Improves how process weights are calculated and displayed in the profile loading UI. Default filter out Idle#43
ivberg merged 3 commits into
mainfrom
user/ivberg/ProcessMCP_Weight

Conversation

@ivberg

@ivberg ivberg commented Mar 30, 2026

Copy link
Copy Markdown
Collaborator

This pull request improves how process weights are calculated and displayed in the profile loading UI, especially regarding the "Idle" process. It introduces a new weight percentage that excludes the Idle process, updates the backend to support this calculation, and modifies the UI to allow users to toggle the exclusion of Idle. Additionally, it streamlines the process information extraction logic and makes several UI layout improvements.

Backend logic and data model changes:

  • Added WeightPercentageExcludingIdle to the ProcessSummary data model to represent process weight percentages calculated without the Idle process.
  • Updated ProcessSummaryBuilder to use process IDs as dictionary keys, calculate non-idle total weights, and populate the new WeightPercentageExcludingIdle field. [1] [2] [3] [4]

UI and process list improvements:

  • Modified the process list in ProfileLoadWindow.xaml to display WeightPercentageExcludingIdle instead of the original percentage and added a checkbox to allow users to exclude or include the Idle process in calculations. [1] [2]
  • Enhanced the UI layout for better usability, including moving controls, resizing columns, and improving progress indicator placement. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13]
  • Updated McpActionExecutor to extract process summaries directly (bypassing the UI window), filter out the Idle process, and use the new non-idle weight percentages for process filtering and display.

Code cleanup:

  • Removed the now-unnecessary ExtractProcessInfoAsync method from McpActionExecutor, as process information is now obtained directly from the backend.

ivberg and others added 2 commits March 29, 2026 11:37
…ses responses

Bypass the ProfileLoadWindow UI for process list extraction in
GetAvailableProcessesAsync and call ETWProfileDataProvider.FindTraceProcesses
directly. The previous approach opened a UI dialog and scraped its ListView,
but a race condition from double TextChanged invocation (binding + reflection)
could cause the wait logic to return an incomplete intermediate list with
empty Name/ImageFileName/CommandLine for most processes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ove ProfileLoadWindow layout

  - Fix ProcessSummaryBuilder hash mutation bug: key dictionaries by ProcessId (int)
    instead of ProfileProcess to prevent duplicate entries when Name changes after
    dictionary insertion (e.g., two Idle rows with split weights)
  - Add WeightPercentageExcludingIdle to ProcessSummary, pre-calculated for instant
    toggling between with/without Idle percentages
  - Add "Exclude Idle" checkbox to ProfileLoadWindow (default: checked) that filters
    PID 0 and shows recalculated weight percentages
  - MCP get_available_processes and open_trace now exclude Idle and use non-idle
    percentages for more meaningful LLM analysis
  - Restructure ProfileLoadWindow layout: DockPanel with buttons docked at bottom,
    process list fills remaining vertical space, removed SizeToContent to prevent
    window from extending off-screen

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 updates process weight calculations and the profile loading UI to better handle the Windows Idle/kernel process by adding a new “excluding Idle” weight percentage and making Idle filtering the default behavior.

Changes:

  • Added WeightPercentageExcludingIdle to ProcessSummary and computed it in ProcessSummaryBuilder.
  • Updated ProfileLoadWindow UI to display the excluding-idle percentage by default and added an “Exclude Idle” toggle that also hides PID 0.
  • Updated McpActionExecutor.GetAvailableProcessesAsync to pull process summaries directly from ETWProfileDataProvider.FindTraceProcesses (avoiding UI coupling) and to default-exclude PID 0 using the new percentage.

Reviewed changes

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

Show a summary per file
File Description
src/ProfileExplorerUI/Windows/ProfileLoadWindow.xaml.cs Applies an Idle filter to the process list view and dynamically switches the displayed weight binding based on the toggle.
src/ProfileExplorerUI/Windows/ProfileLoadWindow.xaml UI layout adjustments; adds “Exclude Idle” checkbox; updates weight column binding and layout.
src/ProfileExplorerUI/Mcp/McpActionExecutor.cs Switches to backend process extraction via FindTraceProcesses and defaults to excluding Idle with non-idle percentages.
src/ProfileExplorerCore/Profile/Data/ProcessSummaryBuilder.cs Uses PID-based maps and computes total and non-idle weight percentages for process summaries.
src/ProfileExplorerCore/Profile/Data/IProfileDataProvider.cs Extends ProcessSummary contract with WeightPercentageExcludingIdle for serialization/transport.

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

Comment thread src/ProfileExplorerCore/Profile/Data/ProcessSummaryBuilder.cs Outdated
Comment thread src/ProfileExplorerUI/Windows/ProfileLoadWindow.xaml.cs Outdated
Comment thread src/ProfileExplorerUI/Mcp/McpActionExecutor.cs Outdated
Comment thread src/ProfileExplorerCore/Profile/Data/IProfileDataProvider.cs Outdated
…e, reorder ProtoMember tags

  - Use ETWEventProcessor.KernelProcessId instead of magic 0 in idle filters
  - Set WeightPercentageExcludingIdle to WeightPercentage for PID 0 to avoid >100% values
  - Reorder ProtoMember tags to ascending order (4, 5) in ProcessSummary
}
} else {
weightPercentageExcludingIdle = 0;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: for more consistent conditional / ternary style immediately preceding this block, i'd personally suggest something like:

double weightPercentageExcludingIdle;
if (nonIdleWeightTicks > 0) {
    // For the idle/kernel process, the excluding-idle percentage is not meaningful.
    // Set it equal to the overall weight percentage to avoid confusing values.
    weightPercentageExcludingIdle = pair.Key != ETW.ETWEventProcessor.KernelProcessId
        ? 100 * (double)pair.Value.Ticks / nonIdleWeightTicks
        : weightPercentage;
} else {
  weightPercentageExcludingIdle = 0;
}

to replace the highlighted part

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Though ack that nesting a ternary within an if-else might start to look messy itself

@ivberg ivberg merged commit baa4f95 into main Mar 30, 2026
6 checks passed
@ivberg ivberg deleted the user/ivberg/ProcessMCP_Weight branch April 28, 2026 23:28
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.

4 participants