Click to See Complete Forum and Search --> : Managed<->unmanaged performance issues


Andy Skalkin
October 30th, 2002, 04:08 PM
We have a regular unmanaged C++ class library compiled into a .lib file. It has a class depending on many other templated and regular classes with inline methods. If a non-inlined computationally intensive method of this class is called from managed C++ code, the method executes twice slower than it does when called from unmanaged C++ code. We proved that the time spent for calling this method is negligible compared to the time spent inside the method.

Although the method is not inlined, it calls many other methods marked as 'inline'. As I mentioned above, the library is included into a managed C++ project as a .lib file and "knows" nothing about MSIL. Still, it works surprisingly slow. The DevPartner profiler reports about 100 managed<->unmanaged calls per call of the method. We think that, when compiling the .lib, the compiler failed to inline many of the methods. Thus, those methods are instantiated from the *.h files when compiling the managed progect, and the methods belonging to the library actually call those non-inline, terribly slow managed functions. Old VC++6 gives a warning if a function cannot be inlined (Warning Level=4), while VC++7 doesn't. So, I cannot even detect the problematic functions.

Do you know if there is any way to force the compiler to use natively generated unmanaged code even if it cannot be inlined when compiling a managed progect?

I know I can use an intermediate proxy class that hides all .h files from managed code, but I'd rather avoid it.

I understand that the inline functions from my .h files must also be available from the managed section, and so, I'm forced to use those entry points even from the native C++ .obj code. Is there a way to duplicate them (one instance for managed and the other one for unmanaged)?

Sincerely,

Andy Skalkin