I am trying to find out if there is an inherent speed difference between inter-thread and inter-process communication.
I know that when using threads the threads share the same memory, can use the same global variables, and the such while processes have to use other tricks, which basically means queues.
But take the following case:
An application is comprised of several completely separate .exe
files. When all are run they form a producer/consumer (or publisher/subscriber) architecture, with some processes producing some values and other processes reading and using those values and maybe producing some other values.
This communication is done with conventional ways of IPC.
My question is: if I were to move the code around so that it's one process with multiple threads (assuming no conflicts with variable names and the such), but keep the communication methods the same, queues with all the locks and semaphores behind them, will the thread-based application be faster than the process-based one?
The startup costs of processes vs. threads are not important because the application is meant to run for a long time (hours) so a few milliseconds will not be important.
Google has yielded no conclusive answers to this.
To clarify some aspects of the question:
-
The factor I want to maximize is throughput.
Some external factor (an arduino sensor for example) produces an input for one of the nodes and the entire network takes some time while all the nodes consume and produce values. Then a new input can be processed. I would like to be able to process more inputs per minute/second.
-
The data being passed back and forth are mostly numbers or small arrays of numbers.
-
The entire network can have lets say between 5 and 25 nodes.
-
As for platform (if it is relevant) I would like answers for both Linux and Windows.
-
The specific use-case is too large to be described here so consider the use-case provided above.
Please ask for any other relevant information that I have not included here.
https://stackoverflow.com/questions/67238708/is-itc-faster-than-ipc-of-the-same-kind April 24, 2021 at 10:06AM
没有评论:
发表评论