3 ms·
Java's "stream fusion" is inspired by the same technique that was originally implemented, I believe, in Haskell [1]. [1] http://fun.cs.tufts.edu/stream-fusion.
by atombender 6y ago
Java's "stream fusion" is inspired by the same technique that was originally implemented, I believe, in Haskell [1].
[1] http://fun.cs.tufts.edu/stream-fusion.pdf http://fun.cs.tufts.edu/stream-fusion.pdf
- chrisseaton 6y agoBut Java doesn't do stream fusion as you're describing. It does conventional inlining and combining loop bodies, which can in some trivial cases achieve the same effect, but these are techniques you'd find in any compiler or even an 80s text book - they didn't come from Haskell. Here's the limitation of Java's 'fusion' - you'll notice there's no pass to do this in Hotspot - it just happens due to the inlining and GCM passes. https://github.com/openjdk/jdk/blob/883a4f65b9b1533c8a51d156640020ae0f87f263/test/micro/org/openjdk/bench/java/util/stream/pipeline/PipelineParMultiple.java https://github.com/openjdk/jdk/blob/883a4f65b9b1533c8a51d156... And here's a paper on trying to add actual Fusion to Java, which they wouldn't be doing if Java had it already. https://dl.acm.org/doi/pdf/10.1145/3355378.3355386?download=true https://dl.acm.org/doi/pdf/10.1145/3355378.3355386?download=...