lib-parallel · crate
kinogaki-parallel
Scoped parallel work over disjoint output slices, sized by cost.
- Repository
- lib-parallel (kinogaki/lib-parallel)
- Folder
libs/lib-parallel/crates/parallel- Source
- 5 files, 558 lines
- Tests
- 3 files, 311 lines
What it is
Scoped parallel work over disjoint output slices, sized by cost.
Kernels lend borrowed data to workers, so work runs on scoped threads (std::thread::scope); a persistent pool would need unsafe to lend borrows (owner decision 2026-10-15: stay safe, revisit later). Starting a thread costs about 8 µs on Linux and macOS but 60–250 µs on Windows, so the worker count is chosen per call site from measured costs:
- each call site (its source location) remembers the time one item took;
- every parallel run measures how long workers took to start;
- thread
kstarts at aboutk·cand works until the endT, soWthreads finish workBwhenB = W·T − c·W²/2:T = B/W + c·W/2, smallest atW = √(2B/c).
The first run of a site uses the caller's minimum block size. The calling thread always works from the start; one helper starts the others, so the caller is not delayed by thread creation. Results never depend on the worker count: callers write disjoint slices.
Helpers come from one process-wide budget (set_budget) within the calling thread's share (with_share); an application sharing the machine with its own user interface keeps cores free that way (see budget).
Depends on
None.
Third-party
None.
Used by
| Crate | Repository | As | What it is |
|---|---|---|---|
kinogaki-capture-diff | Core and the app | normal | Compares two sets of UI reference captures (tools/ui_captures.py compare BEFORE AFTER). |
kinogaki-cook | Core and the app | normal | Studio's core cooking engine, the same for every network kind (the owner's rule: the cooking DAG for nodes is core's). |
kinogaki-geometry-view | Core and the app | normal | Geometry, curves and B-reps in the viewport, independent of any GPU API: the SDK's standard values as surface packets (over the SDK's display triangulation and shading normals, so Solid draws what Render renders), the one picker that answers rays and boxes ... |
kinogaki-project | Core and the app | tests | Studio's project files: a document as a Prism document. |
kinogaki-script-exec | lib-script | normal | lib-script's engine: a column (batch) interpreter in safe Rust. |
kinogaki-scripting | Core and the app | tests | Scripts over the standard values: lib-script's engine behind the SDK's ScriptEngine, and what a script sees of each value. |
kinogaki-workflows | Workflows | tests | Tests alone: tests/workflows drives what a person does across the plugins the app ships, through the real editor offscreen. |
Modules
budget(private)One process-wide budget of helper threads, each thread's share of it, and a hook run as every helper starts.112 linescancel(private)Cooperative cancellation:CancelToken, which an owner raises and long work polls.81 linescosts(private)Measured costs: per-thread start time and per-item time of each call site.105 linesrun(private)Running blocks on the caller and scoped helpers.214 lines
Public types and traits
At the crate root
Structs CancelledCancelToken
By module: 2 public types and traits in 1 module
cancel CancelledCancelToken
Besides these, 2 public functions at module level.
