Skip to content

Implement a method for spawning GenServers on their own threads #8

@fedacking

Description

@fedacking

Motivation

There are scenarios where blocking tasks (sync IO, heavy cpu computation, etc) may cause some async code to block. Tokio relies on cooperative multitasking, so there are bugs if tokio async tasks never yield. A particularly relevant one is that it may cause other tasks that are in the queue for the same thread to never execute. This behaviour is visible in the following tokio issue tokio-rs/tokio/issues/4730

Proposal

  • First: allow the actors to be moved to their own thread in tokio, which can be done through the Runtime::spawn_blocking method.
  • Second: add a requirement to our own custom runtime that doesn't exhibit this behaviour. Either by creating new task always on their own dedicated thread or by having the pool of tasks be global.

Considerations

Before the second proposal, we should investigate if other runtimes exist and what model they use for thread management.

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