473,397 Members | 1,985 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Performance calling from .NET to legacy COM DLL

We've noticed that invocations of legacy C++ COM DLLs from .NET (Managed C++
or C#) desktop applications is quite a bit slower than the same calls from
good old native C++.

Does anybody have specific information about why this would be the case?
How about performance numbers, benchmarks, etc? Any suggestions to speed up
the connection between new .NET code and legacy C++?

Thanks for your help -

Steve
Jul 19 '05 #1
1 1797
steve clark wrote:
We've noticed that invocations of legacy C++ COM DLLs from .NET
(Managed C++ or C#) desktop applications is quite a bit slower than
the same calls from good old native C++.

Does anybody have specific information about why this would be the
case? How about performance numbers, benchmarks, etc? Any
suggestions to speed up the connection between new .NET code and
legacy C++?


Microsoft says that the thunking in platform invoke (and hence COM interop,
which is a specialized form of p/invoke) is 20-30 CPU cycles, not a huge
amount for a single call, but could be large if you are making many calls
from .NET to COM. Here's somethings to consider:

1) what is the threading model of the COM object? By default .NET threads
will be MTA, but the VS.NET wizards always makes the entrypoint thread STA.
You can gain some performance by making sure that the .NET thread is the
same apartment type as the .NET object (and hence they will run in the same
apartment and you don't have apartment marshalling).

2) how 'chatty' is the COM object? If it was designed to be an inproc
server, the designer did not have to think about marshalling issues (because
it is in-apartment) so the interaction with the client could be 'chatty' -
lots of calls. If this is the case then maybe you are amplifying the effect
of the thunks. To get round this you could write a shim native C++ DLL that
batches the calls to the object. From memory, Chris Sells wrote such a shim
to make IEnum calls from VB code to a COM object more efficient. (classic VB
calls makes many IEnumXXX::Next calls, each getting a single item -
inefficient for IPC calls).

Richard
--
my email ev******@zicf.bet is encrypted with ROT13 (www.rot13.org)
Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: brian | last post by:
Hi, I've got a situation where I have a bunch of legacy code accessing a database through an archive. (Not a shared object). I've written an interface to this legacy code with C & Java using...
6
by: Andreas Lauffer | last post by:
I changed from Access97 to AccessXP and I have immense performance problems. Details: - Access XP MDB with Jet 4.0 ( no ADP-Project ) - Linked Tables to SQL-Server 2000 over ODBC I used...
1
by: Lakshmi | last post by:
Hi All, I am having performance issues with the .NET client calling the Java Webservice running on axis. Have detailed the problem below. Please help. I wrote a webservice in Java. Lets name...
1
by: steve clark | last post by:
We've noticed that invocations of legacy C++ COM DLLs from .NET (Managed C++ or C#) desktop applications is quite a bit slower than the same calls from good old native C++. Does anybody have...
48
by: Alex Chudnovsky | last post by:
I have come across with what appears to be a significant performance bug in ..NET 2.0 ArrayList.Sort method when compared with Array.Sort on the same data. Same data on the same CPU gets sorted a...
1
by: MC-Advantica | last post by:
I am exposing a legacy unmanaged C++ class library and deciding whether to use COM or .NET approach. I have a COM DLL containing the legacy (unmanaged) code, and a .NET class library containing...
11
by: briankirkpatrick | last post by:
Forgive me if my post seems a little amateurish... I'm requesting assistance from some of you smart folks out there to get the managed calls write that meet the specification in the esa.h for...
7
by: =?Utf-8?B?UVNJRGV2ZWxvcGVy?= | last post by:
I have a C# logging assembly with a static constructor and methods that is called from another C# Assembly that is used as a COM interface for a VB6 Application. Ideally I need to build a file...
6
by: sasha | last post by:
I have a c++ code that callls csharp. Now I want to be able to pass a function pointer from C++ to Csharp code and have c# callback to it. Is it possible and how? Here is what I have so far :...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.