Skip to content

Tracing

The deterministic event trace. trace(sim) attaches a Tracer that records a canonical TraceRecord per processed event; the resulting sequence is the same-seed-same-result oracle used throughout the parallel test suites. llmsim.trace is a public submodule of the llmsim package.

Functions

trace

trace(sim)

Attach a fresh :class:Tracer to sim and return it.

disable_trace

disable_trace(sim)

Detach any tracer from sim, restoring the zero-overhead default path.

Records

Tracer

Tracer()

Collects a :class:TraceRecord per processed event.

Attach with :func:trace; read :attr:records after the run. Two runs of the same deterministic model produce equal record lists.

Start with an empty log.

record

record(time, eid, kind, priority, event)

Append the record for a processed event (used as the Sim sink).

clear

clear()

Discard all recorded events.

TraceRecord

Bases: NamedTuple

One processed event, in canonical, comparable form.

Attributes:

Name Type Description
time float

The simulation time at which the event was processed.

eid int

The event's monotonic schedule id (the deterministic tie-breaker).

kind str

The event class name (e.g. "Timeout", "Process").

priority int

The scheduling priority the event was processed at.

payload Any

The event's resolved value (or its exception, if it failed).