<div dir="ltr">Innovative thinking, Jesper! But in this case, in this testbed, the fsms aren't getting any messages other than those which they are delivering to themselves. Which adds to the intrigue. <div><br><div>I took your suggestion and tried using gen_fsm:start_timer/2. Interestingly it slightly increased the jitter variance and the negative jitter issue is still present. It's possible that my, ah, rapidly-and-pragmatically-built testbed suffers from some flaw, but I'm not seeing it.</div></div><div><br></div><div>Here's my code:</div><div><br></div><div><a href="https://gist.github.com/anonymous/47cde5e60a619319053f">https://gist.github.com/anonymous/47cde5e60a619319053f</a><br></div><div><br></div><div>Here's sample output on this small but moderately modern non-cloud osx machine:</div><div><br></div><div><div>> test_fsm5:go(1000,40,40,10).</div><div>waiting for 1000 FSMs, tickrate 40</div><div>avg: 1324.1012703862662</div><div>max: 50219</div><div>min: -184</div><div>median: 1018</div><div>95th: 2615</div><div>99th: 9698</div></div><div><br></div><div>note that the max is 50ms of jitter; the min is negative 184 us jitter, and the median jitter is about 1ms, which correlates well with my beliefs about scheduler wakeup timers...</div><div><br></div><div>F.</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 26, 2015 at 12:09 PM, Jesper Louis Andersen <span dir="ltr"><<a href="mailto:jesper.louis.andersen@gmail.com" target="_blank">jesper.louis.andersen@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 26, 2015 at 8:52 PM, Felix Gallo <span dir="ltr"><<a href="mailto:felixgallo@gmail.com" target="_blank">felixgallo@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span style="color:rgb(0,0,0);font-family:Courier,monospace;font-size:medium;font-weight:bold">{next_state,NextStateName,NewStateData,Timeout}</span></blockquote></div><br>This explains why you sometimes get less than 30ms sleep times. If an event reaches the process before Timeout, then the timeout is not triggered. Also, it may explain the jitter you are seeing, because an early event will reset the timeout. Try using gen_fsm:start_timer/2 or erlang:send_after...</div><div class="gmail_extra"><br></div><div class="gmail_extra">If the problem persists, check lcnt. If you are locked on the timer wheel, then consider release 18 :)<span class="HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div>J.</div>
</font></span></div></div>
</blockquote></div><br></div>