An asynchronous runtime compatible with WebAssembly and non-WebAssembly targets.

Overview

Promise x Tokio = Prokio

An asynchronous runtime compatible with WebAssembly and non-WebAssembly targets.

Rationale

When designing components and libraries that works on both WebAssembly targets backed by JavaScript Runtime and non-WebAssembly targets with Native Runtimes. Developers usually face challenges that requires applying multiple feature flags throughout their application:

  1. Select I/O and timers that works with the target runtime.
  2. Native Runtimes usually require Send futures and WebAssembly types are usually !Send.

Implementation

To alleviate these issues, Prokio implements a single-threaded runtime that executes ?Send (Send or !Send) futures.

On platforms with multi-threading support, prokio spawns multiple independent runtimes proportional to the CPU core number. When tasks are spawned with a runtime handle, it will randomly select a worker thread from the internal pool. All tasks spawned with spawn_local will run on the same thread as the thread the task was running. When the runtime runs in a WebAssembly target, all tasks will be scheduled on the main thread.

This runtime is designed in favour of IO-bounded workload with similar runtime cost. When running I/O workloads, it would produce a slightly better performance as tasks are never moved to another thread. However, If a worker thread is busy, other threads will not be able to steal tasks scheduled on the busy thread. When you have a CPU-bounded task where CPU time is significantly more expensive, it should be spawned with a dedicated thread (or Web Worker) and communicates with the application using channels.

Prokio provides the following components:

  1. A Task Scheduler that is capable of running non-Send tasks.
  2. A Timer that is compatible with the scheduler backend.
  3. Task Synchronisation Mechanisms.

Runtime Backend

Prokio runtime is implemented with different runtimes depending on the target platform and can use all features (timers / IO / task synchronisation) from the selected native runtime:

  • wasm-bindgen-futures (WebAssembly targets)
  • tokio (non-WebAssembly targets)
You might also like...
OP-Up is a hive tool for testing OP-Stack-compatible software modules

op-up Warning This is a work in progress. OP-Up is a hive tool for testing OP-Stack-compatible software modules. This project was born out of the need

Nyah is a programming language runtime built for high performance and comes with a scripting language.

🐱 Nyah ( Unfinished ) Nyah is a programming language runtime built for high performance and comes with a scripting language. 🎖️ Status Nyah is not c

🐱 A high-speed JIT programming language and its runtime, meow~

🐱 A high-speed JIT programming language and its runtime, meow~

Build database expression type checker and vectorized runtime executor in type-safe Rust

Typed Type Exercise in Rust Build database expression type checker and vectorized runtime executor in type-safe Rust. This project is highly inspired

Secure mTLS and gRPC backed runtime daemon. Alternative to systemd. Written in Rust.

Auraed A runtime daemon written in Rust. Designed to run as pid 1 mTLS backed gRPC API over unix domain socket Run executables Run containers Run virt

Salty and Sweet one-line Rust Runtime Optimization Library

SAS SAS (Salty-And-Sweet) is an one-line Rust runtime optimization library. Features NUMA-aware rayon: numa feature should be enabled If you have 1 NU

A Platform-less, Runtime-less Actor Computing Model

CrossBus A Platform-Less, Runtime-Less Actor Computing Model Overview CrossBus is an implementation of Actor Computing Model, with the concept that Ru

A heap allocated runtime for deeply recursive algorithms.

Reblessive A heap allocated runtime for deeply recursive algorithms. Turn your cursed recursive algorithm into a blessed heap allocated structure whic

Shared Channel for WebAssembly

Shared Channel for WebAssembly This crate provides a way for WebAssembly threads to receive messages from other threads using a JavaScript primitive c

Comments
  • Bump Swatinem/rust-cache from 1 to 2

    Bump Swatinem/rust-cache from 1 to 2

    Bumps Swatinem/rust-cache from 1 to 2.

    Release notes

    Sourced from Swatinem/rust-cache's releases.

    v2.0.0

    • The action code was refactored to allow for caching multiple workspaces and different target directory layouts.
    • The working-directory and target-dir input options were replaced by a single workspaces option that has the form of $workspace -> $target.
    • Support for considering env-vars as part of the cache key.
    • The sharedKey input option was renamed to shared-key for consistency.

    v1.4.0

    • Clean both debug and release target directories.

    v1.3.0

    • Use Rust toolchain file as additional cache key.
    • Allow for a configurable target-dir.

    v1.2.0

    • Cache ~/.cargo/bin.
    • Support for custom $CARGO_HOME.
    • Add a cache-hit output.
    • Add a new sharedKey option that overrides the automatic job-name based key.

    v1.1.0

    • Add a new working-directory input.
    • Support caching git dependencies.
    • Lots of other improvements.

    v1.0.1

    • Improved logging output.
    • Make sure to consider all-features dependencies when pruning.
    • Work around macOS cache corruption.
    • Remove git-db cache for now.
    Changelog

    Sourced from Swatinem/rust-cache's changelog.

    Changelog

    2.2.0

    • Add new save-if option to always restore, but only conditionally save the cache.

    2.1.0

    • Only hash Cargo.{lock,toml} files in the configured workspace directories.

    2.0.2

    • Avoid calling cargo metadata on pre-cleanup.
    • Added prefix-key, cache-directories and cache-targets options.

    2.0.1

    • Primarily just updating dependencies to fix GitHub deprecation notices.

    2.0.0

    • The action code was refactored to allow for caching multiple workspaces and different target directory layouts.
    • The working-directory and target-dir input options were replaced by a single workspaces option that has the form of $workspace -> $target.
    • Support for considering env-vars as part of the cache key.
    • The sharedKey input option was renamed to shared-key for consistency.

    1.4.0

    • Clean both debug and release target directories.

    1.3.0

    • Use Rust toolchain file as additional cache key.
    • Allow for a configurable target-dir.

    1.2.0

    • Cache ~/.cargo/bin.
    • Support for custom $CARGO_HOME.
    • Add a cache-hit output.
    • Add a new sharedKey option that overrides the automatic job-name based key.

    1.1.0

    • Add a new working-directory input.
    • Support caching git dependencies.
    • Lots of other improvements.

    ... (truncated)

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies github_actions 
    opened by dependabot[bot] 0
  • Provide IO types

    Provide IO types

    tokio provides the following IO types:

    1. Standard Input / Output
    2. TCP / UDP / Unix Sockets
    3. Named Pipes (Windows)

    Whilst we cannot provide these traditional IO types when running in browsers, we can provide some other IO types:

    1. HTTP
    2. WebSockets
    3. WebRTC
    feature-request 
    opened by futursolo 0
  • Enable prokio for wasm32-wasi (wasm-bindgen-futures)

    Enable prokio for wasm32-wasi (wasm-bindgen-futures)

    This issue tracks the missing upstream support to land wasi support for Prokio Runtime with wasm-bindgen-futures backend:

    • [ ] wasm-bindgen supports wasm32-wasi.
    blocked feature-request 
    opened by futursolo 0
  • Enable prokio for wasm32-wasi (tokio)

    Enable prokio for wasm32-wasi (tokio)

    Tokio has just landed support for wasm32-wasi. However, wasi misses some essential features for Yew Runtime to become useful under wasi.

    wasi can be used for:

    • Client-Side Rendering (wasi in Browser)
    • Server-Side Rendering (wasi in JavaScript-capable WebAssembly Runtime & Standalone WebAssembly Runtime)
    • Static-Site Generation (wasi in JavaScript-capable WebAssembly Runtime & Standalone WebAssembly Runtime)

    This issue tracks the tokio features required to land wasi support for Yew Runtime:

    • [ ] wasi target currently lacks networking capability in general. (needed for CSR and SSR.) This is primarily due to sockets under wasi is not standardised. There is an alternative proposal for an HTTP interface.
    • [ ] tokio::fs for wasi. (needed for SSG and potentially SSR.)

    There are some other features that might be desirable before we start to implement the target:

    • [ ] multi-threading support so multiple CPU cores can be utilised.
    blocked feature-request 
    opened by futursolo 1
Releases(v0.1.0)
Owner
Yew Stack
UI for Rust
Yew Stack
👌 A smol functional language that targets other languages

ditto A small, pure functional language that targets other languages. Syntax highlighting coming soon Elevator pitch ⏱️ Ditto is a mashup of my favour

ditto 45 Dec 17, 2022
An API for getting questions from http://either.io implemented fully in Rust, using reqwest and some regex magic. Provides asynchronous and blocking clients respectively.

eithers_rust An API for getting questions from http://either.io implemented fully in Rust, using reqwest and some regex magic. Provides asynchronous a

null 2 Oct 24, 2021
High-order Virtual Machine (HVM) is a pure functional compile target that is lazy, non-garbage-collected and massively parallel

High-order Virtual Machine (HVM) High-order Virtual Machine (HVM) is a pure functional compile target that is lazy, non-garbage-collected and massivel

null 5.5k Jan 2, 2023
ARM TrustZone-M example application in Rust, both secure world side and non-secure world side

ARM TrustZone-M example application in Rust, both secure world side and non-secure world side; projects are modified from generated result of cortex-m-quickstart.

null 44 Dec 4, 2022
A collection (eventually) of examples that use some non-beginner things.

nannou examples A collection (eventually) of examples that use some non-beginner things. Right now the only example combines nannou's standard draw AP

Alexis Andre 22 Oct 21, 2022
The non-opinionated Rust-based commit message linter.

Documentation | Website git-sumi The non-opinionated Rust-based commit message linter Transform your commit practices with flexible linting for consis

Óscar 6 Mar 1, 2024
A asynchronous implementation of the invidious innertube aka youtubei API wrapper

A asynchronous implementation of the invidious innertube aka youtubei API wrapper. Using tokio,reqwest, serde and serde_json

11Tuvork28 11 Dec 22, 2022
a frontier based evm compatible chain template

Substrate Frontier Node Template A FRAME-based Substrate node with the Ethereum RPC support, ready for hacking ?? Generation & Upstream This template

zero network 2 Oct 6, 2021
Write Anchor-compatible Solana programs in Python

seahorse: Write Solana programs in Python The ease of Python with the safety of Rust. Seahorse lets you write Solana programs in Python. It is a commu

✨ amelia chen ✨ 214 Dec 28, 2022
A SCALE-compatible collection of bits

scale-bits · This small utility crate provides two separate things: A Bits type that can be SCALE encoded and decoded, and is fully SCALE compatible w

Parity Technologies 3 Sep 25, 2022