Skip to content

Adaptive parallelism: read current memory use from the operating system instead of the last garbage collection #7873

Done

Description

@thomhurst

Summary

Adaptive parallelism (#7871, PR #7872) decides whether memory is under pressure from GC.GetGCMemoryInfo(). The runtime updates that reading only at a garbage collection, and it is zero before the first one. When tests start memory-heavy child processes or containers while the test process itself allocates little, the reading is out of date: the limit can be raised while the machine is short of memory, or keep being lowered after the pressure has gone.

Proposal

Read current memory use from the operating system at each sample, and keep the runtime's reading as the fallback:

  • Linux: MemAvailable from /proc/meminfo, and the cgroup memory limit and usage when the process runs in a container.
  • Windows: GlobalMemoryStatusEx.
  • macOS: the kern.memorystatus_vm_pressure_level sysctl.

When no reading is available, the policy should not treat that as headroom for raising the limit.

Where

AdaptiveParallelismController.ReadMemoryLoad in src/TUnit.Engine/Scheduling/AdaptiveParallelismController.cs. The limitation is described in docs/docs/execution/parallelism.md under Adaptive Parallelism; remove that paragraph when this is done.

Raised by review on #7872.

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

    P3enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions