Home All Groups Group Topic Archive Search About

interop & performance

Author
25 Jul 2006 9:45 AM
Lloyd Dupont
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.

Author
25 Jul 2006 9:54 AM
Bruno van Dooren
> 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.
    bruno_nos_pam_van_doo***@hotmail.com
    Remove only "_nos_pam"
Author
25 Jul 2006 10:09 AM
Lloyd Dupont
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...

Show quote
"Bruno van Dooren" <bruno_nos_pam_van_doo***@hotmail.com> wrote in message
news:957E216E-3909-41DA-916E-7F3A22EC1ACB@microsoft.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.
>    bruno_nos_pam_van_doo***@hotmail.com
>    Remove only "_nos_pam"
>
Author
25 Jul 2006 10:47 AM
Dominick Baier
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

Show quote
> 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.
>
Author
25 Jul 2006 10:55 AM
Lloyd Dupont
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?

Show quote
"Dominick Baier" <dbaier@pleasepleasenospam_leastprivilege.com> wrote in
message news:4580be6385ad8c87dff9d01cfd0@news.microsoft.com...
> 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.
>>
>
>
Author
25 Jul 2006 11:03 AM
Dominick Baier
Ah ok - adding SUCS will not improve performance - replacing Assert with
SUCS is usually a perf improvement.



Show quote
> 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?
>
> "Dominick Baier" <dbaier@pleasepleasenospam_leastprivilege.com> wrote
> in message news:4580be6385ad8c87dff9d01cfd0@news.microsoft.com...
>
>> 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.
>>>
Author
25 Jul 2006 12:39 PM
Lloyd Dupont
"Dominick Baier" <dbaier@pleasepleasenospam_leastprivilege.com> wrote in
message news:4580be6385b38c87e01e21806f0@news.microsoft.com...
> 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/scalenetchapt05.asp

explains it all!
Author
25 Jul 2006 12:57 PM
Lloyd Dupont
This one!

CodeAccessPermission.Assert()

Anyway, it's not as good as
SupressUnmanagedCodeSecurityAttribute

Show quote
"Dominick Baier" <dbaier@pleasepleasenospam_leastprivilege.com> wrote in
message news:4580be6385b38c87e01e21806f0@news.microsoft.com...
> 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....
>>
>> But my question was: is there a replacement of [SUCS] ? like using a
>> demand or similar stuff?
>>
>> "Dominick Baier" <dbaier@pleasepleasenospam_leastprivilege.com> wrote
>> in message news:4580be6385ad8c87dff9d01cfd0@news.microsoft.com...
>>
>>> 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.
>>>>
>
>
Author
25 Jul 2006 1:30 PM
Dominick Baier
:) that's what i said...

dominick

Show quote
> This one!
>
> CodeAccessPermission.Assert()
>
> Anyway, it's not as good as
> SupressUnmanagedCodeSecurityAttribute
> "Dominick Baier" <dbaier@pleasepleasenospam_leastprivilege.com> wrote
> in message news:4580be6385b38c87e01e21806f0@news.microsoft.com...
>
>> 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....
>>>
>>> But my question was: is there a replacement of [SUCS] ? like using a
>>> demand or similar stuff?
>>>
>>> "Dominick Baier" <dbaier@pleasepleasenospam_leastprivilege.com>
>>> wrote in message
>>> news:4580be6385ad8c87dff9d01cfd0@news.microsoft.com...
>>>
>>>> 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.
>>>>>
Author
25 Jul 2006 2:45 PM
Lloyd Dupont
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! ;-)


Show quote
"Dominick Baier" <dbaier@pleasepleasenospam_leastprivilege.com> wrote in
message news:4580be6385cb8c87e1669df7de0@news.microsoft.com...
> :) that's what i said...
>
> dominick
>
>> This one!
>>
>> CodeAccessPermission.Assert()
>>
>> Anyway, it's not as good as
>> SupressUnmanagedCodeSecurityAttribute
>> "Dominick Baier" <dbaier@pleasepleasenospam_leastprivilege.com> wrote
>> in message news:4580be6385b38c87e01e21806f0@news.microsoft.com...
>>
>>> 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....
>>>>
>>>> But my question was: is there a replacement of [SUCS] ? like using a
>>>> demand or similar stuff?
>>>>
>>>> "Dominick Baier" <dbaier@pleasepleasenospam_leastprivilege.com>
>>>> wrote in message
>>>> news:4580be6385ad8c87dff9d01cfd0@news.microsoft.com...
>>>>
>>>>> 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.
>>>>>>
>
>
Author
25 Jul 2006 2:57 PM
Dominick Baier
Show quote
:))

