- Notifications
You must be signed in to change notification settings - Fork3.1k
Revert ExecutionContext.global to not be a BatchingExecutor#9270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
lrytz commentedOct 23, 2020
Oh *?^!@#?#Q@ I didn't intend to merge this, I was on the wrong tab... This needs a follow-up at least in documentation, to tell people about the batching alternative and how to get it
Here is how users can create a batching EC instance in their codebase (code adapted from a draft by@viktorklang). Maybe this can be improved further, feedback welcome.2.13.x...lrytz:custom-batching-ec We also plan to ship the batching EC in scala-library-next. If preferred, we can revert this PR and re-submit it. |
viktorklang commentedOct 23, 2020
@lrytz I have multiple issues with the proposal:
|
lrytz commentedOct 26, 2020
My assumption is that the actual EC used in an application is always imported (or defined) by the application's own source code - is that wrong? Are there libraries out there that use an EC internally without requiring it to be provided as parameter? To me this would seem to be a problematic design; any application that doesn't use
Yes, we're making the
This looks reasonable to me, the risk of it causing problems in 2.13.x maintenance seems really low.
I agree this is a concern, but in my opinion the benefits of reverting |
viktorklang commentedOct 26, 2020
What people are recommended to do, and what they actually do, was what ended us up in this situation in the first place :)
BatchingExecutor might not be an issue, but leaking internal Promise implementation details is a bit of a no-starter since it completely prevents the implementation to evolve. Also consider ScalaJS.
I hope you're right! |
lrytz commentedOct 27, 2020
Two more things we can do:
|
viktorklang commentedOct 27, 2020
@lrytz Adding the |
lrytz commentedOct 28, 2020
This could be done with#8820 |
viktorklang commentedOct 29, 2020
lrytz commentedOct 29, 2020
That'd be welcome, thank you! |
viktorklang commentedOct 29, 2020
Revert ExecutionContext.global to not be a BatchingExecutor
Revert ExecutionContext.global to not be a BatchingExecutor
Uh oh!
There was an error while loading.Please reload this page.
NOTE This is a change in behaviour. If you make use of
scala.concurrent.ExecutionContext.globalyou maywant to adapt your code. Please note that Akka uses its own execution contexts (dispatchers) so is
unaffected.
In 2.13.0 we changed the behaviour of
ExecutionContext.globalso that it was more "opportunistic", byattempting to batch nested task and execute them on the same thread as the enclosing task. Unfortunately this
relies heavily on the correct usage of the
blocking { }wrapper on any long-running and/or blocking tasks;code that didn't could end up executing serially instead of in parallel. As we believe that correct usage of
blockingisn't as well followed as hoped we decided torevertExecutionContext.globalto its 2.12behaviour and introduce
ExecutionContext.opportunisticfor users that want to switch to it.In order to maintain forwards and backwards binary compatibility of the scala standard library, the usage
instructions require some indirection. Library authors can use the opportunistic execution context for all
Scala 2.13.x versions like so:
While application authors just need to gain access to the
private[scala]field, which they can do by:objectin thescalapackage (example below).private[scala]is emitted aspublicin Java bytecode.For example (option 1):
Links:
Fixesscala/bug#12089