Log in

Threading vs. event-driven - Journal of Omnifarious

May. 16th, 2008

08:06 pm - Threading vs. event-driven

Previous Entry Share Next Entry

A comrade in arms on the event-driven vs. threaded debate has switched sides and is now a threading advocate. He's been having doubts for awhile but was finally convinced by an article about threaded vs. event-driven approaches in Java. I'm not so sure, though it's clear that some of the long-standing reasons that threaded approaches were bad are starting to go away.

My main complaint about threads is that the concurrency model they represent is too hard for most people to use and requires way more discipline than the average programmer seems capable of.

My secondary complaint is basically that they introduce latency. Every synchronization operation represents a piece of data that has to be communicated between threads. I wrote a long pondering article about threads and latency awhile ago.

One thing I've noticed is that reads are usually much more frequent than updates. This makes things like memcached a good idea. I think of memcached as essentially being NUMA without hardware support.

I think it's clear though that some level of threading is a good idea nowadays.

One interesting thing that Java has done that I think is an overall useful concept is making some data structures immutable so that no locking operations are required to access them. Python does this too.

This is going to require some thinking.

Current Mood: [mood icon] contemplative


[User Picture]
Date:May 18th, 2008 05:00 pm (UTC)
How do you expect me to sew patches with out threading?!
(Reply) (Thread)
[User Picture]
Date:May 28th, 2008 08:36 pm (UTC)
Note that the link to the slides in the Java article I linked to is now un-broken and rather interesting. Actual experiments, and pretty graphs.
(Reply) (Thread)