> 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! ;-)
> "Dominick Baier" <dbaier@pleasepleasenospam_leastprivilege.com> wrote
> in message news:4580be6385cb8c87e1669df7de0@news.microsoft.com...
>
>> :) that's what i said...
>>
>> dominick
>>
>>> This one!
>>>
>>> CodeAccessPermission.Assert()
>>>
>>> Anyway, it's not as good as
>>> SupressUnmanagedCodeSecurityAttribute
>>> "Dominick Baier" <dbaier@pleasepleasenospam_leastprivilege.com>
>>> wrote
>>> in message news:4580be6385b38c87e01e21806f0@news.microsoft.com...
>>>> 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....
>>>>>
>>>>> But my question was: is there a replacement of [SUCS] ? like using
>>>>> a demand or similar stuff?
>>>>>
>>>>> "Dominick Baier" <dbaier@pleasepleasenospam_leastprivilege.com>
>>>>> wrote in message
>>>>> news:4580be6385ad8c87dff9d01cfd0@news.microsoft.com...
>>>>>
>>>>>> 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.
>>>>>>>
Author
25 Jul 2006 3:03 PM
Robert Simpson
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

Show quote
"Lloyd Dupont" <net.galador@ld> wrote in message
news:Os6Stj$rGHA.4180@TK2MSFTNGP03.phx.gbl...
> 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! ;-)
>
>
> "Dominick Baier" <dbaier@pleasepleasenospam_leastprivilege.com> wrote in
> message news:4580be6385cb8c87e1669df7de0@news.microsoft.com...
>> :) that's what i said...
>>
>> dominick
>>
>>> This one!
>>>
>>> CodeAccessPermission.Assert()
>>>
>>> Anyway, it's not as good as
>>> SupressUnmanagedCodeSecurityAttribute
>>> "Dominick Baier" <dbaier@pleasepleasenospam_leastprivilege.com> wrote
>>> in message news:4580be6385b38c87e01e21806f0@news.microsoft.com...
>>>
>>>> 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....
>>>>>
>>>>> But my question was: is there a replacement of [SUCS] ? like using a
>>>>> demand or similar stuff?
>>>>>
>>>>> "Dominick Baier" <dbaier@pleasepleasenospam_leastprivilege.com>
>>>>> wrote in message
>>>>> news:4580be6385ad8c87dff9d01cfd0@news.microsoft.com...
>>>>>
>>>>>> 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.
>>>>>>>
>>
>>
>
>
Author
26 Jul 2006 2:57 AM
Lloyd Dupont
Anyway Interop has a cost and it seems you can't get away with it...
Pff...


--
Regards,
Lloyd Dupont

NovaMind development team
NovaMind Software
Mind Mapping Software
<www.nova-mind.com>
Show quote
"Robert Simpson" <rmsimpson@noemail.noemail> wrote in message
news:uJRUHu$rGHA.696@TK2MSFTNGP02.phx.gbl...
> 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
>
> "Lloyd Dupont" <net.galador@ld> wrote in message
> news:Os6Stj$rGHA.4180@TK2MSFTNGP03.phx.gbl...
>> 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! ;-)
>>
>>
>> "Dominick Baier" <dbaier@pleasepleasenospam_leastprivilege.com> wrote in
>> message news:4580be6385cb8c87e1669df7de0@news.microsoft.com...
>>> :) that's what i said...
>>>
>>> dominick
>>>
>>>> This one!
>>>>
>>>> CodeAccessPermission.Assert()
>>>>
>>>> Anyway, it's not as good as
>>>> SupressUnmanagedCodeSecurityAttribute
>>>> "Dominick Baier" <dbaier@pleasepleasenospam_leastprivilege.com> wrote
>>>> in message news:4580be6385b38c87e01e21806f0@news.microsoft.com...
>>>>
>>>>> 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....
>>>>>>
>>>>>> But my question was: is there a replacement of [SUCS] ? like using a
>>>>>> demand or similar stuff?
>>>>>>
>>>>>> "Dominick Baier" <dbaier@pleasepleasenospam_leastprivilege.com>
>>>>>> wrote in message
>>>>>> news:4580be6385ad8c87dff9d01cfd0@news.microsoft.com...
>>>>>>
>>>>>>> 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.
>>>>>>>>
>>>
>>>
>>
>>
>
>

AddThis Social Bookmark Button