lib-parallel · crate

kinogaki-parallel

Libraryenvironment

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
depends onused by tests alonedependencies for tests alone are listed below, not drawn

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 k starts at about k·c and works until the end T, so W threads finish work B when B = W·T − c·W²/2: T = B/W + c·W/2, smallest at W = √(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

CrateRepositoryAsWhat it is
kinogaki-capture-diffCore and the appnormalCompares two sets of UI reference captures (tools/ui_captures.py compare BEFORE AFTER).
kinogaki-cookCore and the appnormalStudio's core cooking engine, the same for every network kind (the owner's rule: the cooking DAG for nodes is core's).
kinogaki-geometry-viewCore and the appnormalGeometry, 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-projectCore and the apptestsStudio's project files: a document as a Prism document.
kinogaki-script-execlib-scriptnormallib-script's engine: a column (batch) interpreter in safe Rust.
kinogaki-scriptingCore and the apptestsScripts over the standard values: lib-script's engine behind the SDK's ScriptEngine, and what a script sees of each value.
kinogaki-workflowsWorkflowstestsTests alone: tests/workflows drives what a person does across the plugins the app ships, through the real editor offscreen.

Modules

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.