Erlang ports and thread safety
"With ports, however, the "controlling process" acts as a serialization (as in arranged in a series) layer, meaning requests are handled one after the other and not all at once. Moreover, I believe (but do not know for certain) that the communication protocol ports use also requires this serial execution."
If I launch a large number of Erlang port processes, each connected to the same C driver, does anyone know whether the C code will be executed in series or parallel by the parallel Erlang processes ? (I suspect in series)
Thx
Erlang only describes program communication through the ports, and not code execution. While you have one point of serialization and all the communication goes through one actor, it doesn't mean that you cannot distribute work in general. You can parallel your C program as you wish even with the single port.
The port is implemented as a pipe, that is why it requires serial communication. But you are free to open a lot communication pipes all of them working completely independent from each other.
It means your different ports will be independent and all the communication through independent ports will be parallel
Hovewer, beam has limited power of the thread pool in which code runs. Every communication event with a port will use thread for the time of data transmission. If you have a lot of ports and send a lot of data, this time may become significant, so ports will start influencing each other. In that case you may need to increase the amount of async threads, wich are used for IO and port communication