Programming is hard by Stephan Schmidt

Interesting picture: Benchmarking Erlang versus Java concurrency

I stumbled upon a nice Java framework called Kilim. It implements message passing in Java and it’s interesting to compare to Erlang:

kilim.gif

As I’ve said before, usually comparing Java to Erlang is stupid, because it compares threads to actors, not Java to Erlang. Comparing actors in Java to actors in Erlang is the right thing to do. Also see Scala (Which I don’t use because it won’t make it into the enterprise and I don’t like a type-inferencing language Update: Since then I’ve been playing with Scala quite a bit, like the inference but add type annotations in places where they usually are not needed but make it clearer to the developer what goes on).

If you liked this post, subscribe to my free full RSS feed.
Filed under: Erlang, Java

You can share this post!
Do you want to tell others about this article? Use the social bookmark icons to submit this artice to the service of your choice. Thanks.

Get free updates by email

If you did like this article you can get free updates with your RSS reader, you can follow me on Twitter or get free update to new posts by email. Enter your email:

 
About the author: Stephan has been working as a head of development and CTO. He has experiences in different technologies since 20 years including Java, Rails and Python. Stephans main field of interest is maintainablity and productivity in software development. Want to know more? All views are only his own.

Comments

Ken

Interesting. Suppose you could post another one that goes to, say, 100,000 “tasks”?

stephan

Sorry, the picture is from the Kilim developers. They have more on their site.

[...] Productivity in software development « Interesting picture: Benchmarking Erlang versus Java concurrency [...]

Sean

I think you may be right about Scala not ever being accepted as an Enterprise language.

Scala can perform type inference, but it doesn’t have to - you can always explicitly state the type. Also, Scala is statically typed. So, while you may elect to let Scala perform type inference, it doesn’t open the program to the potential liabilities of dynamically typed languages like Ruby, Perl or Python.

(I’m the author of the Kilim framework).

Ken asked about 100000 tasks. How about a million? Download and try it out.

http://kilim.malhar.net

This particular benchmark is about testing the speed of message passing. 3000 tasks == 9 million messages (each node passes a message to every other, and waits for a return message).

There’s another benchmark that measures task churn speeds (speed of creation and destruction). At the moment, Kilim’s faster than Erlang and Haskell.

–sriram.

stephan

@Siram: Thanks for commenting. I’ll give Kilim a try to get a feeling about it. Is there an abstraction planned on top of Kilim to make it easier for beginners?

E.g. have an abstract Actor class (Proxy?) where I can send messages to and which has a mailbox (and which does message passing to methods based on type/annotation/… ?

public MyActor extends Actor {

public void handleMyMessage(DeleteEvent event) {

}

public void handleMyOtherMessage(NewEvent event) {

}
}

I could use this actor with myActor.send(myDeleteEvent).

I’ll think about that.

@stephan,

No, I’m not planning to have any abstractions on top of it. I don’t want to fall into the standard java trap of creating yet another massive framework. I’d like all the essential API to fit within a few pages of text.

I’d prefer to cover most techniques as examples and pull it in as part of the framework only when some pattern catches on.

Also, when time permits, I’ll put in a few more examples to cover nio, standard eventing stuff etc. There’s a jetty example that works easily enought with Jetty’s continuations and I have rewritten the tjws webserver in terms of Kilim threads, but both need cleaning up to show as example code.

stephan

Ah, interesting. I thought the Java standard trap was a too low level abstraction - see Swing - which results in no one using it.

stephan

I would be interested in Kilim working with Jetty and Jersey - as a very fast REST service endpoint. Hmm. Or a very scalable one.

Tom Palmer

Um, those who don’t use Swing don’t use it because the font rendering is still too often lousy, because it’s hard to integrate with native widgets, and because it lacks too many useful widgets. I agree with Sriram’s opinion on the value of core functionality. Other people can make frameworks as they see fit. (I think a new Java web framework is invented just about every week.)

stephan

“[...] because it’s hard to integrate with native widgets [...]”

My personal, often disputed opinion, with the web, itunes, chrome, AIR (tweetdeck) native widgets are most often not important anymore.

Fred

> “and it’s interesting to compare to Erlang”

When can a single micro benchmark taken out of context without corresponding source code and compiler options ever be considered “interesting”?

It is however quite interesting to note that concurrency oriented programming seems to gain in popularity.

stephan

@Fred: How can it not be interesting? Perhaps were interested by different things.

I find it interesting if something unusual happens that goes against common wisdom.

If it’s a micro benchmark, I’m interested why the micro benchmark behaves in such a way. I’m curious (see e.g. the Java access benchmark on this blog).

But as I’ve said, peoples interest is sparked by different things.

I hope you’re not a dull Erlang which doesn’t see his preconception scratched. If you’re interested in knowledge, there are other benchmarks of Java actor frameworks around, from the top of my head they show Java around 50% slower than Erlang with actors. I guess the JVM isn’t scheduler optimized for this kind of thing.

Fred

@Stephan: I am interested in knowledge, that is actually my whole point.

For me a random graph without context is not very interesting at all. Usually it smells more like marketing than engineering. I could probably produce a graph showing that Ruby is faster than Java for a specific area if I wanted. It would be against conventional wisdom, yet it would not really be interesting unless I told you what it is I am actually comparing.

In other words *the framework* may be interesting depending on what happens in the Java world (I am hoping we will see the actor model used more widely!) but the single graph in itself without context isn’t.

Before I would consider it interesting I would like to know if this micro benchmark corresponds to a relevant use case in the real world. What is the message sending pattern? How many messages are sent between the “tasks”? What is the message size? What type of data is being sent? Do the tasks do anything but pass messages to each other? Is the data immutable? How do they pass messages? Is the message sending order guaranteed? Is it single core or multi core (or perhaps even tasks on different processors)? Is the benchmarking code concise and readable and following the recommended coding style? What is actually being measured and compared in the graph? Zero-copy vs copying? Byte code vs natively compiled code?

stephan

“For me a random graph without context is not very interesting at all.”

Fred, the graph is not random but from the Kilim site which is linked. Sorry that I did not made this more clear to you so you could have followed the link and read the Kilim presentation.

http://www.malhar.net/sriram/talks/kilim-google.pdf

“What is the message sending pattern? [...] Byte code vs natively compiled code?”

Questions are answered on the linked Kilim site. Again, sorry I haven’t made it clear enough for you to follow the link.

Leave a Reply