Days
Architectural Design

Time & Concurrency

Integer-nanosecond time and concurrency rules in both Days engines.

Scope: Days AGO and Legacy Days. Both Days engines execute on an integer-nanosecond event timeline, but they expose and parallelize that timeline differently.

Exact time and ordering

The exact engine stores time as u64 nanoseconds. Every event has a canonical key:

(time_ns, phase, origin_node, origin_seq)

phase makes same-time protocol ordering explicit. origin_node and origin_seq provide a stable total order without relying on worker scheduling or device execution order. Checked time arithmetic rejects an image or execution that would overflow its supported bounds.

The global scalar backend pops this order from one calendar. Round scalar, CPU, Metal, and CUDA partition state by LP and use positive channel lookahead to process a half-open interval safely:

[frontier, frontier + minimum_channel_lookahead)

Each LP is single-owner during a round. Remote events are invisible until the canonical barrier merge. CPU workers retain whole-LP ownership rather than sharing mutable protocol state per event; device plans preserve the same LP and event identities in bounded arenas.

The minimum channel lookahead counts every channel, including the host-to-host lanes that carry stage notifies on the Spectrum-X fabric. A lane's latency is the smallest NVLink message delay of its host pair minus 1 ns: configs/p16/rail_mini_roce.toml runs with certified_lookahead_ns=346, below that fabric's 502 ns network channels, and on the 1,024-GPU and 128-GPU SimAI shapes the lanes are at least 5,900 ns, so the network's 502 ns stays the minimum.

Legacy time

Nexosim stores the legacy engine clock as MonotonicTime. Days converts that clock to an exact u64 nanosecond offset with clock_ns in legacy/src/utils/exact_time.rs.

Legacy configuration and model behavior cross this boundary as follows:

  • Scenario values must resolve to finite, nonnegative integer nanoseconds.
  • Positive sampled/controller delays round up to the earliest non-early tick.
  • Serialization delay uses checked integer arithmetic and rounds up.
  • seconds_view produces f64 only for compatibility, controllers, and reports.

Packets and frames may carry an f64 time view, and several legacy models retain local f64 fields. Those values do not replace the event clock. Source, sink, switch, scheduler, wire, and L2 handlers read Context::time() where they need authoritative “now”; compatibility timestamps must not be described as an independent local clock.

Legacy concurrency

Nexosim advances to the next event or ticker time and processes work ready at that timestamp. Its multithreaded executor may run independent actor tasks concurrently. Models normally communicate through typed ports, though the legacy application source uses channels and scheduler/PFC bookkeeping uses explicit shared atomic state.

This concurrency model is distinct from exact safe-horizon execution. Nexosim actors do not become exact LPs, and exact CPU worker settings do not control the legacy runtime.

On this page