pub struct RuntimeConfig {Show 20 fields
pub workers: usize,
pub quantum: u32,
pub mailbox: MailboxConfig,
pub max_flows: u32,
pub max_ask_waits: u32,
pub max_host_awaits: u32,
pub max_links: u32,
pub max_monitors: u32,
pub max_registry_names: u32,
pub host_await: Option<Arc<dyn HostAwaitBridge>>,
pub remote_dedup_window: u32,
pub distribution: Option<Arc<DistributionBridge>>,
pub max_runtime_bytes: usize,
pub trust: TrustLevel,
pub output: Arc<dyn OutputSink>,
pub log: Option<Arc<dyn LogSink>>,
pub quota: QuotaConfig,
pub security_audit: Option<Arc<dyn SecurityAuditSink>>,
pub root_authority: RootAuthorityPolicy,
pub jit: JitConfig,
}Expand description
Tunables for Runtime::new. Everything has a sensible default via
RuntimeConfig::default so the common case is Runtime::new(chunk).
Fields§
§workers: usizeNumber of worker OS threads. Defaults to the number of logical CPUs
— one worker per core is the right starting point for a CPU-bound
M:N scheduler; embedders running alongside other CPU-heavy work on
the same machine may want fewer. 0 is raised to 1: a runtime
with no worker cannot run a flow.
quantum: u32Instructions a flow runs before being preempted back to the
scheduler even if it never hits Yield. 0 is raised to 1.
A zero slice returns Yield without executing anything, and the
worker would requeue that flow forever.
mailbox: MailboxConfigMemory + overflow contract applied to every flow mailbox
spawned by this runtime (bytecode Spawn and host spawn).
See MailboxConfig / docs/mailbox.md.
max_flows: u32Hard cap on concurrently live flows (0 = unlimited).
Checked on every host and bytecode spawn.
max_ask_waits: u32Hard cap on outstanding Ask / AskTimeout waiters process-wide
(0 = unlimited). Each asker holds at most one wait; this bounds the
total index size when many flows park against a silent target.
See crate::docs::security (DoS) and Self::sandbox.
max_host_awaits: u32Hard cap on outstanding HostAwait parkers process-wide
(0 = unlimited). Each flow holds at most one await.
max_links: u32Hard cap on live process-wide links (0 = unlimited).
Accounting is performed by the link store itself, under the same synchronization that protects the link table.
max_monitors: u32Hard cap on live process-wide monitors (0 = unlimited).
Accounting is performed by the monitor store itself.
max_registry_names: u32Hard cap on live process-wide registry names (0 = unlimited).
The registry store counts only successfully registered names.
host_await: Option<Arc<dyn HostAwaitBridge>>Host async bridge for crate::Opcode::HostAwait. None fails
any HostAwait closed. Not a CallNative / std-native slot.
remote_dedup_window: u320 = disabled. When set, Runtime::deliver_frame ignores duplicate
(sender, request_id) pairs within the window (at-least-once wire).
distribution: Option<Arc<DistributionBridge>>Host queue for crate::Opcode::SendRemote. None fails that opcode.
Byteflow does not open sockets; the embedder drains the bridge.
max_runtime_bytes: usizeProcess-wide memory ceiling for heap charges (Str / Bytes
register stores and shared crate::HeapStr / crate::HeapBytes).
Independent of per-flow crate::QuotaConfig::mem_limit and mailbox
byte budgets. Default: 256 MiB.
trust: TrustLevelConstant-pool trust for crate::verify_with at runtime construction.
Default is crate::TrustLevel::Untrusted (fail closed).
output: Arc<dyn OutputSink>Where bytecode print (native index 0) writes when using
crate::std_native_table_with. Ignored if you supply your own table.
log: Option<Arc<dyn LogSink>>Scheduler diagnostics (ask, finalize, …). None keeps the
BYTEFLOW_LOG stderr path and adds no collector. The sink is called
inline and must not block or panic.
quota: QuotaConfigPer-flow CPU / memory / spawn-send rate budgets.
security_audit: Option<Arc<dyn SecurityAuditSink>>Optional security audit sink (capability / quota / module denials).
Independent of Self::log; never receives full CapId tokens.
Delivery is asynchronous (bounded queue + dedicated thread) so a
slow sink cannot stall scheduler workers.
Authority minted for host Runtime::spawn (not bytecode Spawn).
Default RootAuthorityPolicy::TrustedHost preserves historical
ROOT + full native mask. Self::sandbox does not change this —
use Runtime::spawn_untrusted or set this field explicitly.
jit: JitConfigjit only.Trace JIT settings (feature = "jit"). Ignored when the feature is off.
Implementations§
Source§impl RuntimeConfig
impl RuntimeConfig
Sourcepub fn sandbox() -> Self
pub fn sandbox() -> Self
Opt-in sandbox profile for untrusted modules.
Default RuntimeConfig stays permissive (max_* = 0 unlimited,
QuotaConfig::permissive).
This profile enables fail-closed process-wide caps and tight
per-flow budgets. Trust defaults to crate::bytecode::TrustLevel::Untrusted
(inherited from Default) so Cap/Pid/Message constants are
rejected at verify time.
Does not change Self::root_authority: host Runtime::spawn
still mints trusted ROOT unless you set the policy or call
Runtime::spawn_untrusted.
Limits (starting point — tune under load):
max_flows = 128live flowsmax_ask_waits = 64,max_host_awaits = 128max_runtime_bytes = 64 MiBprocess heap accounting- mailbox: 256 hops / 4 MiB / Reject (
MailboxConfig::DEFAULT) - per-flow:
QuotaConfig::sandbox
Sourcepub fn sandbox_restricted() -> Self
pub fn sandbox_restricted() -> Self
Same process-wide caps as Self::sandbox, but
crate::bytecode::TrustLevel::Restricted: still no Cap/Pid/Message in the constant
pool; host may grant Caps / natives after admission.
Sourcepub fn policy_fingerprint(&self) -> PolicyFingerprint
pub fn policy_fingerprint(&self) -> PolicyFingerprint
Stable identity of the security-relevant knobs on this config.
Sourcepub fn applies_sandbox_caps(&self) -> bool
pub fn applies_sandbox_caps(&self) -> bool
True when at least one process-wide sandbox ceiling is armed
(max_flows / ask / host-await / runtime bytes tighter than the
permissive defaults). Does not imply the chunk was verified as
Untrusted — check Self::trust separately.