Now that I can create and remove links between processes, I thought of a little experiment:
What happens if I create a loop ?
Here’s the content of both scripts:
inlet('bang', 'Send next number on [bang].') pass = outlet('pass', 'Increasing numbers [float]') function inlet.bang(i) i = i + 1 print(i) pass(i) end -- initiates the loop on script save pass(0)
inlet('bang', 'Send next number on [bang].') pass = outlet('pass', 'Increasing numbers [float]') function inlet.bang(i) i = i + 1 pass(i) end
I stated the script and I let it run for 30s. The counter reached 241’558 in these 30 seconds which means 8’050 messages per second.
The monitor (open during the test) shows 2.4Mb/s of data being transferred.
The same loop in a single process gives this result 1’298’724 (43’290 messages per second). Note that I had to change the “counter” so that it uses “app:post” to send in order to avoid a stack overflow error (in-process messaging is the same as a function call):
Updated “counter” inlet function:
function inlet.bang(i) i = i + 1 print(i) app:post(function() -- post to avoid stack overflow count(i) end) end count(0)
A local loop takes 23μ s with the post overhead. It takes 124μ s when going through the network. This is roughly 0.1 ms latency overhead. This is not too bad.
Another thing to take into account is that sending is a blind process unless feedback is setup. This means that the receiver should work faster or the incoming mailbox will grow. We could overcome this issue by providing other types of links if needed.
Funding from the Swiss Federal Office of Culture to write the graphical frontend to rubyk !
Moving from a global mutex to a global select/poll loop.
comments