Skip to content

Allow external adjustment of parallel search workers - #233

Open
zayenz wants to merge 16 commits into
mainfrom
feature/par-search-worker-adjustments
Open

Allow external adjustment of parallel search workers#233
zayenz wants to merge 16 commits into
mainfrom
feature/par-search-worker-adjustments

Conversation

@zayenz

@zayenz zayenz commented Jul 24, 2026

Copy link
Copy Markdown
Member

A portfolio may need to move a fixed CPU budget between search engines without rebuilding them. This PR adds Search::WorkerControl, a copyable handle that changes how many pre-created workers an engine may execute.

The initial threads value remains the fixed resident capacity. request() is thread-safe and does not wait for the engine to reach the requested count. Growing wakes parked workers; shrinking lets an in-flight search action finish before its worker parks. Zero pauses search without discarding its state, and a positive request resumes it. DFS and BAB also honor pause requests when the resolved capacity is one, including requests made during next().

Controls apply to DFS and BAB leaves owned by RBS and PBS. PBS keeps one control per asset; allocation policy and the portfolio-wide budget remain with the caller. Explicit controlled assets require parallel outer PBS execution; sequential outer PBS rejects them with WorkerControlInUse because a paused asset would prevent it from running siblings. A paused asset in parallel PBS observes the internal stop and reports when another asset closes the round. Its request remains zero and its search state is preserved. If every active asset is paused, next() waits until one resumes. TimeStop has no timer thread to wake a paused engine.

A control binds to one logical leaf-engine lifetime. Copies share request state, while an empty handle preserves fixed-worker behavior. Builds without thread support reject an initially paused attachment and request(0) with InvalidWorkerRequest; controls in those builds are restricted to use from one thread.

PBS retains ownership of each asset seed while building the asset with clone=true. Nested construction failures can therefore clean up without deleting the same space twice. This adds one space clone per asset during construction; search execution is unchanged.

Validation:

  • The complete 25,812-test Search suite passed during validation in a Debug build. After the final configuration checks were added, all 100 affected tests passed for three iterations each in both threaded and no-thread builds. The no-thread normal check target also passed.
  • Focused regressions cover nested construction failures and owned-space cleanup, initial and mid-search capacity-one pauses, resumed DFS/BAB enumeration, and paused DFS/RBS portfolio assets at capacities one and two.
  • Twelve concurrent resize trials cycling through zero to four workers each enumerated all 1,024 expected solutions.
  • The new construction and worker-control regressions are included in CMake and Autoconf check selections.

The Windows vcpkg job uses one current commit for both its checkout and builtin baseline. The previous baseline selected a GMP portfile referencing an MSYS2 autoconf archive that is no longer available.

@zayenz
zayenz force-pushed the feature/par-search-worker-adjustments branch from 5db14f4 to 5f9d5e0 Compare July 28, 2026 08:23
@zayenz zayenz changed the title Feature/par search worker adjustments Allow external adjustment of parallel search workers Jul 28, 2026
@zayenz
zayenz marked this pull request as ready for review July 28, 2026 13:57
Mikael Zayenz Lagerkvist added 5 commits August 20, 2026 08:48
Retain PBS asset seeds while builders clone them so nested construction failures cannot delete a seed twice. Honor worker-control pauses at sequential DFS/BAB search boundaries, preserving PBS stop wakeups. Reject unsupported pausing in builds without threads and controlled assets in sequential outer portfolios. Cover the failures, resumption, and placement rules in the search checks.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant