Refactor profiling into library#61
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the profiling model and related tooling toward a TraceEvent/IR-decoupled library (ProfileExplorer.Profiling), centered on a neutral function identity (ProfileFunctionId) and resolver-based navigation back to IRTextFunction. It updates the UI, MCP server, and tests to use the new identity and call-tree APIs, and introduces a new profiling/test suite project.
Changes:
- Introduces
ProfileExplorer.Profiling(+ tests) with neutralProfileFunctionId, sample/counter aggregation, call-tree building, disassembly annotation, and symbol/binary abstractions. - Re-keys core profiling data structures from
IRTextFunctiontoProfileFunctionId, adding aFunctionResolvermap for UI/document navigation. - Updates UI/MCP server/test code to use new call-tree update signature (
UpdateCallTree(weight, stack)) and to resolve functions viaProfileData.ResolveFunction(...).
Reviewed changes
Copilot reviewed 94 out of 101 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/ProfileExplorerUITests/SyntheticProfileTests.cs | Updates call-tree update invocation to the new weight-based API. |
| src/ProfileExplorerUI/ProfileStyles.xaml | Points CallTree XAML namespace to ProfileExplorer.Profiling assembly. |
| src/ProfileExplorerUI/Profile/ProfileListView.xaml.cs | Uses ProfileCallTreeNode.ResolveFunction(session) and FunctionName string properties. |
| src/ProfileExplorerUI/Profile/FlameGraph/FlameGraphPanel.xaml.cs | Uses resolved function when opening sections. |
| src/ProfileExplorerUI/Profile/FlameGraph/FlameGraphHost.xaml.cs | Switches display/mark/preview actions to use FunctionName and resolved function. |
| src/ProfileExplorerUI/Profile/FlameGraph/FlameGraph.cs | Re-keys flame graph nodes/stack matching to ProfileFunctionId. |
| src/ProfileExplorerUI/Profile/Document/ProfilingUtils.cs | Re-keys marked-function collection from IRTextFunction to ProfileFunctionId. |
| src/ProfileExplorerUI/Profile/Document/ProfileDocumentMarker.cs | Uses FunctionProfileDataProcessing helper for offset-to-element mapping. |
| src/ProfileExplorerUI/Profile/CallTreePanel.xaml.cs | Uses FunctionId for combined-node lookup and resolves IRTextFunction for UI items. |
| src/ProfileExplorerUI/Profile/CallTreeNodePanel.xaml.cs | Re-keys instance enumeration/combining logic to ProfileFunctionId. |
| src/ProfileExplorerUI/Mcp/McpActionExecutor.cs | Resolves functions through ProfileData.ResolveFunction before querying extensions. |
| src/ProfileExplorerUI/MainWindowProfiling.cs | Routes profile navigation through ResolveFunction(this) from neutral call-tree nodes. |
| src/ProfileExplorerCoreTests/ETWUnmappedFrameResolutionTests.cs | Updates tests to use ProfileData.GetFunctionProfile(...) helper. |
| src/ProfileExplorerCoreTests/EndToEndWorkflowTests.cs | Groups/prints function baselines by ProfileFunctionId. |
| src/ProfileExplorerCoreTests/ASMIRSectionReaderTests.cs | Stabilizes test inputs by enforcing explicit CRLF newlines. |
| src/ProfileExplorerCore/Utilities/ExtensionMethods.cs | Adds ProfileCallTreeNode.ResolveFunction(ISession) helper. |
| src/ProfileExplorerCore/Providers/INameProvider.cs | Removes FunctionNameFormatter delegate (moved to profiling library). |
| src/ProfileExplorerCore/ProfileExplorerCore.csproj | Adds project reference to ProfileExplorer.Profiling. |
| src/ProfileExplorerCore/Profile/ProfileFunctionIdExtensions.cs | Adds IRTextFunction.ToProfileId() helper. |
| src/ProfileExplorerCore/Profile/Processing/ProfileSampleFilter.cs | Uses ProfileFunctionId-based child lookup. |
| src/ProfileExplorerCore/Profile/Processing/FunctionSamplesProcessor.cs | Compares stack frames via ProfileFunctionId. |
| src/ProfileExplorerCore/Profile/Processing/FunctionProfileProcessor.cs | Re-keys function profiles and tracks FunctionResolver for navigation. |
| src/ProfileExplorerCore/Profile/Processing/CallTreeProcessor.cs | Uses the new UpdateCallTree(weight, stack) API. |
| src/ProfileExplorerCore/Profile/ETW/ETWProfileDataProvider.cs | Registers created/synthetic functions into ProfileData resolver for navigation. |
| src/ProfileExplorerCore/Profile/Data/ResolvedProfileStack.cs | Implements IResolvedCallStack and precomputes ProfileFunctionId per frame. |
| src/ProfileExplorerCore/Profile/Data/RawProfileData.cs | Uses extracted MethodCode/AddressNamePair types. |
| src/ProfileExplorerCore/Profile/Data/ProfileModuleBuilder.cs | Registers module-created functions into ProfileData resolver. |
| src/ProfileExplorerCore/Profile/Data/ProfileData.cs | Re-keys profiles to ProfileFunctionId + adds FunctionResolver + resolve/register APIs. |
| src/ProfileExplorerCore/Profile/Data/ManagedRawProfileData.cs | Updates managed method code map to new MethodCode type. |
| src/ProfileExplorerCore/Profile/CallTree/ProfileCallTreeExtensions.cs | Adds IRTextFunction convenience overloads mapping to ProfileFunctionId. |
| src/ProfileExplorerCore/IR/Tags/SourceStackTrace.cs | Removes SourceStackFrame (moved into profiling library). |
| src/ProfileExplorerCore/Compilers/ASM/ASMBinaryFileFinder.cs | Switches to BinaryFileLocator for binary location. |
| src/ProfileExplorerCore/Binary/SymbolFileCache.cs | Removes old symbol cache implementation (moved/refactored). |
| src/ProfileExplorerCore/Binary/IDisassembler.cs | Extracts disassembler-related interfaces/options into a dedicated file. |
| src/ProfileExplorerCore/Binary/IDebugInfoProvider.cs | Refactors debug-info interface to derive from ISymbolDebugInfo. |
| src/ProfileExplorerCore/Binary/DotNetDebugInfoProvider.cs | Splits TraceEvent-free managed debug core into library base + PE-specific extensions. |
| src/ProfileExplorer.sln | Adds new profiling library and profiling test projects to the solution. |
| src/ProfileExplorer.Profiling/Symbols/SymbolFileCache.cs | Adds new gzip-based symbol cache in the profiling library. |
| src/ProfileExplorer.Profiling/Symbols/ISymbolFileResolver.cs | Introduces symbol/binary resolver abstraction for library consumers. |
| src/ProfileExplorer.Profiling/Providers/FunctionNameFormatter.cs | Restores FunctionNameFormatter delegate in profiling library. |
| src/ProfileExplorer.Profiling/Profiling/SampleAggregator.cs | Adds concurrent per-function sample aggregation keyed by ProfileFunctionId. |
| src/ProfileExplorer.Profiling/Profiling/ProfileFunctionId.cs | Introduces neutral (module, function-name) function identity. |
| src/ProfileExplorer.Profiling/Profiling/ManagedMethodResolver.cs | Adds managed-method IP resolution via binary search over JIT mappings. |
| src/ProfileExplorer.Profiling/Profiling/IpResolver.cs | Adds IP→(module,function,RVA) resolver with optional managed support. |
| src/ProfileExplorer.Profiling/Profiling/InstructionOffsetConfig.cs | Adds architecture-specific IP-skid correction helper. |
| src/ProfileExplorer.Profiling/Profiling/CounterAggregator.cs | Adds per-function per-instruction performance counter aggregation. |
| src/ProfileExplorer.Profiling/Profiling/CallTreeBuilder.cs | Adds call-tree builder over neutral resolved stacks. |
| src/ProfileExplorer.Profiling/ProfilerOptions.cs | Adds configurable profiling options + validation. |
| src/ProfileExplorer.Profiling/ProfileExplorer.Profiling.csproj | Adds new library project packaging native deps and targets file. |
| src/ProfileExplorer.Profiling/Profile/Data/ModuleProfileInfo.cs | Adds module-level profile grouping model. |
| src/ProfileExplorer.Profiling/Profile/Data/FunctionProfileData.cs | Adds function profile payload (weights, per-instruction weights/counters). |
| src/ProfileExplorer.Profiling/Profile/CallTree/ProfileCallTreeNode.cs | Refactors call-tree nodes to be IRTextFunction-free (uses ProfileFunctionId). |
| src/ProfileExplorer.Profiling/Profile/CallTree/ProfileCallSite.cs | Updates callsite target matching to ProfileFunctionId. |
| src/ProfileExplorer.Profiling/Profile/CallTree/IResolvedCallStack.cs | Adds neutral resolved stack interface/value frame type. |
| src/ProfileExplorer.Profiling/Models/ProfileReport.cs | Adds public library result model (functions map + call tree + total weight). |
| src/ProfileExplorer.Profiling/Models/CounterDescriptions.cs | Adds public performance counter/metric description models. |
| src/ProfileExplorer.Profiling/Models/AnnotatedAssembly.cs | Adds public annotated-assembly output models. |
| src/ProfileExplorer.Profiling/Managed/MethodCode.cs | Adds extracted managed method-code model + call target lookup. |
| src/ProfileExplorer.Profiling/Managed/ManagedDebugInfoProvider.cs | Adds TraceEvent-free managed debug-info core implementing ISymbolDebugInfo. |
| src/ProfileExplorer.Profiling/IR/SourceStackFrame.cs | Moves SourceStackFrame into the profiling library. |
| src/ProfileExplorer.Profiling/Disassembly/AssemblyAnnotator.cs | Adds disassembly annotation logic incl. skid correction + source lines. |
| src/ProfileExplorer.Profiling/Counters/PerformanceCounters.cs | Moves performance counter models/serialization helpers into the library. |
| src/ProfileExplorer.Profiling/Collections/TinyList.cs | Adds TinyList collection to support allocation-reduced call tree node storage. |
| src/ProfileExplorer.Profiling/build/net8.0/ProfileExplorer.Profiling.targets | Adds MSBuild targets for copying native runtime deps to consumer outputs. |
| src/ProfileExplorer.Profiling/Binary/SymbolFileDescriptor.cs | Adds symbol file descriptor model (PDB identity). |
| src/ProfileExplorer.Profiling/Binary/SourceLineDebugInfo.cs | Adds source-line debug info model used by symbol readers/annotation. |
| src/ProfileExplorer.Profiling/Binary/SourceFileDebugInfo.cs | Adds source-file debug info model used by symbol readers/annotation. |
| src/ProfileExplorer.Profiling/Binary/ISymbolDebugInfo.cs | Adds decoupled debug-info interface used by library disassembly/symbol logic. |
| src/ProfileExplorer.Profiling/Binary/IBinaryInfoProvider.cs | Adds binary identity model and provider interface. |
| src/ProfileExplorer.Profiling/Binary/FunctionDebugInfo.cs | Adds function debug info model (RVA/size/name + source lines). |
| src/ProfileExplorer.Profiling/Binary/Disassembler.cs | Refactors disassembler to depend on ISymbolDebugInfo and adds instruction-list API. |
| src/ProfileExplorer.Profiling/Abstractions/IProfileSample.cs | Adds consumer-facing sample abstraction. |
| src/ProfileExplorer.Profiling/Abstractions/IProfileImage.cs | Adds consumer-facing image/module abstraction. |
| src/ProfileExplorer.Profiling/Abstractions/IPerformanceCounterEvent.cs | Adds consumer-facing counter-event abstraction. |
| src/ProfileExplorer.Profiling/Abstractions/IManagedMethodMapping.cs | Adds consumer-facing managed mapping abstraction (+ IL mapping record). |
| src/ProfileExplorer.Profiling.Tests/Unit/SymbolServerClientTests.cs | Adds unit tests for symbol-path parsing and server config. |
| src/ProfileExplorer.Profiling.Tests/Unit/SampleAggregatorTests.cs | Adds unit tests for sample aggregation behavior. |
| src/ProfileExplorer.Profiling.Tests/Unit/ProfilerOptionsValidationTests.cs | Adds unit tests for options validation/clamping. |
| src/ProfileExplorer.Profiling.Tests/Unit/ManagedMethodResolverTests.cs | Adds unit tests for managed method binary search behavior. |
| src/ProfileExplorer.Profiling.Tests/Unit/IpSkidCorrectionTests.cs | Adds unit tests for skid correction behavior. |
| src/ProfileExplorer.Profiling.Tests/Unit/CounterAggregatorTests.cs | Adds unit tests for counter aggregation and derived metrics. |
| src/ProfileExplorer.Profiling.Tests/Unit/CallTreeBuilderTests.cs | Adds unit tests for call tree build + inclusive/exclusive weight behavior. |
| src/ProfileExplorer.Profiling.Tests/Unit/AssemblyAnnotatorTests.cs | Adds unit tests for annotated assembly output and hot-line extraction. |
| src/ProfileExplorer.Profiling.Tests/ProfileExplorer.Profiling.Tests.csproj | Adds profiling tests project configuration. |
| src/ProfileExplorer.Profiling.Tests/Integration/PdbSymbolProviderTests.cs | Adds integration tests for DIA-based PDB symbol loading. |
| src/ProfileExplorer.Profiling.Tests/Integration/PdbDiagnosticTests.cs | Adds optional diagnostic integration test controlled by env var. |
| src/ProfileExplorer.Profiling.Tests/Integration/FunctionProfilerEndToEndTests.cs | Adds end-to-end synthetic profiling → disassembly → annotation integration test. |
| src/ProfileExplorer.Profiling.Tests/Integration/DisassemblerTests.cs | Adds integration tests for disassembly correctness/robustness. |
| src/ProfileExplorer.Profiling.Tests/Helpers/TestDataHelper.cs | Adds shared helper for locating test data (Traces/Symbols/Binaries). |
| src/ProfileExplorer.Profiling.Tests/Helpers/SyntheticSampleBuilder.cs | Adds shared synthetic sample/image builders used by unit tests. |
| src/ProfileExplorer.McpServer/Program.cs | Updates MCP server profiling function lookup/formatting to use ProfileFunctionId. |
| global.json | Pins .NET SDK version for consistent builds. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
trgibeau
marked this pull request as ready for review
June 24, 2026 22:53
Resolve FindFunction conflict in McpServer by adapting main's demangled-name lookup feature to the branch's ProfileFunctionId model. Auto-merge keeps main's Managed Identity symbol auth (#58) alongside the PdbSymbolProvider refactor.
devinro
reviewed
Jul 1, 2026
devinro
reviewed
Jul 1, 2026
devinro
reviewed
Jul 1, 2026
devinro
reviewed
Jul 1, 2026
devinro
reviewed
Jul 1, 2026
devinro
reviewed
Jul 1, 2026
devinro
reviewed
Jul 2, 2026
devinro
reviewed
Jul 2, 2026
devinro
reviewed
Jul 2, 2026
devinro
reviewed
Jul 2, 2026
devinro
reviewed
Jul 2, 2026
devinro
reviewed
Jul 2, 2026
trgibeau
force-pushed
the
user/trgibeau/profilingLib
branch
from
July 2, 2026 16:18
06e470c to
b8a4fd0
Compare
devinro
reviewed
Jul 2, 2026
devinro
approved these changes
Jul 2, 2026
devinro
approved these changes
Jul 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces several improvements and refactorings to the profiling server and test infrastructure. The main focus is on improving function name resolution, refactoring function lookup logic for clarity and correctness, and adding new test helpers for synthetic sample and test data generation.
Profiling server improvements
Program.csto use a more robust approach based onProfileFunctionIdandProfileData, improving accuracy and maintainability. This includes changes toResolveFunctionName,FindFunction, and related usages throughout the code. [1] [2] [3] [4]ModuleName,FunctionName) and improved null checks for better reliability when aggregating callers, callees, and stack traces. [1] [2] [3]Internal API and cache changes
BinaryFileLocator.ClearResolvedCache()instead ofPEBinaryInfoProvider.ClearResolvedCache()for improved binary resolution cache management.Test infrastructure and helpers
SyntheticSampleBuilderhelper class for generating synthetic profile samples and images for unit tests, supporting various common test scenarios.TestDataHelperutility class for locating test data files (ETL, PDB, DLL) and providing helper methods to retrieve unique functions and paths for test cases.SDK version update
global.jsonto specify .NET SDK version8.0.421withrollForwardset tolatestMinorfor consistent build environments.