GithubHelp home page GithubHelp logo

Time and clocks about turmoil HOT 5 CLOSED

tokio-rs avatar tokio-rs commented on September 26, 2024
Time and clocks

from turmoil.

Comments (5)

marcbowes avatar marcbowes commented on September 26, 2024

I'm struggling to understand how things work right now.

  1. When the sim runs, it ticks 1ms forward

    turmoil/src/sim.rs

    Lines 152 to 161 in 2dd03ad

    let tick = self.config.tick;
    loop {
    let mut is_finished = true;
    for (&addr, rt) in self.rts.iter() {
    // Set the current host
    self.world.borrow_mut().current = Some(addr);
    let now = World::enter(&self.world, || rt.tick(tick));
  2. When a message is received, it is only delivered based on whether wallclock now has advanced.

.. presumably this means that for fast tests (i.e. ticks are < 1ms) the code lands up waiting for realtime to advance?

on the recv path (https://github.com/tokio-rs/turmoil/blob/main/src/io.rs#L20) it looks like we will wait for a notification, which (I think) is triggered when the host ticks past the wallclock-now of the message delivery time (which is based on fake time on the send host - which also seems busted to me)

from turmoil.

marcbowes avatar marcbowes commented on September 26, 2024

which is based on fake time on the send host - which also seems busted to me

I take that back. Host::send is actually called on the receiving host. So the method name is just confusing.

from turmoil.

marcbowes avatar marcbowes commented on September 26, 2024

There is some magic (through globals, my favorite) going on that makes this more or less work out the way it should. I'm not sure it's 100% yet, so I plan on digging more before closing this out. Hopefully I can add some comments to help explain how it all works.

from turmoil.

carllerche avatar carllerche commented on September 26, 2024

You can schedule some time with me and I can walk you through it. Short version is that it uses Tokioโ€™s Instant::now which can be made virtual.

from turmoil.

marcbowes avatar marcbowes commented on September 26, 2024

See #23

from turmoil.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.