-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(hydroflow)!:Change current_tick_start to wall clock time #1196
Conversation
Deploying hydroflow with Cloudflare Pages
|
The WASM SystemTime implementation through the pub fn duration_since(&self, earlier: SystemTime) -> Result<Duration, ()> {
let dur_ms = self.0 - earlier.0;
if dur_ms < 0.0 {
return Err(());
}
Ok(Duration::from_millis(dur_ms as u64))
}
|
Let's use #[cfg(not(target_family = "wasm"))]
pub use std::time::SystemTime;
#[cfg(target_family = "wasm")]
pub use web_time::SystemTime; |
This isn't a choice-of-library issue. My main point is that evaluating that some wall-clock time has elapsed after |
Oh! it seems the code in https://github.com/sebcrozet/instant/blob/master/src/wasm.rs#L201-L203 self.duration_since(SystemTime::now()) Is backwards and would always be negative if time goes forward. Should be Self::now().duration_since(*self) Should use |
Oh. I didn't know it had the check completely backward. I suspected it's a millisecond-grained timestamp that makes equal timestamp fails (so >= or <= in a check somewhere instead of < or >). I agree with replacing it. The test will start passing most of the time with a correct implementation. I can then look at pluggable clocks independently. |
Yeah I knew to prefer web-time but I didn't realize how busted instant was until just now looking thru the issues 😭 |
a0d158c
to
0e83cae
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
use tokio::sync::mpsc::UnboundedSender; | ||
use tokio::task::JoinHandle; | ||
use web_time::SystemTime; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh actually may want to target flag this, I think it's always different than std
, even on regular builds
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the library target flags this internally.
I guess maybe your original bug cause may also be true? |
Yup. It passes on my laptop. It may succeed if the test is re-run. Disabling auto-merge. |
963c298
to
95a4331
Compare
Addresses #1187. Wall-clock time isn't monotonic, but that's expected to be understood.
Switched to using `web-time` crate instead of `instant`.
Removing a unit-test: Discussed with Mingwei and it is not super important.
95a4331
to
1a635a7
Compare
Addresses #1187.
Wall-clock time isn't monotonic, but that's expected to be understood.