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.
| Option | Default | Meaning |
|---|---|---|
bound = N | 16 | at most N loop iterations’ prefixes in flight, per loop; must be at least 1 |
explain | off | print the dependency graph, loops and barriers to stderr at compile time |
off | off | compile the function as written; hint attributes are removed |
profile | off | compile 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 | ::psync | path to the psync crate in generated code, for re-exports |
strict | off | unclassified awaited calls are writes to an unknown resource: they conflict with every effect and never run speculatively |
calls = read / write / write_independent / independent | none | a 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) |
speculate | off | writes may run before earlier exits everywhere in the function |
path_text | off | compare 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 = N | off | insert 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, ..)) | none | extra verbs (whole names or first _-separated words) for the effect analysis |
baseline = resync | none | for 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
| Hint | On | Effect inside #[psync::graph] |
|---|---|---|
#[psync::seq] | any statement | the 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 binding | the 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 loop | skip loop-carried-state and cross-iteration effect checks for prefetch and fission; required for while loops |
#[psync::independent] | any other statement | its effects commute with those of the statements around it; data dependencies still apply |
#[psync::par] | a statement of a synchronous (fn) function | worth a thread: it may run on another thread beside independent statements; does nothing in async code |
#[psync::speculate] | statement or for loop | its 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.