tokio-rs / simulation

Framework for simulating distributed applications
96 stars 9 forks source link

Expose API for querying precise simulation state #5

Open gardnervickers opened 5 years ago

gardnervickers commented 5 years ago

It's desirable to have the ability to check the exact state a simulation is in. This could be exposed as an epoch which is advanced on each task poll. This would be useful for debugging and verifying fixes.

Users could conditionally add extra debug information based on the epoch. If there is a bug in the system, but logs are too verbose, users could choose to enable trace logging or whatever for a certain epoch range.

Bug fixes could be verified in an isolated way with this approach. Code could be conditionally ran based on the simulation epoch. This could be useful for situations where a particular program state is difficult to arrive at, and adding the fix changes simulation execution in such a way that the original bug is no longer exposed.

Currently, Simulation only allows applications to query the current time via Now::now() as a rough approximation to where a simulation is at in it's execution. While this may work for some cases, it's granular (1ms) and not actually tied to execution of the simulation.