I understand there\'s some annotation related to @Suspendable
to mark a function as serialisable. How much does a flow checkpoint itself?
Does a node c
@Suspendable
marks a function as potentially suspendable. The flow is actually suspended only when one of the following operations is performed:
send
receive
sendAndReceive
waitForLedgerCommit
getFlowInfo
sleep
When one of these operations is performed, the node uses Quasar to capture the execution stack and create a checkpoint. If a function does not perform any of these operations, no checkpoints will be created. This is true even if the flow is doing heavy computation and/or the function is marked @Suspendable
. In other words, Quasar does not do preemption, meaning we don't "checkpoint periodically", but only at specific call sites.
For example, here is the sequence of checkpoints in a simple flow:
@Suspendable
fun call() {
// checkpoint!
sendSomething()
computeSomething()
}
@Suspendable
fun sendSomething() {
send() // checkpoint!
}
@Suspendable
fun computeSomething() {
heavyComputation() // no checkpoint!
}