less_slow.cpp icon indicating copy to clipboard operation
less_slow.cpp copied to clipboard

Memory issue with `sorting_with_executors`

Open alexbarev opened this issue 9 months ago • 5 comments

  1. Run sorting_with_executors benchmark using the std::execution::par_unseq policy.

  2. Memory consumption quickly exceeds my machine's availability of 60GB after the second test variant finishes: sorting_with_executors/par_unseq/4194304/

Observations:

  1. Memory does not decrease between tests with inputs of different sizes.

  2. I tried moving the policy inside the loop, but it did not resolve the issue:

    for (auto _ : state) {
        auto local_policy = std::execution::par_unseq; // Create policy here
        std::reverse(local_policy, array.begin(), array.end());
        std::sort(local_policy, array.begin(), array.end());
        bm::DoNotOptimize(array.size());
        bm::DoNotOptimize(local_policy); // even tried this just in case
    }
    
  3. I noticed that only 16 threads are spawned, which matches the number of available CPU's. The issue is puzzling, and I am yet to understand its root cause.

alexbarev avatar Jan 05 '25 20:01 alexbarev