get_recommended_threads: Get recommended number of threads for parallel operations

View source: R/memory_utils.R

get_recommended_threadsR Documentation

Description

Returns a recommended number of threads for parallel operations, based on available CPU cores and system load.

Usage

get_recommended_threads(use_fraction = 0.8)

Arguments

use_fraction

Numeric. Fraction of available cores to use (default 0.8). Using all cores (1.0) may overload the system.

Details

This function uses the C++ implementation to detect CPU cores and returns a conservative estimate leaving room for the OS and other processes.

Default behavior (use_fraction = 0.8):

  • 4 cores → 3 threads

  • 8 cores → 6 threads

  • 16 cores → 13 threads

Value

Integer with recommended number of threads (minimum 1)

See Also

get_cpu_cores

Examples


# Get recommended threads
threads <- get_recommended_threads()

# Use for OpenMP operations
options(BigDataStatMeth.threads = threads)

# More aggressive (use 90% of cores)
threads <- get_recommended_threads(use_fraction = 0.9)



BigDataStatMeth documentation built on May 15, 2026, 1:07 a.m.