Skip to content

Avoid `QueryInterface' + 'Release' when wrapping managed CCWs #1938

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 28, 2025

Conversation

Sergio0694
Copy link
Member

This PR does a small optimization when creating IObjectReference-s wrapping CCWs produced by ComWrappers over managed objects. All CCWs produced by ComWrappers implement IAgileObject, meaning they're all always free-threaded. The original code didn't rely on this fact, and instead tested for the presence of that interface every single time. This PR removes that unnecessary work by adding a new 'AttachFreeThreadedUnsafe' method that can be used specifically when wrapping CCWs produced by ComWrappers, which skips the checks and always just wraps the objects as agile objects.

@Sergio0694 Sergio0694 added the performance Related to performance work label Feb 27, 2025
@Sergio0694 Sergio0694 merged commit 7cf8b53 into staging/2.3 Feb 28, 2025
10 checks passed
@Sergio0694 Sergio0694 deleted the user/sergiopedri/skip-agile-qi branch February 28, 2025 21:33
Sergio0694 added a commit that referenced this pull request Mar 12, 2025
Squashed commit of the following:

commit 8003cbd
Author: Sergio Pedri <sergio0694@live.com>
Date:   Wed Mar 12 09:13:10 2025 -0700

    Add .NET 9 target for WinRT.Runtime.dll (#1843)

    * Build CsWinRT with .NET 9 locally

    * Suppress all 'IL2081' warnings

    * Update 'MarshalNonBlittable' for AOT support

    * Update build steps for .NET 9

    * Update .nuspec file for .NET 9

    * Fix duplicate 'global.json' creation

    * Remove new framework references

    * Update CsWinRT-PublishToNuget-Stage.yml

    * Build .NET 9 in CI as well

    * Fix new IL analyzer warnings

    * Add missing nullable annotation

    * Remove double lookup in 'FindRcwTypeByNameCached'

    * Delete leftover API compat files

    * Fix build

    * Bump .NET SDK to 9.0.201

    Co-authored-by: Manodasan Wignarajah <mawign@microsoft.com>

    * Update src/build.cmd

    ---------

    Co-authored-by: Manodasan Wignarajah <mawign@microsoft.com>

commit ede00cc
Author: Sergio Pedri <sergio0694@live.com>
Date:   Tue Mar 11 09:11:39 2025 -0700

    Remove unused internal 'IPropertyValue' and IDIC support (#1937)

    * Remove 'IPropertyValue' IDIC interface

    * Add tests

    ---------

    Co-authored-by: Manodasan Wignarajah <mawign@microsoft.com>

commit 2abc88e
Author: Sergio Pedri <sergio0694@live.com>
Date:   Fri Mar 7 11:19:00 2025 -0800

    Remove unnecessary overload use (#1945)

commit 7cf8b53
Author: Sergio Pedri <sergio0694@live.com>
Date:   Fri Feb 28 13:33:42 2025 -0800

    Add and use 'AttachFreeThreadedUnsafe' (#1938)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Related to performance work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants