Skip to content
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

Improve Stream efficency #191

Open
jbgi opened this issue Sep 8, 2015 · 8 comments
Open

Improve Stream efficency #191

jbgi opened this issue Sep 8, 2015 · 8 comments

Comments

@jbgi
Copy link
Member

jbgi commented Sep 8, 2015

Stream is rather slow, we should probably switch to an implementation based on a fold algebra with fusion whenever possible.

@jbgi
Copy link
Member Author

jbgi commented Sep 8, 2015

https://www.cs.ox.ac.uk/ralf.hinze/publications/IFL10.pdf looks like a good read on the subject.
also scala/slip#17 may be of interest.

@clinuxrulz
Copy link
Contributor

Does anyone have a good benchmark for Streams?
Stream fusion looks very much like coroutines, but I'm guessing there is more to it.

@jbgi
Copy link
Member Author

jbgi commented Feb 15, 2016

A easy first step to improve perf would be to implement this change: scalaz/scalaz#1104

@jbgi
Copy link
Member Author

jbgi commented Mar 10, 2016

food for thought: http://jyp.github.io/posts/controlled-fusion.html

@jbgi
Copy link
Member Author

jbgi commented Mar 13, 2016

initial experiment show good results based on Mu/Nu lists from above. If no objection I will try to put something together. @clinuxrulz did you work on a design for stream fusion?

@clinuxrulz
Copy link
Contributor

No. I've been too busy at work unfortunately. I have nothing to contribute, you go ahead with your implementation.

@clinuxrulz
Copy link
Contributor

I haven't worked out how to do stream fusion in Java yet.

However I've got an implementation based on a stackless Coroutine with re-associated binds that emits values.

which is more or less like this in haskell

data StepF a next
  = Emit a next
  | Bind (forall b r. (Stream b -> (b -> Stream a) -> r) -> r)

newtype Stream2 a = Stream2 (Free (StepF a) Unit)

Heres the code:

https://github.com/clinuxrulz/functionaljava/blob/stream/core/src/main/java/fj/data/Stream2.java

I just need benchmarks to see if I've helped or hindered the situation.

@dimitarg
Copy link

dimitarg commented Jan 9, 2017

I think quite some work was done in RxJava2 on operator fusion, it might be interesting to whoever takes on this issue.
https://www.google.bg/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=rxjava%20operator%20fusion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants