I’ve been ranting already about today’s non-thread-blocking needs (here: Efficient I/O: working smart with slow byte movers) and the fact that some of the most prominent runtimes (e.g. JVM…) lack support for fibers, causing everyone to shelter in asynchronous programming models instead of looking for ways to complement the runtime.
Actually Ron Pressler has been writing about this issue quite extensively in Parallel Universe’s blog , for example a very fine post is Little’s Law, Scalability and Fault Tolerance: The OS is your bottleneck (and what you can do about it) but I warmly recommend reading everything in there as there’s a lot of insight and great architectural and even day-to-day suggestions are provided.
Let me call this syndrome Asyncmania. Ron and the other guys at Parallel Universe are proposing an appealing cure for it through Quasar (with Pulsar, it’s elegant Clojure dress) and Comsat. They build upon a lean code transformation approach, using JVM’s ability to instrument bytecode in a way that allows fiber-blocking calls to be suspended and later resumed without blocking the whole thread (more about this here: Implementing, Abstracting and Benchmarking Lightweight Threads on the JVM).
Blocking APIs are easier to write, to read, to reason about and to maintain, so adding fibers to the runtime looks like a better solution (to me, at least) than providing cumbersome asynchronous abstractions. I really hope we’ll come back to that saner way of writing things.
Can you remember the happy times of blocking socket programming? Those little and simple calls in a sequence or loop… “bind”, “listen”, “connect”, “receive”, “send”… Wouldn’t you like to have them back for writing high-performance HTTP and WebSocket server and client applications having the same level of performance as the asynchronous ones?
…I did want, so I have started putting together Blazar. Blazar is a set of straightforward fiber-blocking Clojure APIs to write high-performance HTTP and WebSocket clients and servers.
Blazar builds upon Pulsar and its great support to transform async APIs into fiber-blocking ones, which I used to bridge http-kit‘s and Gniazdo‘s, two great async HTTP and WebSocket Clojure toolkits.
It is still a very young toy, but it’s already working and there are both tests and examples to start using it. Of course it is OSS, dual-licensed under Eclipse and LGPLv3, same as Pulsar.
Have a look, tell me what you think and be sure that more will come, so stay tuned.
Let’s heal from Asyncmania, together we can!