Skip to content

Apply parallel worker memory budgets on Windows - #2035

Merged
Mister-Meeseeks merged 1 commit into
CrocSwap:mainfrom
Tairitsu-Aya:codex/windows-memory-worker-budget
Oct 15, 2026
Merged

Mister-Meeseeks merged 1 commit into
CrocSwap:mainfrom
Tairitsu-Aya:codex/windows-memory-worker-budget

Conversation

@Tairitsu-Aya

@Tairitsu-Aya Tairitsu-Aya commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Change and mathematical scope

Native Windows has no os.sysconf, so run_parallel.memory_gib() returned None and the default worker count ignored the documented three-GiB-per-worker budget. On the tested Windows host, the old code chose 32 workers; querying 31.297 GiB of physical RAM now selects 10. The shared verify_parallel.default_jobs() also receives the detected capacity.

Use the standard-library ctypes binding to GlobalMemoryStatusEx, with the SDK's fixed-width fields and initialized structure length. Preserve the POSIX query, explicit JOBS overrides and unknown-memory fallback. This restores the existing total physical memory heuristic; it is not a free-memory reservation or a hard resource limit. No scientific input, certificate, selected result or kappa changes.

Task and overlap

Validation

The new tests produced five failures against the unchanged base implementation. After the fix:

Environment Check Result
Windows, CPython 3.12.9 python -X utf8 -B -m unittest discover -s tests -p test_parallel_memory.py -v 11 pass, including the real Windows API
Windows, CPython 3.14.2 Same command 11 pass
Ubuntu 24.04 under WSL, CPython 3.12.3 python3 -B -m unittest discover -s tests -p 'test_parallel*.py' -v 17 tests, one Windows-only smoke test skipped; all others pass

Controls cover a fractional capacity above 4 GiB, total versus available memory, API failure with a populated buffer, zero/unknown capacity, CPU and minimum-worker bounds, explicit overrides, and the shared isolated-group budget. The existing Windows-safe scheduler tests also pass (four tests covering overrides, failure propagation, snapshots and invalid CLI/group inputs).

python -X utf8 -B scripts/research_baseline.py, python -X utf8 -B scripts/verify_selected_result.py and git diff --check pass. The source-bound baseline reports the unchanged selected record. No heavy audit workers were launched for the scheduler comparison. Full historical/mathematical replay was not run for this tooling-only change. Hosted CI is separate from these local results.

Hosted CI currently requires maintainer approval: Verify research artifacts reports action_required with no jobs executed. The local results above do not claim hosted CI success.

Credit

Retain the existing Apache-2.0 notice and credit eumemic's PR154 worker policy and the integrated maintenance work. API layout and return semantics follow Microsoft's MEMORYSTATUSEX and GlobalMemoryStatusEx documentation. Prepared for Tairitsu-Aya with substantial OpenAI Codex assistance.

Open next questions

This is an existing-tool repair, not a new research package. Accounting for competing processes, free RAM or container/job-object limits would require a separate scheduling-policy change; this patch preserves the current total-memory policy.

@Mister-Meeseeks
Mister-Meeseeks merged commit 06164c0 into CrocSwap:main Oct 15, 2026
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.

2 participants