Kyron User Manual#
Kyron User Manual
|
status: valid
security: YES
safety: QM
|
||||
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 thatscore_toolchains_rustprovides for the selected Bazel platform configuration (--config=x86_64-linuxin 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-qnxandarm64-qnxin.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.iceoryx2and its base libraries: IPC and base containers, used bykyron-foundationand, when IPC is enabled, bykyron.proc-macro2,quoteandsyn: build time only, used bykyron-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 |
|---|---|---|
|
enabled |
Builds the iceoryx2-based IPC support. |
|
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 |
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 |
|---|---|
|
Number of async workers, 1 to 128. |
|
Task queue size of each async worker. Must be a power of two and at least 2. |
|
OS priority and scheduler type of the async workers. Configure both. If either is unset, both are inherited from the parent thread. |
|
CPU cores the async workers may run on. |
|
Stack size of the async workers. The minimum is OS and platform dependent. |
|
Adds a dedicated worker, which keeps the tasks spawned to it on its own thread. |
|
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().awaitbetween 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#
Add the module to your
MODULE.bazel:bazel_dep(name = "score_kyron", version = "<version>")
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.