gix_features::parallel

Function optimize_chunk_size_and_thread_limit

Source
pub fn optimize_chunk_size_and_thread_limit(
    desired_chunk_size: usize,
    num_items: Option<usize>,
    thread_limit: Option<usize>,
    available_threads: Option<usize>,
) -> (usize, Option<usize>, usize)
Available on crate feature parallel only.
Expand description

Return the ‘optimal’ (size of chunks, amount of threads as Option, amount of threads) to use in in_parallel() for the given desired_chunk_size, num_items, thread_limit and available_threads.

  • desired_chunk_size is the amount of items per chunk you think should be used.
  • num_items is the total amount of items in the iteration, if Some. Otherwise this knowledge will not affect the output of this function.
  • thread_limit is the amount of threads to use at most, if Some. Otherwise this knowledge will not affect the output of this function.
  • available_threads is the total amount of threads available, if Some. Otherwise the actual amount of available threads is determined by querying the system.

Note that this implementation is available only if the parallel feature toggle is set.