Make comhost cache COM activation delegate info#130498
Merged
elinor-fung merged 6 commits intoJul 11, 2026
Merged
Conversation
DllGetClassObject resolved the COM activation delegate on every call, which loaded hostfxr and parsed the app's runtimeconfig.json (creating a new secondary host context) each time. For applications that create COM objects implemented in .NET in a tight loop this is a significant, repeated cost. Resolve the activation delegate once and cache it for the process lifetime (the runtime is never unloaded). Failures are not cached, so a transient failure is retried on the next activation. This reduces the per-activation runtimeconfig.json parsing from once per call to once per process. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR changes comhost’s DllGetClassObject path to resolve the COM activation delegate once and cache the activation state (app path, delegate pointers, and load context) for reuse, instead of reloading hostfxr and re-parsing configuration on every activation.
Changes:
- Added a cached
com_activation_infoand aget_com_activation_delegatehelper that initializes the activation delegate once and returns cached state on subsequent calls. - Updated
DllGetClassObjectto use the cached activation state when invoking the runtime activation delegate.
Show a summary per file
| File | Description |
|---|---|
| src/native/corehost/comhost/comhost.cpp | Introduces process/module-lifetime caching of COM activation delegate info and switches DllGetClassObject to use it. |
Copilot's findings
- Files reviewed: 1/1 changed files
- Comments generated: 1
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
AaronRobinsonMSFT
approved these changes
Jul 10, 2026
This was referenced Jul 11, 2026
Open
Member
Author
|
/ba-g wasm failures are #129849 |
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.
DllGetClassObject resolved the COM activation delegate on every call, which loaded hostfxr, parsed the app's runtimeconfig.json, and created a new secondary host context each time.
Since the inputs (the comhost path and runtimeconfig) for getting the activation delegate and load context should not change, we can just do this once per
comhost. This changescomhostto get the activation delegate once and cache it for the process lifetime.cc @dotnet/appmodel @AaronRobinsonMSFT @batzen
Fixes #130251