in_place_scope
and in_place_scope_fifo
are variations of scope
and scope_fifo
, running the initial non-Send
callback directly on the current thread, rather than moving execution to the thread pool.IntoParallelIterator
.FromParallelIterator
make it possible to collect
complicated nestings of items.FromParallelIterator<(A, B)> for (FromA, FromB)
works like unzip
.FromParallelIterator<Either<L, R>> for (A, B)
works like partition_map
.Range
and RangeInclusive
.FromParallelIterator
and ParallelExtend
for Vec<T>
now uses MaybeUninit<T>
internally to avoid creating any references to uninitialized data.ParallelBridge
fixed a bug with threads missing available work.Thanks to all of the contributors for this release!
rustc
is now 1.36.Thanks to all of the contributors for this release!
flat_map_iter
and flatten_iter
methods can be used to flatten sequential iterators, which may perform better in cases that don't need the nested parallelism of flat_map
and flatten
.par_drain
method is a parallel version of the standard drain
for collections, removing items while keeping the original capacity. Collections that implement this through ParallelDrainRange
support draining items from arbitrary index ranges, while ParallelDrainFull
always drains everything.positions
method finds all items that match the given predicate and returns their indices in a new iterator.IntoParallelIterator for Range<char>
and RangeInclusive<char>
with the same iteration semantics as Rust 1.45.scope
closure.Thanks to all of the contributors for this release!
Vec
now drops any partial writes while unwinding, rather than just leaking them. If dropping also panics, Rust will abort.IndexedParallelIterator::step_by()
adapts an iterator to step through items by the given count, like Iterator::step_by()
.ParallelSlice::par_chunks_exact()
and mutable equivalent ParallelSliceMut::par_chunks_exact_mut()
ensure that the chunks always have the exact length requested, leaving any remainder separate, like the slice methods chunks_exact()
and chunks_exact_mut()
.Thanks to all of the contributors for this release!
IntoParallelIterator
, creating a MultiZip
iterator that produces items as similarly-shaped tuples.--cfg=rayon_unstable
supporting code for rayon-futures
is removed.rustc
is now 1.31.Thanks to all of the contributors for this release!
Send
bounds have been added for the Item
and Error
associated types on all generic F: Future
interfaces. While technically a breaking change, this is a soundness fix, so we are not increasing the semantic version for this.--cfg=rayon_unstable
supporting code will be removed in rayon-core 1.7.0
. This only supported the now-obsolete Future
from futures 0.1
, while support for std::future::Future
is expected to come directly in rayon-core
-- although that is not ready yet.Thanks to all of the contributors for this release!
Thanks to all of the contributors for this release!
ParallelIterator::copied()
converts an iterator of references into copied values, like Iterator::copied()
.ParallelExtend
is now implemented for the unit ()
.rustc
is now 1.28.Thanks to all of the contributors for this release!
spawn_fifo()
and scope_fifo()
global functions, and their corresponding ThreadPool
methods.join
are not affected.breadth_first
configuration flag, which globally approximated this effect, is now deprecated.ThreadPoolBuilder
can now take a custom spawn_handler
to control how threads will be created in the pool.ThreadPoolBuilder::build_scoped()
uses this to create a scoped thread pool, where the threads are able to use non-static data.std::thread
.ParallelIterator
has 3 new methods: find_map_any()
, find_map_first()
, and find_map_last()
, like Iterator::find_map()
with ordering constraints.ParallelIterator::panic_fuse()
makes a parallel iterator halt as soon as possible if any of its threads panic. Otherwise, the panic state is not usually noticed until the iterator joins its parallel tasks back together.IntoParallelIterator
is now implemented for integral RangeInclusive
.Folder
s now have optimized consume_iter
implementations.rayon_core::current_thread_index()
is now re-exported in rayon
.rustc
is now 1.26, following the update policy defined in RFC 3.Thanks to all of the contributors for this release!
ParallelExtend
is now implemented for tuple pairs, enabling nested unzip()
and partition_map()
operations. For instance, (A, (B, C))
items can be unzipped into (Vec<A>, (Vec<B>, Vec<C>))
.ParallelExtend<(A, B)>
works like unzip()
.ParallelExtend<Either<A, B>>
works like partition_map()
.ParallelIterator
now has a method map_init()
which calls an init
function for a value to pair with items, like map_with()
but dynamically constructed. That value type has no constraints, not even Send
or Sync
.for_each_init()
is a variant of this for simple iteration.try_for_each_init()
is a variant for fallible iteration.Thanks to all of the contributors for this release!
ParallelBridge
trait with method par_bridge()
makes it possible to use any Send
able Iterator
in parallel!rayon::prelude
.Item
s across the thread pool. Iteration order is not preserved by this adaptor.par_iter()
should still be preferred when possible for better efficiency.ParallelString
now has additional methods for parity with std
string iterators: par_char_indices()
, par_bytes()
, par_encode_utf16()
, par_matches()
, and par_match_indices()
.ParallelIterator
now has fallible methods try_fold()
, try_reduce()
, and try_for_each
, plus *_with()
variants of each, for automatically short-circuiting iterators on None
or Err
values. These are inspired by Iterator::try_fold()
and try_for_each()
that were stabilized in Rust 1.27.Range<i128>
and Range<u128>
are now supported with Rust 1.26 and later.rayon-core
now only depends on rand
for testing.Thanks to all of the contributors for this release!
rayon::iter::split()
.Thanks to all of the contributors for this release!
ParallelIterator
added the update
method which applies a function to mutable references, inspired by itertools
.IndexedParallelIterator
added the chunks
method which yields vectors of consecutive items from the base iterator, inspired by itertools
.String
now implements FromParallelIterator<Cow<str>>
and ParallelExtend<Cow<str>>
, inspired by std
.()
now implements FromParallelIterator<()>
, inspired by std
.ThreadPoolBuilder
replaces and deprecates Configuration
.ThreadPoolBuildError
type, rather than Box<Error>
, and this type implements Send
and Sync
.ThreadPool::new
is deprecated in favor of ThreadPoolBuilder::build
.initialize
is deprecated in favor of ThreadPoolBuilder::build_global
.IndexedParallelIterator::len
and ParallelIterator::opt_len
now operate on &self
instead of &mut self
.IndexedParallelIterator::collect_into
is now collect_into_vec
.IndexedParallelIterator::unzip_into
is now unzip_into_vecs
.Configuration
and initialize
from rayon-core.Thanks to all of the contributors for this release!
Configuration
now has a build
method.ParallelIterator
added flatten
and intersperse
, both inspired by itertools.IndexedParallelIterator
added interleave
, interleave_shortest
, and zip_eq
, all inspired by itertools.iter::empty
and once
create parallel iterators of exactly zero or one item, like their std
counterparts.iter::repeat
and repeatn
create parallel iterators repeating an item indefinitely or n
times, respectively.join_context
works like join
, with an added FnContext
parameter that indicates whether the job was stolen.Either
(used by ParallelIterator::partition_map
) is now re-exported from the either
crate, instead of defining our own type.Either
also now implements ParallelIterator
, IndexedParallelIterator
, and ParallelExtend
when both of its Left
and Right
types do.Debug
.Clone
where possible.The spawn_future()
method has been refactored into its own rayon-futures
crate, now through a ScopeFutureExt
trait for ThreadPool
and Scope
. The supporting rayon-core
APIs are still gated by --cfg rayon_unstable
.
rayon-core
, but since they're fixing soundness bugs, we are considering these minor changes for semver.Scope::spawn
now requires Send
for the closure.ThreadPool::install
now requires Send
for the return value.iter::internal
module has been renamed to iter::plumbing
, to hopefully indicate that while these are low-level details, they‘re not really internal or private to rayon. The contents of that module are needed for third-parties to implement new parallel iterators, and we’ll treat them with normal semver stability guarantees.rayon::iter::split
is no longer re-exported as rayon::split
.Thanks to all of the contributors for this release!
ParallelSliceMut
now has six parallel sorting methods with the same variations as the standard library.par_sort
, par_sort_by
, and par_sort_by_key
perform stable sorts in parallel, using the default order, a custom comparator, or a key extraction function, respectively.par_sort_unstable
, par_sort_unstable_by
, and par_sort_unstable_by_key
perform unstable sorts with the same comparison options.rayon::spawn()
-- spawns a task into the Rayon threadpool; as it is contained in the global scope (rather than a user-created scope), the task cannot capture anything from the current stack frame.ThreadPool::join()
, ThreadPool::spawn()
, ThreadPool::scope()
-- convenience APIs for launching new work within a thread-pool.#[must_use]
for_each_with
adapter, similar to map_with
.#[cfg]
flag. This means that to see the unstable APIs, you must do RUSTFLAGS='--cfg rayon_unstable' cargo build
. This is intentionally inconvenient; in particular, if you are a library, then your clients must also modify their environment, signaling their agreement to instability.map_with
and fold_with
combinators, which help for passing along state (like channels) that cannot be shared between threads but which can be cloned on each thread split.while_some
combinator, which helps for writing short-circuiting iterators.Option<T>
or Result<T, E>
into a Option<Collection<T>>
or Result<Collection<T>, E>
.FromParallelIterator
for Cow
.BoundedParallelIterator
and ExactParallelIterator
traits, which were not serving much purpose.Send
impls.spawn_async
and spawn_future_async
-- which spawn tasks that cannot hold references -- to simply spawn
and spawn_future
, respectively.current_thread_index
, for querying the index of the current worker thread within its thread-pool (previously available as thread_pool.current_thread_index()
);current_thread_has_pending_tasks
, for querying whether the current worker that has an empty task deque or not. This can be useful when deciding whether to spawn a task.RAYON_NUM_THREADS
and RAYON_LOG
. The older variables (e.g., RAYON_RS_NUM_CPUS
are still supported but deprecated).Thanks to the following contributors:
This release is a targeted performance fix for #343, an issue where rayon threads could sometimes enter into a spin loop where they would be unable to make progress until they are pre-empted.
This release marks the first step towards Rayon 1.0. For best performance, it is important that all Rayon users update to at least Rayon 0.7. This is because, as of Rayon 0.7, we have taken steps to ensure that, no matter how many versions of rayon are actively in use, there will only be a single global scheduler. This is achieved via the rayon-core
crate, which is being released at version 1.0, and which encapsulates the core schedule APIs like join()
. (Note: the rayon-core
crate is, to some degree, an implementation detail, and not intended to be imported directly; it's entire API surface is mirrored through the rayon crate.)
We have also done a lot of work reorganizing the API for Rayon 0.7 in preparation for 1.0. The names of iterator types have been changed and reorganized (but few users are expected to be naming those types explicitly anyhow). In addition, a number of parallel iterator methods have been adjusted to match those in the standard iterator traits more closely. See the “Breaking Changes” section below for details.
Finally, Rayon 0.7 includes a number of new features and new parallel iterator methods. As of this release, Rayon's parallel iterators have officially reached parity with sequential iterators -- that is, every sequential iterator method that makes any sense in parallel is supported in some capacity.
Producer
trait now features fold_with
, which enables better performance for some parallel iterators.par_split()
and par_split_whitespace()
.Configuration
API is expanded and simplified:num_threads(0)
no longer triggers an errorConfiguration::thread_name
.find_first()
, find_last()
, position_first()
, and position_last()
.rev()
, which primarily affects subsequent calls to enumerate()
.scope()
API is now considered stable (and part of rayon-core
).rayon::split
function for creating custom Rayon parallel iterators.weight
mechanism, which is deprecated.sum()
and friends now use the standard Sum
traitsIn the move towards 1.0, there have been a number of minor breaking changes:
Configuration::set_num_threads()
lost the set_
prefix, and hence become something like Configuration::num_threads()
.Configuration
getters are removedrayon::iter
, e.g. rayon::iter::Filter
rayon::slice::Windows
sum()
or product()
, type annotations are needed for the result since it is now possible to have the resulting sum be of a type other than the value you are iterating over (this mirrors sequential iterators).Experimental features require the use of the unstable
feature. Their APIs may change or disappear entirely in future releases (even minor releases) and hence they should be avoided for production code.
Scope::spawn_future
or rayon::spawn_future_async()
.rayon::spawn_async()
function for using the Rayon threadpool to run tasks that do not have references to the stack.Thanks to the following people for their contributions to this release:
This release includes a lot of progress towards the goal of parity with the sequential iterator API, though there are still a few methods that are not yet complete. If you'd like to help with that effort, check out the milestone to see the remaining issues.
Announcement: @cuviper has been added as a collaborator to the Rayon repository for all of his outstanding work on Rayon, which includes both internal refactoring and helping to shape the public API. Thanks @cuviper! Keep it up.
collect()
and not just collect_with()
. You can use collect()
to build a number of collections, including vectors, maps, and sets. Moreover, when building a vector with collect()
, you are no longer limited to exact parallel iterators. Thanks @nikomatsakis, @cuviper!skip()
and take()
on parallel iterators. Thanks @martinhath!min()
and max()
. We also support min_by_key()
and max_by_key()
. Thanks @tapeinosyne!mul()
method is now renamed to product()
, to match sequential iterators. Thanks @jonathandturner!u64
values. Thanks @cuviper!par_chars()
method on strings for iterating over characters in parallel. Thanks @cuviper!reduce()
functionality now has better inlining. Thanks @bluss!join()
function now has some documentation. Thanks @gsquire!reduce
method has been vastly simplified, and reduce_with_identity
has been deprecated.fold
method has been changed. It used to always reduce the values, but now instead it is a combinator that returns a parallel iterator which can itself be reduced. See the docs for more information.find_any()
: similar to find
on a sequential iterator, but doesn't necessarily return the first matching itemposition_any()
: similar to position
on a sequential iterator, but doesn't necessarily return the index of first matching itemany()
, all()
: just like their sequential counterpartscount()
combinator is now available for parallel iterators.thread_local!
.scope()
API implementation.rayon::scope
for details.unstable
.rayon-demo
.num_cpus
to 1.0. Thanks @jamwt!chain
combinator for parallel iterators.Option
, Result
, as well as many more collection types now have parallel iterators.Thanks to @cuviper, @edre, @jdanford, @frewsxcv for their contributions!
cloned()
and inspect()
combinators.Thanks to @areilb1, @Amanieu, @SharplEr, and @cuviper for their contributions!
par_iter
APIs now available:into_par_iter
is now supported on vectors (taking ownership of the elements)Configuration
object to control number of threads and other detailscargo run --release -- visualize
in demo/nbody
:)+=
syntaxThanks to @bjz, @cuviper, @Amanieu, and @willi-kappler for their contributions!
No release notes were being kept at this time.