Skip to content

Move from std:::thread to Windows Thread Pool #32

Open

Description

@mgradwohl

Each frame 8 std::threads are constructed, execute, and are destructed.

Investigate moving to Windows thread pool https://learn.microsoft.com/en-us/windows/uwp/cpp-and-winrt-apis/concurrency-2

Activity

  1. added
    enhancementNew feature or request
    priority: medFix next: reliability, maintainability, and high-value usability
    review: 2026-11Repository-wide review at fdf20b4, November 2026
    severity: lowLimited impact, maintenance improvement, or optional new capability
    on Nov 9, 2026
  2. mgradwohl commented on Nov 9, 2026

    @mgradwohl
    OwnerAuthor

    Repository-wide review: 2026-11

    Classification: recommendation. Severity: low. Priority: med. Impact: performance.
    Reviewed revision: fdf20b4cbfbbb8009d45296f3d60f0f541ee539b.

    Evidence

    Board.cpp:330-349, Renderer.cpp:154-188, MainWindow.xaml.cpp:330-345.

    Finding

    Both simulation and rendering create/join 2..8 OS threads on every draw; the UI callback waits for both phases. Merely switching the spelling to std::jthread gives scoped joining, not persistent workers. The work uses multiple parallelism mechanisms and has no benchmark evidence for always parallelizing small boards.

    Recommended change

    After correctness fixes, benchmark serial work versus reusable bounded workers/Windows thread pool and choose measured thresholds. Consider publishing immutable generations from a background simulation worker rather than blocking the UI. Keep bounded work/cancellation/backpressure and propagate failures correctly. Treat sparse/HashLife or GPU engines as later experiments, not a shortcut around the current rule/ownership defects.

    Acceptance criteria

    • Benchmark 25x25, default 300x300, and 700x700 sparse/dense boards.
    • Record update/render/frame latency, thread creation, and UI responsiveness separately.
    • Results remain identical across worker counts and shutdown is bounded.
    • Avoid claiming speedups until measured on representative x64/ARM64 machines.

    Related context / sources

    Comparable architecture ideas: Golly has distinct QuickLife/HashLife algorithms (bundled algorithm docs mirror); Ready uses OpenCL for continuous/discrete automata (project README). Their semantics/workloads differ; GPU acceleration and HashLife are not universally faster.

  3. mgradwohl commented on Nov 9, 2026

    @mgradwohl
    OwnerAuthor

    Backlog triage

    Status: Still open.
    Severity: low. Priority: med. Impact: performance.
    Assessed against fdf20b4cbfbbb8009d45296f3d60f0f541ee539b.

    Evidence

    Board.cpp:330-349

    Disposition and remaining scope

    Still outstanding. Simulation and rendering still construct/join jthreads for every frame; no reusable worker pool exists.

    Completion criteria

    • Benchmark 25x25, default 300x300, and 700x700 sparse/dense boards.
    • Record update/render/frame latency, thread creation, and UI responsiveness separately.
    • Results remain identical across worker counts and shutdown is bounded.
    • Avoid claiming speedups until measured on representative x64/ARM64 machines.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestimpact: performanceReview impact category: performancepriority: medFix next: reliability, maintainability, and high-value usabilityseverity: lowLimited impact, maintenance improvement, or optional new capability

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions