aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/wasm/CodeGen.zig
diff options
context:
space:
mode:
authorLoris Cro <kappaloris@gmail.com>2025-11-04 21:11:40 +0100
committerLoris Cro <kappaloris@gmail.com>2025-11-07 12:43:25 +0100
commit0156d68f0c9626074ca14d6c2cf677135e47e585 (patch)
tree8527f8972db535a6c578bd1cec656c8c1bf3d1a0 /src/codegen/wasm/CodeGen.zig
parent19af9fa488ba7ddf2e7fd8f2f06ab594f7e23f91 (diff)
downloadzig-0156d68f0c9626074ca14d6c2cf677135e47e585.tar.gz
zig-0156d68f0c9626074ca14d6c2cf677135e47e585.zip
Io.Threaded PoC reimplementation
This is a reimplementation of Io.Threaded that fixes the issues highlighted in the recent Zulip discussion. It's poorly tested but it does successfully run to completion the litmust test example that I offered in the discussion. This implementation has the following key design decisions: - `t.cpu_count` is used as the threadpool size. - `t.concurrency_limit` is used as the maximum number of "burst, one-shot" threads that can be spawned by `io.concurrent` past `t.cpu_count`. - `t.available_thread_count` is the number of threads in the pool that is not currently busy with work (the bookkeeping happens in the worker function). - `t.one_shot_thread_count` is the number of active threads that were spawned by `io.concurrent` past `t.cpu_count`. In this implementation: - `io.async` first tries to decrement `t.available_thread_count`. If there are no threads available, it tries to spawn a new one if possible, otherwise it runs the task immediately. - `io.concurrent` first tries to use a thread in the pool same as `io.async`, but on failure (no available threads and pool size limit reached) it tries to spawn a new one-shot thread. One shot threads run a different main function that just executes one task, decrements the number of active one shot threads, and then exits. A relevant future improvement is to have one-shot threads stay on for a few seconds (and potentially pick up a new task) to amortize spawning costs.
Diffstat (limited to 'src/codegen/wasm/CodeGen.zig')
0 files changed, 0 insertions, 0 deletions