简体   繁体   English

.NET本机和RCW开销

[英].NET Native and RCW overhead

I'm curious about how .NET Native works. 我对.NET Native的工作方式很好奇。 Normally when using WinRT classes in managed code, they are invoked through RCW, incurring some overhead due to the interop between managed and unmanaged code. 通常,在托管代码中使用WinRT类时,它们是通过RCW调用的,由于托管代码和非托管代码之间的互操作会产生一些开销。 I wonder if there is theoretically the same overhead when the managed code is compiled using .NET Native? 我想知道使用.NET Native编译托管代码时,理论上是否有相同的开销?

.NET Native interop with WinRT has the same structure as running with CoreCLR or full framework. 带有WinRT的.NET本机互操作具有与CoreCLR或完整框架一起运行的结构。 This is because you have the unavoidable overhead of ensuring the memory for various objects is tracked properly as they are handed accross the boundary. 这是因为不可避免的开销是确保跨边界处理各种对象时正确跟踪它们的内存。 There will always be come irreducible set of things that need to be tracked because of the GC in whichever .NET runtime you're targeting. 无论您针对哪个.NET运行时,总是会有一些不可归结的事物需要跟踪,这是因为GC。

That said, the interop code generated for a .NET Native based application will have the benefit of being generated ahead-of-time. 也就是说,为基于.NET Native的应用程序生成的互操作代码将具有提前生成的好处。 This means that it's able to be optimized by the same program optimizer that is part of our C++ compiler so you're going to get the best assembly codegen that Microsoft can offer. 这意味着它可以由我们C ++编译器中的同一程序优化器进行优化,因此您将获得Microsoft提供的最佳汇编代码源。

(Disclosure: I work on the .NET Native runtime and compiler team) (公开:我在.NET Native运行时和编译器团队工作)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM