Control over parallelism

#1

Why doesn’t the parallel method include an int parameter to influence the amount of parallelism the developer may want to use? It seems that the API is either spiking processor usage or working on a single thread but doesn’t allow for much in between.

#2

Sorry, which method is that? There once was a par method, but I think it’s gone.

Usually, methods that may use more than one thread take an ExecutionContext as an (often implicit) argument, and the ExecutionContext determines the amount of parallelism.

1 Like
#3

Only in a sense. As of Scala 2.13, to use .par you have to add a dependency on scala-parallel-collections and import an implicit. Details at https://github.com/scala/scala-parallel-collections#usage

And, information on configuring the parallelism is at https://docs.scala-lang.org/overviews/parallel-collections/configuration.html

1 Like
#4

P.S. Is there a reason you’re asking here and not on https://users.scala-lang.org? Is this in the context of some Scala contribution you’re working on?

3 Likes
#5

A couple of relevant tickets.