Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
e47ead7
chore: claim moq-clock migration quest
kixelated Oct 16, 2026
5a7be23
Migrate timing onto moq-clock
kixelated Oct 16, 2026
4a239bb
Finish moq-clock timing migration
kixelated Oct 16, 2026
0241940
Merge remote-tracking branch 'origin/main' into pr-5681
kixelated Oct 16, 2026
e91b1e9
fix(clock): anchor each paused runtime on its own clock and read the …
kixelated Oct 16, 2026
b7711ee
fix: finish the moq-clock migration in feature-gated callers and benches
kixelated Oct 16, 2026
6393f2b
fix(cli): run native playback on moq-clock
kixelated Oct 16, 2026
97e57ad
fix(media): stamp captured audio and rate-control video on moq-clock
kixelated Oct 16, 2026
50d783b
Merge remote-tracking branch 'origin/main' into pr-5681
kixelated Oct 16, 2026
6820f68
style(cli): format the play feature list
kixelated Oct 16, 2026
73a8c49
fix(clock): start the runtime clock 2^32 s past zero
kixelated Oct 16, 2026
18d1933
Merge remote-tracking branch 'origin/main' into pr-5681
kixelated Oct 16, 2026
2606f45
Merge remote-tracking branch 'origin/main' into pr-5681
kixelated Oct 16, 2026
cf10cd8
fix(clock): anchor on real time and restore sim idle settling
kixelated Oct 16, 2026
3330cd4
Merge remote-tracking branch 'origin/main' into pr-5681
kixelated Oct 16, 2026
dfb102a
fix(net): freeze the cache clock in unit tests and loom
kixelated Oct 16, 2026
519b0bf
fix(srt,mux): keep late SRT instants and test the ambient wall
kixelated Oct 16, 2026
617766e
Merge remote-tracking branch 'origin/main' into quest/m1/time/net
kixelated Oct 17, 2026
ebe1615
docs(wasm): describe the logical moq-clock instant
kixelated Oct 17, 2026
7b253e2
Merge remote-tracking branch 'origin/main' into quest/m1/time/net
kixelated Oct 17, 2026
9cd9950
Merge remote-tracking branch 'origin/main' into quest/m1/time/net
kixelated Oct 17, 2026
e4cbf57
docs(mux): Clock::at no longer refuses the browser
kixelated Oct 17, 2026
bcef421
Merge remote-tracking branch 'origin/main' into quest/m1/time/net
kixelated Oct 17, 2026
39e96d7
style(cli): format the play clock port
kixelated Oct 17, 2026
2615b38
Merge remote-tracking branch 'origin/main' into quest/m1/time/net
kixelated Oct 17, 2026
ea3a935
test(net): run main's new lite publisher tests on moq-clock
kixelated Oct 17, 2026
b5bef1f
Merge remote-tracking branch 'origin/main' into quest/m1/time/net
kixelated Oct 17, 2026
c6049f4
fix(uring): anchor driver deadlines before the poll
kixelated Oct 17, 2026
d1bc1e7
Merge remote-tracking branch 'origin/main' into quest/m1/time/net
kixelated Oct 17, 2026
c654062
test(net): run main's new subscriber and publisher tests on moq-clock
kixelated Oct 17, 2026
1f59e14
Merge remote-tracking branch 'origin/main' into quest/m1/time/net
kixelated Oct 17, 2026
7fb1f20
Merge remote-tracking branch 'origin/main' into quest/m1/time/net
kixelated Oct 17, 2026
1edfc4c
test(net): drive the auth-swap update through the update hold
kixelated Oct 17, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 6 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ members = [
"rs/moq-native",
"rs/moq-net",
"rs/moq-net/fuzz",
"rs/moq-net/sim",
"rs/moq-net/sim/macros",
"rs/moq-nvenc",
"rs/moq-pattern",
"rs/moq-quic",
Expand Down
4 changes: 0 additions & 4 deletions quest/m1/spinning-loops.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ Decided 2026-10-09 while reworking #5088:
datagram backlog after `TrackServe` yields, and its drain arm would skip
datagrams after a yield unless it returns `Poll`.

## Required

- [moq-net on moq-clock](/quest/m1/time/net.md) - moq-net's tests reach the moq-clock sim, which hosts the poll counter

## Related

- [Session burst hang](https://github.com/moq-dev/moq/pull/5238) - the same bench shapes that hang
Expand Down
3 changes: 1 addition & 2 deletions quest/m1/time/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ reasons, so later sessions don't reopen them:
dev-dependency only, so production builds never compile it). It is one
backend of the ambient clock, starts at zero, keeps deadlock detection, and
seeds the later runtime trait. `#[moq_clock::test]` replaces
`#[moq_net_sim::test]`.
`#[moq_clock::test]`.
- **Tests for migrated contracts use the sim wherever possible.** A test with no real I/O
that cannot run on the sim yet uses paused tokio, whose clock `moq-clock`
reads. A real-I/O test never uses paused tokio, which auto-advances to the
Expand Down Expand Up @@ -95,7 +95,6 @@ cleanup and the global lint ratchet belong to

## Required

- [moq-net on moq-clock](/quest/m1/time/net.md) - moq-net, moq-mux, moq-stats, moq-room, and moq-ffi run on moq-clock and moq-net-sim is gone
- [Every crate on moq-clock](/quest/m1/time/crates.md) - every remaining crate reads time only through moq-clock, with controlled tests for the production/public API migrations
- [moq-uring on moq-clock](/quest/m1/time/uring.md) - one clock read per worker turn and moq-clock's deadline queue replace the private timer heap
- [The relay seam](/quest/m1/time/relay-seam.md) - one in-memory session and a generic `moq_relay::Connection`, so relay tests run on the sim
Expand Down
4 changes: 0 additions & 4 deletions quest/m1/time/crates.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ workspace-wide lint ratchet follow in m2.
Public API: breaking wherever a crate exposes an instant or a time source.
Wire: none.

## Required

- [moq-net on moq-clock](/quest/m1/time/net.md) - these crates consume moq-net's instant

## Related

- [Time test sweep](/quest/m2/time-test-sweep.md) - unrelated test-only/private clock cleanup and global lint are deferred; migrate production/public APIs and their required regression tests here
61 changes: 0 additions & 61 deletions quest/m1/time/net.md

This file was deleted.

4 changes: 0 additions & 4 deletions quest/m1/time/relay-seam.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,3 @@ types as the switch to `moq-quic` (#5664) left them. Simulated UDP belongs to
QUIC on the sim.

Public API: the remaining relay seam. Wire: none.

## Required

- [moq-net on moq-clock](/quest/m1/time/net.md) - the sim and instant the relay tests run on
4 changes: 0 additions & 4 deletions quest/m1/time/uring.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ Public API: breaking. `moq_uring::Timer` is re-exported, and `Timer::set`
takes `Option<moq_clock::Instant>` instead of std's; no conversion shim.
Wire: none.

## Required

- [moq-net on moq-clock](/quest/m1/time/net.md) - the driver's instant becomes moq-clock's

## Closes

- [#3122](https://github.com/moq-dev/moq/issues/3122) - close this issue when the quest finishes
Expand Down
4 changes: 0 additions & 4 deletions quest/m2/sim-seed.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,3 @@ replays bit-exact.
Decided 2026-10-10: out of [controlled time](/quest/m1/time/README.md); with
controlled time a test advances past the largest jitter, so seeding only adds
exact replay. Production keeps its OS randomness.

## Required

- [moq-net on moq-clock](/quest/m1/time/net.md) - the sim and its first jitter consumer
2 changes: 1 addition & 1 deletion rs/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Prefer poll. New logic is a `poll_*` with an `async` helper, not the other way a

# Testing

- Tests are inline `#[cfg(test)] mod tests`, except full Client/Server session tests over a crate's shared mock harness, which go in its `tests/integration/` module. Time-dependent async tests call `tokio::time::pause()` first (moq-net uses `#[moq_net_sim::test]` instead), unless they cross real networking that can't be mocked (sockets, smoke tests); those run on the wall clock and assert lower bounds.
- Tests are inline `#[cfg(test)] mod tests`, except full Client/Server session tests over a crate's shared mock harness, which go in its `tests/integration/` module. Time-dependent async tests call `tokio::time::pause()` first (moq-net uses `#[moq_clock::test]` instead), unless they cross real networking that can't be mocked (sockets, smoke tests); those run on the wall clock and assert lower bounds.
- Run tests through `just` (nextest), not `cargo test`: nextest kills a wedged test as TIMEOUT, cargo hangs forever. A test flagged SLOW is a bug to fix, not a threshold to raise.
- `just check` compiles default features only, like CI. `just rs features` (nightly) covers `--all-features` / `--no-default-features`. Keep a feature gate around the dependency, not the logic, so the logic's tests stay in the merge gate.
- Local checks compile only the host platform; PR CI runs `just rs windows` / `macos` on those hosts, and `just rs wasm` covers `moq-wasm`.
4 changes: 3 additions & 1 deletion rs/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,11 @@ android *args:
wasm *args:
cargo clippy --locked -p moq-wasm -p moq-mux -p moq-ffi -p moq-clock --target wasm32-unknown-unknown --lib "$@" -- -D warnings

# Run the browser clock backend on the Playwright Chromium installed by wasm.yml.
# Run the browser clock backend on the Playwright Chromium installed by wasm.yml,
# with the runtime and with reads alone.
wasm-test:
CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUNNER="bun {{ justfile_directory() }}/test/wasm/rust.ts" cargo test --locked -p moq-clock --lib --target wasm32-unknown-unknown
CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUNNER="bun {{ justfile_directory() }}/test/wasm/rust.ts" cargo test --locked -p moq-clock --lib --target wasm32-unknown-unknown --no-default-features

# Auto-fix the browser/WASM bindings.
[positional-arguments]
Expand Down
3 changes: 2 additions & 1 deletion rs/moq-audio/src/capture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
//! in that same callback so the buffers leaving here are already clean.

use std::task::Poll;
use std::time::{Duration, Instant};
use std::time::Duration;

use cpal::traits::{DeviceTrait, HostTrait, StreamTrait};
use moq_net::time::Instant;
use ringbuf::traits::Producer;

use crate::Error;
Expand Down
3 changes: 2 additions & 1 deletion rs/moq-audio/src/capture/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

use std::sync::Arc;
use std::sync::atomic::{AtomicU64, Ordering};
use std::time::{Duration, Instant};
use std::time::Duration;

use moq_net::time::Instant;
use ringbuf::traits::{Consumer, Observer, Producer, Split};
use ringbuf::{CachingCons, CachingProd, HeapCons, HeapProd, HeapRb};
use tokio::sync::mpsc;
Expand Down
5 changes: 3 additions & 2 deletions rs/moq-audio/src/encode/capture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
use std::fmt;
use std::sync::Arc;
use std::task::Poll;
use std::time::{Duration, Instant};
use std::time::Duration;

use moq_net::time::Instant;
use rand::RngExt;

use moq_mux::catalog::hang::CatalogExt;
Expand Down Expand Up @@ -2107,7 +2108,7 @@ mod tests {
/// the broadcast clock's own correlation, so the published timestamp is exactly that
/// instant however late the read happens.
mod clock {
use std::time::{Duration, Instant, SystemTime};
use std::time::{Duration, SystemTime};

use super::*;

Expand Down
6 changes: 2 additions & 4 deletions rs/moq-audio/src/encode/producer.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//! Encode raw PCM and publish it as a moq audio track.

use std::time::Instant;

use bytes::Bytes;

use moq_mux::catalog::hang::CatalogExt;
Expand Down Expand Up @@ -442,7 +440,7 @@ impl<E: CatalogExt> Producer<E> {
if self.grouped >= self.group_samples {
self.track.cut(None)?;
}
self.track.flush(timestamp, Instant::now())?;
self.track.flush(timestamp, moq_net::time::now())?;
Ok(())
}

Expand All @@ -468,7 +466,7 @@ impl<E: CatalogExt> Producer<E> {
keyframe: false,
duration: None,
})?;
track.flush(timestamp, Instant::now())?;
track.flush(timestamp, moq_net::time::now())?;
}

track.cut(Some(terminal.end))?;
Expand Down
2 changes: 1 addition & 1 deletion rs/moq-c/src/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ impl Publish {
/// unless their caller explicitly identifies the frame as encoder output.
pub fn media_flush(&mut self, media: Id, timestamp: hang::container::Timestamp) -> Result<(), Error> {
let track = self.media.get_mut(media).ok_or(Error::MediaNotFound)?;
track.flush(timestamp, std::time::Instant::now())?;
track.flush(timestamp, moq_net::time::now())?;
Ok(())
}

Expand Down
4 changes: 2 additions & 2 deletions rs/moq-c/src/video.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use std::ffi::{c_char, c_void};
use std::sync::atomic::{AtomicU64, Ordering};
use std::sync::{Arc, OnceLock};
use std::time::{Duration, Instant};
use std::time::Duration;

use tokio::sync::oneshot;

Expand Down Expand Up @@ -232,7 +232,7 @@ async fn follow_reservation(
max = next;
control = Control::new(Policy::new(max));
}
let Some(bitrate) = control.update(estimate, Instant::now()) else {
let Some(bitrate) = control.update(estimate, moq_net::time::now()) else {
continue;
};

Expand Down
1 change: 1 addition & 0 deletions rs/moq-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ humantime = { workspace = true }
moq-archive = { workspace = true }
moq-audio = { workspace = true, optional = true, features = ["aac"] }
moq-auth = { workspace = true, features = ["serve"] }
moq-clock = { workspace = true }
# `server` enables the HTTP egress server for `moq export hls`; the importer is always available.
moq-hls = { workspace = true, features = ["server"] }
# Names the MSF catalog track `export archive` records.
Expand Down
8 changes: 4 additions & 4 deletions rs/moq-cli/src/play/fake.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
//! A deviceless [`Output`] for tests: it records what the speaker would have
//! played and when, on tokio's clock, so a paused runtime measures playback
//! played and when, on the ambient clock, so a paused runtime measures playback
//! without waiting on it.

use std::sync::{Arc, Mutex};
use std::time::Duration;

use moq_audio::playback::Input;
use tokio::time::Instant;
use moq_clock::Instant;

use super::output::{Output, Sink, Speaker};
use super::window::Event;
Expand Down Expand Up @@ -43,7 +43,7 @@ impl Recorder {
pub fn present(&self, media: &super::media::Media<Self>) -> Option<hang::moq_net::Timestamp> {
let mut video = media.video.lock().unwrap();
let presentation = media.presentation.lock().unwrap();
let now = Instant::now().into_std();
let now = moq_clock::now();
let mut shown = None;
while video
.front()
Expand Down Expand Up @@ -116,7 +116,7 @@ pub(super) struct FakeSink {

impl Sink for FakeSink {
async fn finish(self) {
tokio::time::sleep_until(self.end).await;
moq_clock::sleep_until(self.end).await;
}

fn write(&mut self, samples: &[u8]) -> anyhow::Result<()> {
Expand Down
Loading
Loading