Repository navigation
Description
Summary
Parse the planned [runtime] with.toml keys for fiber stack and pool sizing and plumb them into program runtime initialization. The runtime has hardcoded defaults and test-only stack-size hooks today; project configuration can parse package/build/c_import settings but ignores [runtime]. This turns §14.19's planned surface into enforceable configuration.
Spec
§14.19 says stack sizing is implementation-defined configuration and calls out planned [runtime] with.toml keys. Requirements 14.19.1.5 and 14.19.1.36 track fiber_stack_size and fiber_pool_size.
[runtime]
fiber_stack_size = 131072
fiber_pool_size = 64Current state
ProjectConfig has fields for package metadata, c_import paths, link paths, no_std/alloc/runtime booleans, and overflow mode, but no runtime stack/pool fields (src/compiler/ProjectConfig.w:5). project_config_apply_entry handles std, alloc, runtime, [build].overflow, [c_import].include_paths, [link].search_paths, and C deps only (src/compiler/ProjectConfig.w:114). project_config_wants_key likewise ignores [runtime] (src/compiler/ProjectConfig.w:249).
The runtime hardcodes stack size in platform cores (rt/fiber_core_darwin.w:27, rt/fiber_core_windows.w:26) and has pool counters/stack reuse internals (rt/fiber_core_darwin.w:66, rt/fiber_core_darwin.w:701; Windows mirrors this at rt/fiber_core_windows.w:65, rt/fiber_core_windows.w:700). with_fiber_spawn accepts an explicit stack-size parameter (rt/fiber_core_darwin.w:522, rt/fiber_core_windows.w:521), but project defaults are not configured.
Implementation plan
- Add
runtime_fiber_stack_sizeandruntime_fiber_pool_sizefields toProjectConfig, with0meaning runtime default. - Teach
project_config_wants_keyandproject_config_apply_entryto accept[runtime] fiber_stack_sizeandfiber_pool_size, parse positive integer values, and produce manifest errors for invalid/negative/zero values as appropriate. - Thread the config through
CompilationConfigor a dedicated runtime-config object so check/build/run/test paths all see the same values. - Add runtime functions in
rt/fiber_core_darwin.wandrt/fiber_core_windows.wto set defaults before first fiber spawn. Do not mutate stack size after fibers exist unless the runtime loudly rejects it. - Apply default stack size in
with_fiber_spawnwhen the per-task@[stack_size]argument is zero; keep per-task stack size taking precedence. - Implement pool-size limiting in the free-stack pool.
fiber_pool_size = 0should mean implementation default or unlimited; document the chosen meaning and test it. - Update §14.19 wording from "planned" to normative when implementation lands.
Test plan
Add project-config tests with temporary with.toml fixtures:
- valid
[runtime] fiber_stack_sizechangeswith_fiber_default_stack_size(); - invalid string/negative/zero values produce a manifest error;
- per-task
@[stack_size]still overrides the project default.
Add behavior coverage for pool size using with_fiber_pool_allocs() / with_fiber_pool_reuses() (rt/fiber_core_darwin.w:701, rt/fiber_core_darwin.w:704) where those test hooks are available.
Acceptance criteria
[runtime] fiber_stack_sizeandfiber_pool_sizeare parsed fromwith.toml.- Invalid values fail loudly with manifest diagnostics.
- Runtime defaults are applied before first fiber spawn and do not affect already-created fibers.
- Existing
@[stack_size]behavior remains higher priority. with build && with build :fixpoint && with build :testpass.
Dependencies
Overlaps #501 for stack-pool test coverage.
Activity
ehartford commentedon Jun 11, 2026
Implemented in 913466f.
[runtime] fiber_stack_sizeandfiber_pool_sizenow parse from with.toml, validate positive integer values, appear in project-info output, flow through sema into native and emit-C main wrappers, configure the async fiber runtime before init, preserve@[stack_size]priority, and cap the reusable fiber stack pool. Added positive runtime behavior coverage and negative manifest diagnostics. Also fixed the release embedded-runtime dependency so updated runtime objects are baked into the compiler binary. Verification passed on 2026-06-11:WITH=$PWD/out/bin/with ./out/bin/with build,WITH=$PWD/out/bin/with ./out/release/bin/with build :fixpoint,WITH=$PWD/out/bin/with ./out/release/bin/with build :test, andWITH=$PWD/out/bin/with ./out/release/bin/with build :test-green.