Skip to main content

RECOMMENDED_STACK_SIZE

Constant RECOMMENDED_STACK_SIZE 

Source
pub const RECOMMENDED_STACK_SIZE: usize = _; // 12_582_912usize
Expand description

Recommended native stack size (12 MiB) for any thread that drives kaish execution — the REPL sizes its block_on thread and tokio worker threads to this, and embedders that call Kernel::execute (directly or via a tokio runtime) should do the same (runtime::Builder::thread_stack_size, and a std::thread stack for a non-worker driver).

The kernel recurses on the native stack (command substitution, shell functions, .kai scripts). MAX_RECURSION_DEPTH converts a runaway into a loud error, but only if the stack is at least this large — on the default ~2 MB tokio worker stack the recursion overflows (SIGSEGV) before reaching the cap. This floor is the companion to that cap (see its docs for the cap × per-level < floor relationship): 12 MiB holds the depth-48 cap with margin even for an unoptimized embedder build (~193 KB/level), and #48 shrank the per-level cost enough to drop it from 16 MiB. kaish can’t set this itself (it doesn’t own the runtime), so it exposes the floor for owners to apply. See GH #47 / #48.