Skip to content

Get the number of threads in the Polars thread pool.

Source code

Description

The threadpool size can be overridden by setting the POLARS_MAX_THREADS environment variable before process start. It cannot be modified once polars is loaded. It is strongly recommended not to override this value as it will be set automatically by the engine.

Usage

pl$thread_pool_size()

Details

For compatibility with CRAN, the threadpool size is set to 2 by default. To disable this behavior and let the engine determine the threadpool size, one of the following ways can be used:

  • Enable the disable_limit_max_threads feature of the library. This can be done by setting the feature flag when installing the package. See the installation vignette (vignette(“install”, “polars”)) for details.
  • Set the polars.limit_max_threads option to FALSE with the options() function. Same as setting the POLARS_MAX_THREADS environment variable, this option must be set before loading the package.

Value

The number of threads

Examples

library("polars")

pl$thread_pool_size()
#> [1] 4