> 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.

Signature
Kind regards,
Bruno.
bruno_nos_pam_van_dooren@hotmail.com
Remove only "_nos_pam"
Lloyd Dupont - 25 Jul 2006 11:09 GMT
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...
>> I have an application which use has a DLL with 100+ (auto-generated)
>> Managed
[quoted text clipped - 13 lines]
> If that is your problem, there is very little you can do about that while
> keeping your design as it is now.
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.
[quoted text clipped - 12 lines]
> After all my code this is for a desktop application with as much right
> as the user.
Lloyd Dupont - 25 Jul 2006 11:55 GMT
Well I don't have any plugin API so there is no problem....
But my question was: is there a replacement of [SUCS] ?
like using a demand or similar stuff?
> SUCS is indeed a significant performance improvement for unmanmaged calls.
> Not sure if it applies to your scenario - but give it a try.
[quoted text clipped - 21 lines]
>> After all my code this is for a desktop application with as much right
>> as the user.
Dominick Baier - 25 Jul 2006 12:03 GMT
Ah ok - adding SUCS will not improve performance - replacing Assert with
SUCS is usually a perf improvement.
> Well I don't have any plugin API so there is no problem....
>
[quoted text clipped - 27 lines]
>>> After all my code this is for a desktop application with as much
>>> right as the user.
Lloyd Dupont - 25 Jul 2006 13:39 GMT
> Ah ok - adding SUCS will not improve performance - replacing Assert with
> SUCS is usually a perf improvement.
hu....
your statment is kind of confusing.....
Anyway:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag/html/scal
enetchapt05.asp
explains it all!
Lloyd Dupont - 25 Jul 2006 13:57 GMT
This one!
CodeAccessPermission.Assert()
Anyway, it's not as good as
SupressUnmanagedCodeSecurityAttribute
> Ah ok - adding SUCS will not improve performance - replacing Assert with
> SUCS is usually a perf improvement.
[quoted text clipped - 30 lines]
>>>> After all my code this is for a desktop application with as much
>>>> right as the user.
Dominick Baier - 25 Jul 2006 14:30 GMT
:) that's what i said...
dominick
> This one!
>
[quoted text clipped - 37 lines]
>>>>> After all my code this is for a desktop application with as much
>>>>> right as the user.
Lloyd Dupont - 25 Jul 2006 15:45 GMT
Ho... this Assert?
I didn't know about it!
It's why I was asking!
I though you were talking about System.Diagnostic.Assert
I though it was non sensical!
I should have know better!
Someone who thinks SUCS is an understandable acronym is likely to have a
second meaning! ;-)
> :) that's what i said...
>
[quoted text clipped - 41 lines]
>>>>>> After all my code this is for a desktop application with as much
>>>>>> right as the user.
Dominick Baier - 25 Jul 2006 15:57 GMT
:))
> Ho... this Assert?
>
[quoted text clipped - 53 lines]
>>>>>>> After all my code this is for a desktop application with as much
>>>>>>> right as the user.
Robert Simpson - 25 Jul 2006 16:03 GMT
Turing on that attribute will drastically improve performance ...
I'm using it in my SQLite ADO.NET 2.0 provider, which calls the native
database engine. I was floored at how close the performance was to raw
unmanaged C++ ...
I did a few performance benchmarks comparing raw native C++ to ADO.NET C#:
http://sqlite.phxsoftware.com/forums/thread/37.aspx
Robert
> Ho... this Assert?
>
[quoted text clipped - 53 lines]
>>>>>>> After all my code this is for a desktop application with as much
>>>>>>> right as the user.
Lloyd Dupont - 26 Jul 2006 03:57 GMT
Anyway Interop has a cost and it seems you can't get away with it...
Pff...

Signature
Regards,
Lloyd Dupont
NovaMind development team
NovaMind Software
Mind Mapping Software
<www.nova-mind.com>
> Turing on that attribute will drastically improve performance ...
>
[quoted text clipped - 65 lines]
>>>>>>>> After all my code this is for a desktop application with as much
>>>>>>>> right as the user.