the blog for developers

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).

You can leave a Reply here. Of course, you should follow me on twitter here.

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.

About the author: Stephan Schmidt has more than 15 years of internet technology experience and 10 years experience in agile. He was head of development, consultant and CTO and is a speaker, author and blog writer. He specializes in organizing and optimizing software development helping companies by increasing productivity with lean software development and agile methodologies. Want to know more? All views are only his own.
Leave a reply.

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.

Bjorn Borg

For some reason, actor model does not seem like a natural extension to Java. I am no James Gosling to say whether Java is meant to do this or not. Perhaps should we shift the blame on to the frameworks which have made actor model like an after-thought on Java? These weaving strategy implementations like Kilim, ActorFoundry, Actors Guild etc… have to take some blame for making actor models look very unnatural to Java development – putting a kink in every development step and development tool. The leap of faith with actor models may perhaps never happen until it is made a part of Java platform itself (like how actors implementation is provided as part of the Scala standard library). For now, for die-hards Java nerds, I would suggest that among Java alternatives, Jetlang is the best because it provides a consistent model that does not feel misplaced or unnatural in the context of Java.

Bjorn Borg

Kilim in my judgment is an attempt to misuse the purposes of a University in coming up with an offering to gain appeal with Java corporate world in the guise of academic research work. Hundreds of successful Java frameworks have been written during week-ends by great people through open source initiatives. Kilim can come no way close to them in terms of acceptance from the Java community. But unlike Kilim, none of them have got a PhD because they were willing to play by the moral rules of the game than go for fringe gains. You don’t need the paraphernalia of a University (professors, library, state grants …) to write a Java framework eh! Hope Universities see through this, if not they will be rendered inconsequential. For heaven’s sake, may Universities focus only on works which have larger impact on the society, bring real futuristic technologies that would make our generation proud!

Anonymous

Why care if Kilim is successful Java framework or not, it has anyway taught us a new way of doing things in life. Come up with a Java framework, release it as open source and take credit from Java community. On the other hand, at the back force fit some E=mc2 theory to it and present it to University for getting a PhD degree, thereby killing two birds in one stone. Extremely smart, way to go!

Universities anyway get free dollars from Uncle Sam, so they can afford to be Santa Claus to award PhDs to Java frameworks or perhaps to even product manuals!

Research is no more about being selfless and working for benefit of mankind. It is about outsmarting the system to get a degree!

“I never perfected an invention that I did not think about in terms of the service it might give others… I find out what the world needs, then I proceed to invent….” – Thomas Alva Edison

Leave a Reply

What people wrote somewhere else:

Additional comments powered by BackType

Guide to CodeMonkeyism

Over the last 4 years I wrote many articles on this blog. To make it easier for you to find the relevant ones, I've organized them into topics.

Top 10

6 reasons why my VC funded startup did fail

Go Ahead: Next Generation Java Programming Style

Java Interview questions: Write a String Reverser

The dark side of NoSQL

7 Bad Signs not to Work for a Software Company or Startup

Is Java dead?

Scala vs. Clojure

Never, never, never use String in Java

No future for functional programming in 2008 – Scala, F# and Nu

Clojure vs Scala, Part 2

Java Developer

Is Java Dead?

Go Ahead: Next Generation Java Programming Style

Be careful with magical code

All variables in Java must be final

Never, never, never use String in Java

Bending Java: More readable code with methods that do nothing?

NoSQL Guy

NoSQL: The Dawn of Polyglot Persistence

The dark side of NoSQL

Essential storage tradeoff: Simple Reads vs. Simple Writes

Sharding destroys the goals of your relational database

The unholy legacy of databases

Startup/CTO

Development Dream Teams

6 reasons why my VC funded startup did fail

American vs. European style of Software Development

12 Things to Reduce Your Lead Time and Time to Market

The high cost of overhead when working in parallel

Essential storage tradeoff: Simple Reads vs. Simple Writes

Job Seeker

Another Good (Java) Interview Question

7 Bad Signs not to Work for a Software Company or Startup

Java Interview questions: Write a String Reverser (and use Recursion!)

Java Interview questions: Multiple Inheritance

As a Manager: What I value in developers

Top 10 Tips (+1) to Get a Pay Raise

Agilist

What Developers Need to Know About Agile

5 Practices Better to Change in Your Scrum Implementation

Scrum is not about engineering practices

ScrumMaster and ZenMaster: The joke of certification

What is Trans-Scrum?