<div>Hi,</div>
<div> </div>
<div>I have a single-process solution for a server that, I feel, could be implementet</div>
<div>in a more concurrent fashion. Its internal state is a vector that consists of n numbers.</div>
<div>It receives casts without parameters. Every cast is basically a matrix multiplication.</div>
<div>The matrices are known in advance. So, if the internal state is v, and the server</div>
<div>process receives a cast, and it has the matrix M associated with that cast, then the</div>
<div>new state will be M*v (M is a matrix, * is matrix multiplication, and v is a column vector</div>
<div>representing the previous internal state of the server process).</div>
<div> </div>
<div>My problem is that the size of v (and the matrices) can be very large, and my</div>
<div>server runs in a single process. It would be great to split it apart and use several</div>
<div>smaller processes to calculate the new state. I would like to use separate</div>
<div>processes for each number in v. But because of the nature of matrix multiplication,</div>
<div>that's not so easy to achieve, because in order to be able to calculate a single</div>
<div>number in the new state, I need to know all the numbers in the previous state.</div>
<div>The prev state could be shared between processes in advance, but that would</div>
<div>require large messages containing all the old values to all the processes around.</div>
<div>I believe that is a wrong idea and there must be a better one.</div>
<div> </div>
<div>My question is how would you crach this problem if efficiency matters?</div>
<div> </div>
<div> </div>
<div>I have one possible solution in mind, and would like to know your opinion: there</div>
<div>could be a main server process and size(v) calculator processes, one for every</div>
<div>number in v. The server process handles the casts, and it has the whole v vector</div>
<div>in it. The calculator processes have only one number from v, and they have the</div>
<div>proper lines from M. When a cast arrives, the server process builds a fun that has</div>
<div>the whole v encoded in it as a clojure, and this anon function gets sent to the</div>
<div>calculator processes. Then the calculator processes apply the fun to the</div>
<div>appropriate line of M, and they have the new number that they have to send</div>
<div>back to the server. I'm not sure if sending a huge function with a large body is</div>
<div>cheaper than sending a large list of numbers, but I hope there's some optimisation</div>
<div>going on in BEAM with funs... Am I right with all this?</div>
<div> </div>
<div>THX</div>
<div> </div>
<div> </div>