-
Notifications
You must be signed in to change notification settings - Fork 520
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Find a nice way of configuring the compute pool in IOApp #1238
Comments
Related to #1227 |
I'd also request that we need some way to do more overriding to the pool than just counts. For example, it's very important for me at least that the pool has mxbeans exposed for metric collection. If those aren't built in, I'd need to swap in a pool that had them |
@Daenyth Would you mind opening an issue for what you would like to see exposed in the mxbeans? |
So one thought here is that |
@djspiewak It'd still need to be @volatile to ensure visibility of modifications (i.e. establish HB-edges). Also, it is likely that you'll risk having check-then-act problems, necessitating a critical section(s) with mutual exclusion, which introduces the risk of deadlocks. In general, using deferencing as a decision-mechanism has not been a great experience for me in concurrency settings. |
@viktorklang It would definitely be race-condition-y, but I think that's solvable, particularly since this is one of those things that only happens once per JVM. I definitely agree with you that dereference-based decisioning is usually awful but, because this is a thing that happens right at the beginning of the JVM startup, it might be okay. The alternative is pretty bad, tbh. Like either we don't have the ability to configure the global runtime outside of system properties (i.e. the situation we have right now), or we have to split the |
@djspiewak Indeed. I had to go through the same kind of process when I worked on the |
In this case, I think we have one lever that you didn't have with |
@djspiewak If you control main you could probably install a ThreadLocal to identify that you were initialized via the main method? (As opposed to having to do stack-walking to figure that out). |
@viktorklang Oh actually I was thinking of something sneakier than that! object IORuntime {
@volatile
private[effect] var _global: IORuntime = null
lazy val global: IORuntime = {
// this, but you know, atomic and stuff
if (_global == null)
_global = new IORuntime(System.getProperty("config.option"))
else
_global
}
}
trait IOApp {
protected val ConfigOption = System.getProperty("configOption")
def main(args: Array[String]): Unit = {
val runtime = new IORuntime(ConfigOption)
IORuntime._global = runtime
// ...
}
} With this setup, users can |
@djspiewak I'd probably make |
Agreed. That's much nicer than directly mutating a var |
Some applications will perform better with slightly different thread counts within the compute pool. Notably, @viktorklang has discussed how, in many of his tests, JVM applications behave better when the compute pool runs closer to 70% of available cores rather than the 100% we default to. Whether or not this is the case for any given application depends on a lot of factors, including how much data is being pushed through the caches, how good the cache utilization is, how much allocation is being done, and the exact implementation of hyperthreading available (or unavailable) on the host system. All in all, we can't really detect these factors, so it's better for us to, in the end, make it configurable.
This would be similar to the ce2
IOApp.WithContext
, but maybe a little nicer. Note that, in order to do this properly, we're going to need to adjustcreateDefaultComputeThreadPool
somewhat so that users can actually construct a work-stealing pool with a non-default thread count.The text was updated successfully, but these errors were encountered: