Skip to main content

max_parallelism

Function max_parallelism 

Source
pub fn max_parallelism() -> NonZeroUsize
Expand description

Returns the maximum number of tasks that ty is allowed to process in parallel.

Returns std::thread::available_parallelism, unless the environment variable TY_MAX_PARALLELISM or RAYON_NUM_THREADS is set. TY_MAX_PARALLELISM takes precedence over RAYON_NUM_THREADS.

Falls back to 1 if available_parallelism is not available.

Setting TY_MAX_PARALLELISM to 2 only restricts the number of threads that ty spawns to process work in parallel. For example, to index a directory or checking the files of a project. ty can still spawn more threads for other tasks, e.g. to wait for a Ctrl+C signal or watching the files for changes.