pub struct Graph { /* private fields */ }Expand description
A captured graph produced by Client::stop_capture: a recorded
launch sequence that replay re-runs against its original
buffers, skipping the launch path it was recorded from. Cheap to clone
(shares one backend graph).
The graph itself lives in the backend server, referenced here only by
GraphId; this handle holds a reference-counted owner that releases the
backend graph once the last clone drops. The graph replays against the exact
device buffers used during capture. The caller keeps those input/output
Handles alive and, each iteration, writes fresh inputs into the input
handles (same device pointers) and reads the output handles after replaying —
see Client::stop_capture.
Stream ordering. replay always dispatches on the
stream the graph was captured on, but input writes and output reads go on the
writing client’s current stream. They are ordered against the replay only
when they land on that same stream, so keep the client pinned to the capture
stream (via set_stream) — or issue all writes,
replays, and reads from the same unpinned client — for the whole decode loop.
Refreshing inputs from a client on a different stream races the replay and
silently feeds it stale data.
Implementations§
Source§impl Graph
impl Graph
Sourcepub unsafe fn replay(&self) -> Result<(), ServerError>
pub unsafe fn replay(&self) -> Result<(), ServerError>
Replay the captured launch sequence — every recorded kernel re-run against the buffers it was captured with, on the stream it was captured on. Self-contained (the handle owns its device handle); no client needed.
How much of the launch path this skips depends on the backend: a hardware graph (CUDA, HIP) replays as one dispatch, while a software graph (wgpu) re-encodes the recorded dispatches from prebuilt state. Either way pipeline lookup, binding resolution and metadata upload happened once, at capture.
Blocking only on the enqueue: replay waits for the
device thread to accept the dispatch and hands back what that enqueue
said — an unknown or destroyed graph, a refusal — then returns without
waiting for the device. A failure also leaves the graph’s write set
carrying it, so a read of those buffers keeps failing until a replay
lands.
The wait costs end-to-end throughput nothing: the device-thread work happens either way, and blocking here only stops deferring it to the next sync. What it does move is the caller-visible latency of this call, from the cost of posting to a channel to the real cost of enqueuing the pass — so a benchmark reading this column is reading latency, not throughput.
§Safety
The dispatch re-runs the recorded kernels against the raw device pointers captured with them; nothing validates those buffers still exist or are unshared. The caller must guarantee, until the replay’s work completes on the stream:
- Liveness — every
Handlethe captured kernels read or wrote is still allocated. Freeing one returns its memory to the pool, and a later replay reads or corrupts whatever the allocator has since placed there. - No concurrent use — no other stream or thread touches buffers the graph reads or writes while the replay executes; the replay is ordered only against work on its capture stream.
- Same-stream refreshes — input writes and output reads are issued on
the capture stream (keep the client pinned to it via
set_stream, or do everything from the one client), so they order against the replay instead of racing it.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Graph
impl !UnwindSafe for Graph
impl Freeze for Graph
impl Send for Graph
impl Sync for Graph
impl Unpin for Graph
impl UnsafeUnpin for Graph
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more