scala/akka performance versus java 7 fork/join
Asked Answered
G

1

5

I am new to Scala/Akka, although I am very well familiar with the concept of actor-based modeling. I am trying to parallelize an existing code for better performance, and I have two versions: one in Scala/Akka and one in Java 7's ForkJoinPool.

I was expecting that the actor-based approach should be faster, but the result is the other way round. It is something like 20 sec for Scala/Akka versus 17 sec for Java fork/join.

I'd like to know if akka is intrinsically slower? Or could it be because I am using the classes from the existing code written in normal Java in my both implementations?

Getter answered 21/8, 2012 at 11:53 Comment(3)
Why would expect the scala version to be faster than the lower level Java version? Higher level languages are almost always slower to run, but the reason you use them is that they can be much faster for the developer to write.Nudity
I expect akka to be faster because in actor models, you have a clear separation of memory for different actors, which could in principle help in avoiding cache misses and cache poisoning.Getter
I suspect fork join is doing the same thing in your your case, but with lower overhead.Nudity
P
7

Akka is using the ForkJoinPool in some of its implementations of its Actors framework (See Java 7 ForkJoinTask and Akka 2.0), so it is expected to be slower when running. In opposition, its made to be easier to work with on the developer side, you choose which side you prefer: development speed or running speed!

For the second question you might want to split it into another SO question.

Pulido answered 21/8, 2012 at 12:4 Comment(5)
OK. I agree that I should not expect Akka to be faster. But why at least the same speed? I mean the fact that Akka is based on Java, does not necessarily mean that it has to be slower.Getter
Thanks for the hint. I'll put the second question separately.Getter
@Getter When you build something on top of something else its almost always going to be slower. The only question is how much slower (can be from; you-can't-measure-it to OMG! )Nudity
Also, now try to add more nodes (jvms) to your app, and use Akka Actors vs Java Fork-Join, which model scales out?Javanese
@Klang good programmed Java on a 12 core will be very hard to beat by any kind of Cluster, because remote invocation is much slower AND Scala's remoting is very slow (based on unreliable multicast, tcp doesn't scale anyway) AND Akka is very overhyped. Design errors and the inherent inefficiency of Scala make it much slower than it could be.Urbannai

© 2022 - 2024 — McMap. All rights reserved.