Skip to content

Order of arrival of message responses can delay execution #5212

Open
@ggreif

Description

@ggreif

@timohanke provided this feedback

let fut1 = Actor1.call(); // the slow (e.g. inter-subnet) call
let fut2 = Actor2.call(); // the fast one

await fut1;
// state changes
await fut2;

in this scenario if the fut2 response arrives before fut1's, it gets saved while await fut1 is still blocking. When we come to await fut2 the continuation is not invoked immediately, because of the mandatory commit semantics enforcing a context switch.

Timo proposes an opt-in mechanism to avoid the commit and immediately go on executing the continuation, thus avoiding the delay.

I propose a parenthetical like

(with commit = false) await fut2;

to opt out of await's mandatory blocking.

The other possibility is a parallel await

let vals = [await] [fut1, fut2];

@Kamirus suggests

let val = switch (fulfilled fut2) {
  case (?val) val;
  case null await fut2
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions