Kyron User Manual#

Kyron User Manual
status: valid
security: YES
safety: QM
version: 1

Overview#

This manual describes how to integrate and use Kyron, an async/await runtime for Rust. Kyron runs async tasks on one or more execution engines. Each engine has a pool of async workers with work-stealing scheduling, optional dedicated workers that keep a task on its thread, and an optional safety worker. The runtime also provides an I/O event loop, TCP/UDP networking, timers and sleep, channels, select!, iceoryx2-based IPC, and the #[kyron::main] attribute macro.

For building and testing Kyron itself, see Kyron.

Environment Needs#

  • Rust: Kyron supports Rust 1.90.0, used by Cargo builds and by Bazel builds without a platform configuration (rust-toolchain.toml, MODULE.bazel). Kyron is tested with the Ferrocene toolchain that score_toolchains_rust provides for the selected Bazel platform configuration (--config=x86_64-linux in CI).

  • Build system: Bazel 8.8.2 (.bazelversion) or Cargo.

  • Operating systems: Linux (x86_64) and QNX 8 (x86_64, aarch64). The Bazel configurations are x86_64-linux, x86_64-qnx and arm64-qnx in .bazelrc. QNX builds use QNX SDP 8.0.5; see the README for the GitHub token and the QNX license they need.

Dependencies#

  • libc: bindings to the operating system C library.

  • iceoryx2 and its base libraries: IPC and base containers, used by kyron-foundation and, when IPC is enabled, by kyron.

  • proc-macro2, quote and syn: build time only, used by kyron-macros.

Under Bazel, the crates come from score_crates. Under Cargo, they come from Cargo.lock. All of them are licensed under Apache-2.0 and/or MIT. See MODULE.bazel and Cargo.toml for the exact versions.

Module Configuration Details#

Build Configuration#

Bazel flag / Cargo feature

Default

Effect

//src/flags:k_enable_ipc / iceoryx2-ipc

enabled

Builds the iceoryx2-based IPC support.

//src/flags:k_runtime_disable_time_correction / disable_vm_correction

disabled

Disables the correction of time that goes backwards, which is needed on some virtual machines. Native Linux on x86_64 may disable it.

Cargo feature tracing

enabled

Emits tracing events from the runtime.

Runtime Configuration#

The runtime is created with RuntimeBuilder. with_engine adds one execution engine, configured through ExecutionEngineBuilder:

Setting

Meaning

workers(cnt)

Number of async workers, 1 to 128.

task_queue_size(size)

Task queue size of each async worker. Must be a power of two and at least 2.

thread_priority(prio) and thread_scheduler(type)

OS priority and scheduler type of the async workers. Configure both. If either is unset, both are inherited from the parent thread.

thread_affinity(cores)

CPU cores the async workers may run on.

thread_stack_size(bytes)

Stack size of the async workers. The minimum is OS and platform dependent.

with_dedicated_worker(id, params)

Adds a dedicated worker, which keeps the tasks spawned to it on its own thread.

enable_safety_worker(params) and safety_worker_task_queue_size(size)

Enables the safety worker and sizes its queue (a power of two).

The #[kyron::main] macro creates a runtime with one engine from its arguments (worker_threads, default 2; task_queue_size, default 256; worker thread parameters; dedicated workers). See the rustdoc of kyron-macros.

Configuration Effects#

Each engine has its own thread pool, and engines do not share workers, so a separate engine isolates a workload. Tasks within an engine have equal priority and are scheduled cooperatively: a task that blocks occupies its worker until it yields. Blocking work belongs on a dedicated worker.

Long-Running Operations#

This guideline realizes Yielding Guideline (comp_req__kyron_runtime__yield_guideline).

Tasks are scheduled cooperatively. A task keeps its async worker until it reaches an .await that is not ready, so a long computation delays every other task queued on that worker.

  • Divide a long computation into segments, and call kyron::futures::yield_now().await between them. The task then goes back to the queue, and the worker runs the other queued tasks first.

  • Choose the segment size so that one segment runs for a short time compared with the latency that the other tasks of the engine need.

  • Do not rely on a scheduling order after yield_now. The task only gives other queued tasks a chance to run.

  • Move work that cannot be divided, such as blocking system calls or third-party libraries with blocking calls, to a dedicated worker (spawn_on_dedicated) instead.

Examples#

The examples are in src/kyron/examples. Bazel aliases are in examples/:

bazel run //examples:select       # select! over several spawned tasks
bazel run //examples:main_macro   # runtime set up by #[kyron::main]
bazel run //examples:mpmc         # multi-producer, multi-consumer channel
bazel run //examples:safety_task  # tasks on the safety worker

See examples/README.md.

API Reference#

The public API is documented in rustdoc: cargo doc -p kyron --open.

Performance Considerations#

No performance analysis is published yet. The main factors are the number of workers per engine, the task queue sizes, and the thread priorities and affinities.

Integration Guidelines#

Integrating with Your Project#

  1. Add the module to your MODULE.bazel:

    bazel_dep(name = "score_kyron", version = "<version>")
    
  2. Depend on the runtime from your Rust target:

    rust_binary(
        name = "my_app",
        srcs = ["src/main.rs"],
        proc_macro_deps = ["@score_kyron//src/kyron-macros:runtime_macros"],
        deps = ["@score_kyron//src/kyron:libkyron"],
    )
    

Version History, Compatibility, and Troubleshooting#

For the version history, see the Kyron releases on GitHub. Each release carries its release notes and its verification evidence (coverage, test results, static analysis, vulnerability scan, SBOM) as assets. The release note of this documentation version, with its compatibility notes, known issues and known vulnerabilities, is Kyron Release Note (doc__kyron_release_note).

Safety and Security#

Safety-critical usage: Kyron is classified QM in the current release and makes no ASIL claim. An integrator must not rely on the safety worker or any other Kyron feature to achieve a safety goal. The classification and its tailoring are described in Kyron Safety Plan (doc__kyron_safety_plan).

Security considerations: Kyron provides no authentication or encryption for its TCP/UDP sockets, and it trusts every process with access to an iceoryx2 service. The security assumptions are listed in Kyron Security Plan (doc__kyron_security_plan). The security manual (wp__module_security_manual) is not created yet.

License#

Kyron is licensed under the Apache License Version 2.0. See the LICENSE file in the repository.

Feedback and Contributions#

Report issues and suggestions in the Kyron issue tracker. Contributions follow CONTRIBUTION.md.