When does a node checkpoint itself

前端 未结 1 489
孤城傲影
孤城傲影 2021-01-20 03:24

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

相关标签:
1条回答
  • 2021-01-20 03:27

    @Suspendable marks a function as potentially suspendable. The flow is actually suspended only when one of the following operations is performed:

    • Flow start
    • 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! }

    0 讨论(0)
提交回复
热议问题