Skip to content

xtask on Windows sizes CI from PowerShell's RAM numbers and ignores the job memory limit #3705

Open

Description

@THEtheChad

Follows #3652 (PR #3654, Windows RAM and job limits in lightcraft-sysmem), itself on #3072 (PR #3118, cgroup limits).

Summary

On Windows, cargo xtask ci sizes its build jobs and test threads without looking at the job object it runs in. Both of xtask's memory readings go through PowerShell, and neither sees a job memory limit:

  • Available RAM (available_ram_mb): Win32_PerfFormattedData_PerfOS_Memory.AvailableMBytes, the machine's free memory. CI uses this first to size its build jobs (ci_jobs: one per 1.5 GB).
  • Total RAM (total_ram_gb): Win32_ComputerSystem.TotalPhysicalMemory, the installed RAM. CI falls back to half of this when available RAM can't be read, and the CI report records it as ram_total_gb.

So a CI runner, container or sandbox that starts xtask in a job with a memory limit gets as many jobs as the whole machine would. For example, a 64 GB machine with 40 GB free and an 8 GB job limit gets 26 jobs (capped at the CPU count) instead of about 5. Allocations past the limit fail, so the build or the tests then die partway through. That is the out-of-memory failure #3072 fixed on Linux.

On Linux, #3118 already moved xtask to lightcraft_sysmem::effective_total() / available(). #3654 adds the Windows job limit to effective_total() and the new job_limit(), but leaves xtask on PowerShell. Its description lists this as a follow-up.

Evidence (fix/3652-windows-memory 609bff3)

  • xtask/src/ci.rs:26-27: on Windows, available_ram_mb runs powershell … AvailableMBytes, which counts the whole machine.
  • xtask/src/ci.rs:48-49: on Windows, total_ram_gb runs powershell … (Get-CimInstance Win32_ComputerSystem).TotalPhysicalMemory, which is also the whole machine.
  • xtask/src/main.rs:134: available_ram_mb().or_else(|| total_ram_gb() … / 2) then ci_jobs(…). Neither reading is held to a job limit.

Proposed fix

  • Total: total_ram_gb uses lightcraft_sysmem::effective_total() on Windows as on Linux, which gives min(RAM, job limit). The PowerShell query for the total goes away. When nothing can be read, the result is None, as today, and CI keeps its default of 4 jobs.
  • Available: sysmem has no Windows available(), so xtask keeps PowerShell's AvailableMBytes for the machine's free memory. It holds that number to the job limit (job_limit()). This is an upper bound: Windows' job query here doesn't report how much the job already uses.
  • Tests: keep the decision logic in pure functions that are tested on every platform. Add a Windows-only test that total_ram_gb matches effective_total().

Activity

  1. ticket-craft commented on Nov 3, 2026

    @ticket-craft

    Possibly related: #3072 and #3652.

  2. added 3 commits that reference this issue on Nov 3, 2026
  3. added 7 commits that reference this issue on Nov 9, 2026
  4. added 4 commits that reference this issue on Nov 20, 2026
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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions