Journal of Omnifarious - Threading vs. event-driven

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.

Tags: , ,
Current Location: 5463 Leary Ave NW, 98107 (Mr Spot's Chai House)
Current Mood: [mood icon] contemplative
(2 comments | Leave a comment)

Comments:

[User Picture]
From:rosencrantz319
Date:May 18th, 2008 05:00 pm (UTC)
(Link)
How do you expect me to sew patches with out threading?!
(Reply) (Thread)
[User Picture]
From:pphaneuf
Date:May 28th, 2008 08:36 pm (UTC)
(Link)
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)