8000 Proposal for threading and syscall interface redesign · Issue #66 · nebulet/nebulet · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Feb 28, 2023. It is now read-only.
This repository was archived by the owner on Feb 28, 2023. It is now read-only.
Proposal for threading and syscall interface redesign #66
Open
@lachlansneff

Description

@lachlansneff

Asynchronous code seems to be all the rage these days. I figured out a way of implementing coroutines in Nebulet that appear to be normal threads to the user, but are, in fact, lightweight coroutines. This would allow the syscall interface to be completely asynchronous, but actually appear to be blocking. This would simplify writing applications for Nebulet and improve performance.

This would involve removing preemption for threads and each process would only run on a single core at a time (essentially making processes the defacto unit of true concurrency), eliding the need for expensive synchronization.

Gist

  • No preemption at the thread level. A process only executes on one cpu at a time.
  • Create threads normally, but thread switching code is injected at specific points, like external function calls and in some loops.
  • To run on multiple cpus, create multiple processes.
  • To the user, threads appear to be fully-preemptive, but under the hood, they are coroutines.
  • Can mark spots as thread switch locations and mark functions where no thread switches should be generated.

Advantages

  • May result in better overall performance.
  • No locks or atomics are necessary for tables or thread queues.
  • The syscall interface can appear to be blocking, but actually be asynchronous.
  • No language support required for coroutines.

Disadvantages

  • May constrict some usages.

Design Challenges

  • Requires some way of generating and saving new wasm stacks.
  • Requires a complete rewrite of the threading support in Nebulet.

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    designDesign DiscussionsenhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0