Skip to content

[Engine] Report that macOS places the CPU expert workers - #7436

Open
macintog wants to merge 4 commits into
Niko1221:mainfrom
macintog:codex/up-pool-macos-placement-v0223
Open

macintog wants to merge 4 commits into
Niko1221:mainfrom
macintog:codex/up-pool-macos-placement-v0223

Conversation

@macintog

Copy link
Copy Markdown
Contributor

Problem and result

On macOS, Strata lists specific logical processors for the CPU expert workers and the host thread. With --pool-cores 0,1, it even warns that a worker competes with the host on processor 0. The macOS implementation of pin_thread_to_cpu() leaves placement to the scheduler.

On my M4 Max, the default pool and a pool started with --pool-cores 0,1 now report, respectively:

15 pool workers. macOS places the workers and the host thread
2 pool workers. macOS places the workers and the host thread (--pool-cores is used only for sizing)

Related discussion

None.

Approach

On macOS, ExpertPool sets pin = false, and generate.cpp omits its separate processor list. --pool-cores still sets the default worker count from the distinct usable entries. Invalid IDs can warn and are dropped. If none are usable, automatic sizing applies. A positive --pool-workers overrides the count.

The host-collision check now runs only when the pool pins threads. Windows and Linux engine starts still request pinning. Tests and bwg_pool_bench --pin 0 can request an unpinned pool.

Engine and Terminal help, the config docstring, docs/TERMINAL_LAUNCH.md and docs/DETAILS.md explain macOS sizing. The Metal build now registers pool_cores_test.

Validation

Passed:

  • At dd56c0ecf, rebased onto v0.2.23 (4560d0379), I built and linked strata and pool_cores_test on an M4 Max with macOS 27.3, Apple Clang 21.0.0 and Release Metal (-DSTRATA_OWN_CPU_QUANT=ON -DSTRATA_BUILD_TESTS=ON).
  • pool_cores_test reported 16 logical processors and passed. Its two-worker default printed the macOS message, and the list 3,1 added the sizing note. strata --help showed the macOS text for --host-core and --pool-cores. python tools/settings_register.py --check exited 0.
  • Earlier standalone pool checks on an M4 Max (15 workers) and M2 (7 workers) printed the new placement text and dropped the warning for 0,1. That build also included the Windows process-mask and one-CPU-default changes.

Failed: Stock 58ee32277 printed processor lists on both Macs and warned about processor 0 for 0,1.

Not run: Windows or Linux builds, or full engine startup with a model. I only compiled the change to the second startup line in generate.cpp.

Limits

Thread placement stays with macOS. The explicit_cores() comment in pool.hpp still implies pinning, and DETAILS.md scopes invalid-ID warnings to Windows and Linux even though macOS can emit them. I kept terminal/data/settings-register.json out of the diff to avoid line-number churn. Its check verifies setting names only.

On an M4 Max the default line claimed CPU 1 through 15 and host CPU 0. An explicit list containing CPU 0 also warned of a conflict. The macOS affinity implementation leaves the threads to the scheduler.

Report the count and how macOS places the threads. Register the CPU-only placement test in the Metal build: two placement checks failed before the change and both pass after it.
The M4 Max startup check found 15 workers, with no CPU pins. The engine help still promised exact processor placement. The linked Release executable now describes scheduler placement for both host and workers and the count supplied by a CPU list.
macOS places the host thread and the workers. The launch help, the
server config docstring and the --pool-cores section of DETAILS.md now
say that on macOS the list only sets the worker count, and DETAILS.md
scopes its pinning sentences to Windows and Linux.
On macOS the pool pins nothing, so it no longer warns about the host
thread's processor. Say where the warnings apply, and give the macOS
form of the start-up line beside placement_line().
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