From: Chuck Remes on
I've been banging on a problem for a few days now and don't feel any closer to solving it. I'm hoping some of the big brains on the ruby ML can shed some light. Following are a few paragraphs with a brief system overview before I state the problem. I apologize in advance for this question being only tangentially related to Ruby the language. :)

I have written a distributed message passing system (in Ruby!) for doing some mathematical simulation work. Each component of the system does a very specific job. Each component may run on any of 3 distinct machines on a LAN. Components communicate with each other using the 0mq "socket" library to pass messages on well-defined ports that all components know about (hard-coded information instead of a dynamic lookup via a "service directory" mechanism).

The entire system is akin to a distributed state machine. I poke a command into it from the outside and it sets off a cascade of events which in turn generate more events until eventually I have my answer. Some the events have timeouts or other time-based characteristics associated with them. Also, some of the returned data has time-based characteristics (e.g. a timestamp) which impacts the transitioning of the state machine. It's all working quite nicely in real-time.

My problem is mocking out the time source so that I can run simulations in faster than real-time. For example, I may send a request for a data record and give it a 5 second timeout. This works fine when the clock source is the actual operating system, but if I want to run faster than real-time I need to mock the clock out. That is, I want to take a simulation that might run in 4 hours real-time (with lots of waiting or other timer related delays) to run in 20 minutes because 1 second of simulation time is only a fraction of a second in the real world.

This is simple to do for a single component on a single system because I can intercept all calls to Time and replace it with my own source. However, I don't know how to get all of the distributed components (across multiple machines or multiple processes on one machine) to use a mocked clock.

I tried googling around for answers, but all of the papers appear to be concerned with adjusting clock skew across a network where each device already has a local time source. I don't know if those solutions apply here.

Anyone have any bright ideas? Need more information?