Hi,
i've looked briefly at Java project Loom : https://www.youtube.com/watch?v=J31o0ZMQEnI
If i understand correctly the project is exploring the application of using fiber to schedule computations instead of the threadpool, this would make all code automatically "async" optimized, because no thread would be stuck waiting, but just a fiber.
Is this concept been investigated on clr as an alternative to TPL/async-await ?
What would be the advantage of having two different ways of achieving the same goal?
that fibers require no code change, returning task is viral
@valeriob Right, that's the advantage of fibers, but that's not what I'm asking.
At this point, pretty much all libraries and presumably most applications that would benefit from this have already been converted to async
-await
. How does it make sense to introduce fibers at this point, especially since it would probably mean we would be stuck with having to deal with both kinds of dealing with asynchony (or all 4, if you count APM and EAP)?
Is this concept been investigated on clr as an alternative to TPL/async-await ?
Yes, this concept has been investigated in depth when the Task APIs were introduced originally and discussed number of times since then.
Some of the challenges with fibers are:
It would be certainly nice in some cases to not worry about whether to make method async or not. For better or worse, .NET choose to have explicit annotations for what needs to be async.
Our current thinking is keep improving efficiency async methods . For example, one async method cannot really be inlined into another async method today by the JIT. It is something we would like to fix.
Thanks @jkotas ! I was asking exactly about the trade of that was chosen, if fibers where investigated/prototyped 馃槃
Do you know of any language that has implemented it ? I though that those where solved problem, at least for the BEAM vm.
Do you know of any language that has implemented it?
golang
golang
Thanks i did know that, that explains a lot 馃槃
Java is also looking to adopt green threads with OpenJDK Loom. They make the argument that async-specific APIs and language features are workarounds for the real problem, that blocking threads is bad because threads are so expensive. Async APIs and language features are also "viral" and create the situation of "function colors" where your sync code and async code should never mix, which is true in C#.
I'm not going to make the argument that the CLR or C# should change tact here, but I think it's very interesting to see what Java is doing in this space. The early access builds show a lot of promise.
Most helpful comment
Yes, this concept has been investigated in depth when the Task APIs were introduced originally and discussed number of times since then.
Some of the challenges with fibers are:
It would be certainly nice in some cases to not worry about whether to make method async or not. For better or worse, .NET choose to have explicit annotations for what needs to be async.
Our current thinking is keep improving efficiency async methods . For example, one async method cannot really be inlined into another async method today by the JIT. It is something we would like to fix.