互操作&性能 [英] interop & performance

查看:61
本文介绍了互操作&性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,它使用具有100+(自动生成)的DLL管理

C ++包装一些原生API。


比较到一个纯粹的版本,我的应用程序有一些性能问题,我只是意识到这可能是由于安全检查只发生了

之前每个(众多)调用这个本机API。


现在我知道,或许,我可以使用

< SuppressUnmanagedCodeSecurityAttribute>
$标记我的MC ++包装器b $ b但是我想知道我是否可以在Main()

函数(例如Permission.Demand()或类似的东西)中放置其他调用来实现

相同的结果?


在我的所有代码之后,这是一个桌面应用程序,与用户一样多。

用户。

解决方案

我有一个应用程序,它使用的DLL有100+(自动生成)托管


C ++包装一些原生API。


与纯版本相比,我的应用程序有一些性能问题而且我只是意识到它可能是应付的在每次(多次)调用此本机API之前,安全检查只发生在



我不知道安全配置有多大影响,但

在托管和非托管上下文之间转换也需要时间,如好吧

来回作为编组参数。

如果你必须每秒多次这样做,这将产生重大影响。

如果这是你的问题,你可以做的很少,而

保持你现在的设计。


-


亲切的问候,

布鲁诺。
BR ********************** @ hotmail.com

仅删除_nos_pam


它只能是安全性。


没有参数编组,因为我正在使用C和指针(不是数组!)


100万方法调用(只是将int增加1)需要94ms纯粹的

native或.NET

但是700ms我使用两者的混合。

我怀疑安全堆栈走路是罪魁祸首...


Bruno van Dooren < br ********************** @ hotmail.comwrote in message

news:95 ******** ************************** @ microsof t.com ...


>我有一个应用程序,其中包含一个带有100+(自动生成)的DLL
管理的
C ++包装器,用于一些原生API。
与纯版本相比,我的应用程序有一些性能问题,而且我刚刚意识到这可能是由于安全检查只是在每次(多次)调用此本机之前发生的API。



我不知道安全配置有多大影响,但

在托管和非托管上下文之间转换也需要时间,如

well

作为来回编组参数。

如果你每秒必须多次这样做,这将有一个

重大影响。

如果这是你的问题,你可以做的很少,而

保持你现在的设计。 br $>
-


亲切的问候,

布鲁诺。
BR ********************* *@hotmail.com

仅删除_nos_pam



SUCS确实是一个对于没有损坏的电话,显着的性能提升。

不确定它是否适用于您的场景 - 但试一试。


请注意其含义 - 这个意味着部分信任ed调用者

可以使用你的包装器来调用Win32,而无需访问非托管代码。


dominick


我有一个应用程序,它使用的DLL有100+(自动生成)

托管C ++包装一些原生API。


比较一个纯粹的版本我的应用程序有一些性能问题

我刚刚意识到这可能是由于安全检查

发生在每个(众多)调用此本机之前API。


现在我知道,或许,我可以使用

< SuppressUnmanagedCodeSecurityAttribute>
$ b标记我的MC ++包装器$ b但是我想知道我是否可以在Main()

函数(例如Permission.Demand()或类似的东西)中放置另一个调用

实现了相同的结果吗?


完成我的所有代码后,这是一个桌面应用程序,用户身份为




I have an application which use has a DLL with 100+ (auto-generated) Managed
C++ wrapper around some native API.

Compare to a purely version my application has some performance issue and I
just realized it is probably due to the security check which happen just
before each of the (numerous) call into this native API.

Now I know that, perhaps, I could tag my MC++ wrapper with
<SuppressUnmanagedCodeSecurityAttribute>

But I wonder if there is not an other call I could place in the Main()
function (such as Permission.Demand() or stuff like that) which will achieve
the same result?

After all my code this is for a desktop application with as much right as
the user.

解决方案

I have an application which use has a DLL with 100+ (auto-generated) Managed

C++ wrapper around some native API.

Compare to a purely version my application has some performance issue and I
just realized it is probably due to the security check which happen just
before each of the (numerous) call into this native API.

I don''t know how much impact the security configuration has, but
transitioning between managed and unmanaged context takes time too, as well
as marshalling parameters back and forth.
If you have to do this lots of times per second, this will have a
significant impact.
If that is your problem, there is very little you can do about that while
keeping your design as it is now.

--

Kind regards,
Bruno.
br**********************@hotmail.com
Remove only "_nos_pam"


It could only be security.

No parameter marshalling happen, as I am using C and Pointers (not array!)

1 million method call (which just increment an int by 1) takes 94ms in pure
native or .NET
but 700ms when I use a mix of both.
I suspect the security stack walk to be the culprit...

"Bruno van Dooren" <br**********************@hotmail.comwrote in message
news:95**********************************@microsof t.com...

>I have an application which use has a DLL with 100+ (auto-generated)
Managed
C++ wrapper around some native API.

Compare to a purely version my application has some performance issue and
I
just realized it is probably due to the security check which happen just
before each of the (numerous) call into this native API.


I don''t know how much impact the security configuration has, but
transitioning between managed and unmanaged context takes time too, as
well
as marshalling parameters back and forth.
If you have to do this lots of times per second, this will have a
significant impact.
If that is your problem, there is very little you can do about that while
keeping your design as it is now.

--

Kind regards,
Bruno.
br**********************@hotmail.com
Remove only "_nos_pam"



SUCS is indeed a significant performance improvement for unmanmaged calls.
Not sure if it applies to your scenario - but give it a try.

Just be aware of the implications - this means that a partially trusted callers
can use your wrapper to call Win32 without having unmanaged code access.

dominick

I have an application which use has a DLL with 100+ (auto-generated)
Managed C++ wrapper around some native API.

Compare to a purely version my application has some performance issue
and I just realized it is probably due to the security check which
happen just before each of the (numerous) call into this native API.

Now I know that, perhaps, I could tag my MC++ wrapper with
<SuppressUnmanagedCodeSecurityAttribute>

But I wonder if there is not an other call I could place in the Main()
function (such as Permission.Demand() or stuff like that) which will
achieve the same result?

After all my code this is for a desktop application with as much right
as the user.



这篇关于互操作&amp;性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