Control over parallelism

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.

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

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 GitHub - scala/scala-parallel-collections: Parallel collections standard library module for Scala 2.13+

And, information on configuring the parallelism is at Configuring Parallel Collections | Parallel Collections | Scala Documentation

1 Like

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

A couple of relevant tickets.