If I use erlang as say a spawner process, it does major functions things that are not too speed critical like communicating with a server and handling server-client communication messages.
Then I choose to spawn a process in erlang and run c/c++ code from it, will this make my code faster?
Will erlang more efficiently handle multithreading than an equivalent in c/c++?
If I were to spawn many c nodes from erlang, would they stack on a single core or would erlang handle the multithreading. This is the main point I am wondering about.
You talk about two different concepts in your question: Erlang processes running C/C++ code and C nodes.
C or C++ code run from inside Erlang is not scheduled at all. In fact, it will block the Erlang scheduler for the current CPU core, so having long run times in C-land will most likely mess up your (Erlang) scheduling.
For example, on a quad core processor Erlang will by default create 4 scheduler threads, each which will occupy one core. Any process running C code will block the scheduler it is assigned to until that code has finished executing.
When running C nodes, you're totally on your own. An Erlang node does not know about the scheduling of a C node at all, it only cares about it's own scheduling. Of course, you could create your own scheduling such as dedicating one core to the C node and three to the Erlang node or something similar.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With