Skip to content

Subtasks, wasi:cli/run, host invocations of functions, and relationships within #608

@alexcrichton

Description

@alexcrichton

Wasmtime's host API today is that when a function is invoked it returns both the function's return value and TaskExit. The TaskExit value has a single method, block, which is intended to transitively wait for all subtasks spawned by the original root task. This structure is used in a few situations:

In discussions with @lukewagner and @dicej I've realized that Wasmtime's modeling of subtasks in this way is incorrect and needs to change. Effectively the TaskExit return value is going to need to be removed from Wasmtime because subtasks are tied to instances, not tasks themselves.

In doing this, however, it raises the question of what should be happening in all of these cases? For example at what point should wasi:cli/run "finish"? Is that the same answer as --invoke? Or is serve perhaps a bit different? I wanted to open this issue to write down some thoughts and have some possible discussion about this.

In the near-term what I plan to do is to add some sort of "wait for all tasks in this Store" method which will be used in all of these situations. That would mean, however, that a background task would keep the entire store alive and would keep Wasmtime from exiting. That's probably fine in the near-term but I don't think that this is a great long-term solution. I'm also not exactly sure what the solution might be and where it would lie, as the answer could be in WASI idioms or in the component model itself, unsure!

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