GCC Newspaper
JULY 29, 2026
gcc Proposed

Validation for an approach to PR115367

Proposes improving libgomp's OMP_DYNAMIC thread spawning by memoizing load average and optimizing when it's fetched.

This discussion proposes improvements to the libgomp implementation of OMP_DYNAMIC for thread spawning on Linux. The current approach uses glibc’s getloadavg with a 15-minute average, which has been criticized for its potentially too-long or too-short averaging window. The proposer suggests memoizing the load average to reduce overhead on short-lived parallel blocks and fetching it during GOMP_parallel_end instead of GOMP_parallel_start. Additionally, it’s suggested that using the 1, 5, and 15-minute averages along with program runtime could lead to a more optimal thread count.

In Details

This proposal addresses the dynamic thread management within libgomp, specifically the OMP_DYNAMIC runtime behavior. It aims to optimize the fetching and utilization of system load averages (via getloadavg) to determine the number of threads for OpenMP parallel regions. The core issues are the overhead of repeated system calls and the suitability of the averaging period for varying workloads.

For Context
OMP_DYNAMIC
An OpenMP runtime environment variable that controls whether the number of threads used in parallel regions can be dynamically adjusted by the runtime library.
libgomp
GCC's implementation of the OpenMP runtime library.
getloadavg
A POSIX function that returns the average system load over the last 1, 5, and 15 minutes.
PR115367
A bug report (Problem Report) concerning the limitations or desired improvements for OMP_DYNAMIC in libgomp.
Filed Under: OpenMPlibgompthreadingperformanceruntime