Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Attributes and hints

#[psync::graph(...)]

Goes on an async fn, including methods and async fn main (put it above #[tokio::main], #[tracing::instrument] and other attributes; inside an #[async_trait] impl, on the method: Other attribute macros). It also rewrites async blocks and async closures inside the function it is on. On an ordinary fn it runs statements marked #[psync::par] on threads (Synchronous code, with the std feature). A bare #[graph] works when psync::graph is imported.

OptionDefaultMeaning
bound = N16at most N loop iterations’ prefixes in flight, per loop; must be at least 1
explainoffprint the dependency graph, loops and barriers to stderr at compile time
offoffcompile the function as written; hint attributes are removed
profileoffcompile the function as written, and report each statement that awaits, with its line and time, to the clock and sink given to psync::profile::install (Getting a trace)
crate = path::psyncpath to the psync crate in generated code, for re-exports
strictoffunclassified awaited calls are writes to an unknown resource: they conflict with every effect and never run speculatively
calls = read / write / write_independent / independentnonea mark for the whole function: unclassified calls read (even with strict) or write; the independent forms also make every statement #[psync::independent] (Marking a whole function)
speculateoffwrites may run before earlier exits everywhere in the function
path_textoffcompare files by path text, as before 2026-11-26, instead of by identity (device and inode, resolved symlinks); literal paths that differ are then never gated (Owned files). owned_files names the default explicitly
yield_every = Noffinsert psync::yield_now().await at the start of every loop body in async code, every N iterations (Yield injection)
effects(read(a, ..), write(b, ..), ordered(c, ..))noneextra verbs (whole names or first _-separated words) for the effect analysis
baseline = resyncnonefor comparisons only: schedule by ReSynchronizer’s rules (within one block, one effect per environment, no gates, no hints); see Measured: the same functions under ReSynchronizer’s rules

Options are comma-separated: #[psync::graph(bound = 4, explain)]. Anything else is a compile error: expected `bound = N`, `explain`, `off`, `strict`, `speculate`, `effects(..)`, `calls = ..`, `yield_every = N`, `profile`, `owned_files`, `path_text` or `crate = path` .

Hints

HintOnEffect inside #[psync::graph]
#[psync::seq]any statementthe statement is a barrier: it and everything around it keep their order; on a for loop, the loop is not prefetched
#[psync::fresh]let x = init; with one bindingthe let stays in place, and each concurrent chain that uses x begins with its own let x = init;; uses of x are not conflicts
#[psync::independent]for or while loopskip loop-carried-state and cross-iteration effect checks for prefetch and fission; required for while loops
#[psync::independent]any other statementits effects commute with those of the statements around it; data dependencies still apply
#[psync::par]a statement of a synchronous (fn) functionworth a thread: it may run on another thread beside independent statements; does nothing in async code
#[psync::speculate]statement or for loopits writes may run before earlier exits, or for later items before an earlier item ends the loop

Outside a #[psync::graph] function, the hints expand to their input unchanged.

Names psync treats specially

Every list of names psync reads (verbs, pure and ordered methods, guards, delays, clock calls, blocking calls, SQL words, logging and pure macros) is on Names psync knows, included from the source.