https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122878
Bug ID: 122878
Summary: [16 Regression] std::counting_semaphore performance
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
Target Milestone: ---
#include "benchmark/benchmark.h"
#include <semaphore>
#include <chrono>
void BM_counting_sema(benchmark::State& state) {
using namespace std::chrono;
for (auto _ : state)
{
benchmark::DoNotOptimize(csem.try_acquire_for(1ns));
}
}
BENCHMARK(BM_counting_sema);
BENCHMARK_MAIN();
Using this benchmark I see a major performance regression compared to gcc-15.
GCC 15:
-----------------------------------------------------------------
Benchmark Time CPU Iterations
-----------------------------------------------------------------
BM_counting_sema 2766 ns 2763 ns 256073
GCC 16:
-----------------------------------------------------------------
Benchmark Time CPU Iterations
-----------------------------------------------------------------
BM_counting_sema 61974 ns 8684 ns 80370