fix stale session state when loading a second (new) trace via file>open#42
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes stale UI/profile state when loading multiple traces sequentially via File > Open, ensuring deterministic function table contents by clearing per-session and cache state between loads.
Changes:
- Add APIs to clear
SectionPanelmodule summaries and invoke them during section panel setup. - Clear static frame caches in
ResolvedProfileStackand thread-local caches used during ETW load. - Force function list refresh when setting the main summary for a new session.
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/Panels/SectionPanelPair.xaml.cs | Adds a passthrough method to clear module summaries from the main section panel. |
| src/ProfileExplorerUI/Panels/SectionPanel.xaml.cs | Implements clearing moduleSummaries_ and related computed state. |
| src/ProfileExplorerUI/MainWindowPanels.cs | Clears stale module summaries and refreshes function list during section panel setup; adds trace logging. |
| src/ProfileExplorerCore/Profile/ETW/ETWProfileDataProvider.cs | Clears static frame caches and thread-local caches to prevent cross-trace leakage. |
| src/ProfileExplorerCore/Profile/Data/RawProfileData.cs | Adds API to clear caches used for IP-to-image resolution. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Fixes stale state persisting when opening multiple traces in the same app session, which could lead to incorrect function-table data (e.g., old functions persisting with 0ms weights).
Changes:
- Clears
SectionPanel’s accumulated module summaries when setting up a new trace. - Resets static frame caches in
ResolvedProfileStackto prevent cross-trace frame/function reuse. - Clears thread-local IP→image caches to avoid leaking per-thread state across trace loads.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/ProfileExplorerUI/Panels/SectionPanelPair.xaml.cs | Adds pass-through API to clear module summaries. |
| src/ProfileExplorerUI/Panels/SectionPanel.xaml.cs | Implements clearing of cached module summaries / computed state. |
| src/ProfileExplorerUI/MainWindowPanels.cs | Clears summaries on setup and forces function list update on main summary load. |
| src/ProfileExplorerCore/Profile/ETW/ETWProfileDataProvider.cs | Resets static caches on provider construction and clears thread-local caches during chunk collection. |
| src/ProfileExplorerCore/Profile/Data/ResolvedProfileStack.cs | Adds ResetCaches() for static frame caches. |
| src/ProfileExplorerCore/Profile/Data/RawProfileData.cs | Adds API to clear thread-local caches. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Fixes nondeterministic/stale UI profiling data when loading a second trace by clearing state that can leak across trace loads (UI module summaries and static/thread-local frame/image caches).
Changes:
- Add
ClearModuleSummaries()toSectionPanel(and a forwarding method onSectionPanelPair) to reset optional module summary state between loads. - Clear
ResolvedProfileStackstatic caches at ETW provider construction time and clear thread-local image caches at the start of chunk processing. - Ensure the section panel initialization path clears prior module summaries when setting up panels for a new load.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/ProfileExplorerUI/Panels/SectionPanelPair.xaml.cs | Adds a ClearModuleSummaries() forwarder to the main section panel. |
| src/ProfileExplorerUI/Panels/SectionPanel.xaml.cs | Implements ClearModuleSummaries() to reset stored optional module summaries. |
| src/ProfileExplorerUI/MainWindowPanels.cs | Clears module summaries during section panel setup and forces function list refresh on main summary set. |
| src/ProfileExplorerCore/Profile/ETW/ETWProfileDataProvider.cs | Resets static frame caches per load and clears thread-local caches per chunk worker start. |
| src/ProfileExplorerCore/Profile/Data/ResolvedProfileStack.cs | Adds ResetCaches() API for static frame cache dictionaries. |
| src/ProfileExplorerCore/Profile/Data/RawProfileData.cs | Adds ClearThreadLocalCaches() helper to reset per-thread IP→image caches. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
7be56c3 to
11deb4e
Compare
11deb4e to
c1e898e
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Opening a second trace via
File > Openwhile another trace is already loaded might show wrong data in the function table (stale functions from the previous trace persist with 0ms weights).Two things were leaking across trace loads on occasion:
moduleSummaries_in SectionPanel was never cleared, so old functions accumulated alongside new onesResolvedProfileStackand thread-localIpToImageCacheentries survived across loads since thread pool threads get reusedClearing these on new trace load makes results deterministic, regardless of order we open trace after trace in.
Tested by loading the same trace fresh vs after another trace, and seeing that now the weights, etc., are equal.