less_slow.cpp
                                
                                
                                
                                    less_slow.cpp copied to clipboard
                            
                            
                            
                        Memory issue with `sorting_with_executors`
- 
Run
sorting_with_executorsbenchmark using thestd::execution::par_unseqpolicy. - 
Memory consumption quickly exceeds my machine's availability of 60GB after the second test variant finishes:
sorting_with_executors/par_unseq/4194304/ 
Observations:
- 
Memory does not decrease between tests with inputs of different sizes.
 - 
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 } - 
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.