[FoRK] outsourcing back end

J. Andrew Rogers andrew at jarbox.org
Tue May 7 17:23:32 PDT 2013

On May 7, 2013, at 4:43 PM, "Joseph S. Barrera III" <joe at barrera.org> wrote:
> On 5/7/2013 4:35 PM, Owen Byrne wrote:
> > The actual architecture (single threaded with asynchronous callbacks)
> > makes it quite a bit easier to wrap your head around than some
> > other multi-processing architectures like say, Java multithreading.
> But isn't single threading kind of out of step with modern architectural trends, with pretty much every processor being multicore, especially those on servers?

Yes and no. Classic multi-threading architecture (locks, thread pools, shared resources, etc) is definitely on the way out. Node.js is not a good example of this but it captures a bit of the flavor.

Modern multicore processors are what is driving software *away* from threading. CPUs have become so efficient at retiring instructions that anything which injects modest latency has a huge cost in terms of throughput.

Some of the biggest culprits for avoidable latency: context-switching, cache coherency, and non-local memory references. The easiest way to design these out of your code is to have a single thread/process per core and to schedule all operations in userspace using coroutines, callbacks, etc. Any interactions between threads is used sparingly and based on message passing. There may be a shared address space but very little actual sharing going on.

In practice, the performance benefit to doing things this way compared to the classical multithreaded paradigm is integer factor. Another benefit is that most code can be written in a simple, single-threaded style since there are no locking considerations but you also have to design your own schedulers. Cooperative multitasking is back! 


More information about the FoRK mailing list