xyncro / freya

Freya Web Stack - Meta-Package
https://freya.io
Other
330 stars 30 forks source link

Task or Hopac #52

Closed panesofglass closed 5 years ago

panesofglass commented 9 years ago

Should we consider Task or Hopac rather than Async? See performance comparisons. I would love to leverage Hopac, as it works with Tasks and also provides a very nice F# API. Task would be next on the list. OWIN already uses Task, so we are always having to map between Async and Task. I've considered doing the same for Frank for years and just never gone back through. In short, though, I think both Task and Hopac could provide better performance for non-IO internal processing.

panesofglass commented 9 years ago

@haf, I'd be interested in your thoughts here, as well. Are you and @ademar considering Hopac for Suave?

panesofglass commented 9 years ago

Task support can be found in F#x. I'm not certain as to its quality. @mausch, is the TaskBuilder in good shape?

kolektiv commented 9 years ago

I'm personally more than willing to consider an alternative to the underlying async aspect. It was my default choice as it seemed to make sense as a first attempt but I'd be delighted if something else better could be dropped in. To some extent I expected that most of the async stuff in a web framework would probably be doing IO, so I'm not sure what degree of gains we'd see from an alternative, but I'll also admit I really want to use Hopac for something. The only thing stopping me is a feeling that I don't understand it quite well enough not to do something silly yet. I still haven't actually finished the Reppy book on ConcurrentML, and I'm also still not totally sure of the right way to make Hopac interact with elements like Sockets, etc. in .NET. I would love to have a chat about that with @VesaKarvonen one day, although I should probably try some experiments first.

mausch commented 9 years ago

I'm not aware of anyone actually using the FSharpx Task CE. I'm not aware of any outstanding issues with it either. It sure would be nice to be able to abstract that away but F# just isn't powerful enough (unless you take the "inline everything" route or that other weird encoding of monads I always forget about).

haf commented 9 years ago

Yes, we are. https://github.com/SuaveIO/suave/issues/97#issuecomment-53071154

I haven't finished (or even started gasp!) the red book yet. But I have it close by ;) and will soon be too tempted to abstain any longer.

dsc_0025

kolektiv commented 9 years ago

It's probably worth an experimental branch at some point to see if we could come up with benchmarks (when we have some more stability, probably after I finish the major redesign of the underlying graph system!) It shouldn't be too hard to change our current monad which is basically AsyncState to be TaskState, especially given a sensible example of a Task monad to look at.

As with @mausch, I'd love a way of letting the type of concurrency/parallelism abstraction be parameterised, but yes, sadly not in our type system... Maybe F# 5.0? :)

kolektiv commented 9 years ago

@haf I'm glad I'm not the only one with that book sat making me feel guilty near my desk! I'm about half way through - and it's really good, I just have so much else to do!

panesofglass commented 9 years ago

I'm mostly done with the Reppy book. I still have some examples to read through. It's quite good. @VesaKarvonen left a note in the F# Web Stack discussion list about trade-offs to consider. Looks like we are on the same page: we all want to experiment further. Perhaps a maintained branch using Hopac Jobs? Should we investigate another using Task?

kolektiv commented 9 years ago

I think it would be great to have some branches experimenting with both, absolutely. My only concern with both is that they may require F# devs to know something more than async (with Task they're likely to be fairly familiar already, with Job maybe less so...) That's not going to stop some experimentation though, or at least I don't think it should!

panesofglass commented 9 years ago

Someone want to help out with this, perhaps do some investigation? /cc @VesaKarvonen @vasily-kirichenko

vasily-kirichenko commented 9 years ago

I'm not interested in web dev, so I'm not useful here.

kolektiv commented 9 years ago

Can't argue with that :) I think we'll leave this open for now though!

vasily-kirichenko commented 9 years ago

Sorry :)

panesofglass commented 9 years ago

No worries, @vasily-kirichenko. Thank you for responding. :)

polytypic commented 9 years ago

I find it difficult to say anything useful here. I wouldn't expect any major problems converting from async to job in this context. Happy to answer specific questions as always. As a first thing, I'd just replace Async<_> with Job<_> and start following compiler errors. I also wouldn't expect any major benefits from doing such a conversion - unless you are having performance issues with async or unless you have opportunities for concurrency/parallelism that could not be exploited with async. If you want to try Hopac—well, just try it. There is no obligation try it either. If everything is already working nicely then just move on.