Inter Process Communication between C++ - C#
-
I am working on C++ project where performance is critical. there is no logging mechanism. I dont want to implement logging in the same project as it will hit performance. And hence I want to create A C# project while takes care of actually logging from C++ process I will push the Log strings to C# process to do Actually logging. I want to know which is the best IPC - Named pipes ? Memory Mapped files ? Socket Which should not hit the performance Could you please point me to some sample code/link which has the mechanism to Log from C++ to C# code please
-
I am working on C++ project where performance is critical. there is no logging mechanism. I dont want to implement logging in the same project as it will hit performance. And hence I want to create A C# project while takes care of actually logging from C++ process I will push the Log strings to C# process to do Actually logging. I want to know which is the best IPC - Named pipes ? Memory Mapped files ? Socket Which should not hit the performance Could you please point me to some sample code/link which has the mechanism to Log from C++ to C# code please
Logging will not be a performance issue if you do that in an own thread. That thread may be part of the application itself or another application. Using another application with IPC makes it more complicated and requires that the other application is running. So I would not use another application if there is no need for other communications besides logging. There might be even no need of using a thread when logging does not occur at high rates with large data. The log data has to be prepared anyway within the time critical thread. Using then a log file which stays open might be sufficient. If you are concerned about the file write times, use overlapped IO so that the writing is done by the system in the background (which is basically the same as suggested above: moving the operation to another thread). I know that the above is not what you asked for but I think it is helpful and you might find out that using IPC is not necessary. When maximum performance is a must-have, you have to use one of the above mentioned methods (own thread or overlapped IO) anyway even with IPC.
-
I am working on C++ project where performance is critical. there is no logging mechanism. I dont want to implement logging in the same project as it will hit performance. And hence I want to create A C# project while takes care of actually logging from C++ process I will push the Log strings to C# process to do Actually logging. I want to know which is the best IPC - Named pipes ? Memory Mapped files ? Socket Which should not hit the performance Could you please point me to some sample code/link which has the mechanism to Log from C++ to C# code please
ptr_Electron wrote:
I want to know which is the best IPC - Named pipes ? Memory Mapped files ? Socket Which should not hit the performance
On the Microsoft Windows platform the fastest possible logging is through Event Tracing for Windows (ETW)[^]. Logging with ETW so fast... graphics drivers can render at 150 FPS and perform logging at the same time without losing any framerate. What it basically does is write integers into a circular buffer all in RAM. There is nothing faster.
ptr_Electron wrote:
Could you please point me to some sample code/link which has the mechanism to Log from C++ to C# code please
ETW logging msdn examples - Bing[^] Best Wishes, -David Delaune
-
I am working on C++ project where performance is critical. there is no logging mechanism. I dont want to implement logging in the same project as it will hit performance. And hence I want to create A C# project while takes care of actually logging from C++ process I will push the Log strings to C# process to do Actually logging. I want to know which is the best IPC - Named pipes ? Memory Mapped files ? Socket Which should not hit the performance Could you please point me to some sample code/link which has the mechanism to Log from C++ to C# code please
ptr_Electron wrote:
I dont want to implement logging in the same project as it will hit performance.
I was involved in a C++ project years ago. Unix based. Performance was a contractual requirement. The architect was sure that logging was a performance problem. So we removed logging. Absolute zero impact on performance. And that was back when spewing stuff to a console (stdio) could impact performance. If you have a performance problem then you need to address the requirements and design first before looking for problems in the implementation and technologies.
ptr_Electron wrote:
which has the mechanism to Log from C++ to C# code please
Every logging library that I have seen for at least the past 10 years if not longer uses pluggable designs. Which means if the plugs that are already available do not meet your needs then you can create your own. However at least when I looked some already supported remote logging plugs.