Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / July 2006

Tip: Looking for answers? Try searching our database.

interop & performance

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lloyd Dupont - 25 Jul 2006 10:45 GMT
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.
Bruno van Dooren - 25 Jul 2006 10:54 GMT
> 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.
Dominick Baier - 25 Jul 2006 11:47 GMT
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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.