Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ziglang/zig
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: ziglang/zig
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: io-threaded-no-queue
Choose a head ref
Checking mergeability… Don’t worry, you can still create the pull request.
  • 3 commits
  • 1 file changed
  • 1 contributor

Commits on Nov 7, 2025

  1. 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.
    kristoff-it committed Nov 7, 2025
    Configuration menu
    Copy the full SHA
    0156d68 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    b80e439 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    c199124 View commit details
    Browse the repository at this point in the history
Loading