Tagged benchmarks

Recently, I had a craving for some PowerPC action, so I dug up an old PPC970-based machine and had some considerable fun playing with it. The machine in question is an early model of double-processor PowerMac G5, version 7.2 to be exact:

works

I've decided to write this post because these machines are getting old and any sort of info on how to boot GNU/Linux on them is getting sparser by the year. Especially the correct sort.

Continue reading

Just the other day, while programming in Scala, I was thinking how nice it is that Haskell hides non-strictness (a.k.a. laziness) underneath, so no obnoxious lazy stream creation/forcing needs to be done. And then it struck me: how cool would it be to treat Promises in a language the same way that Haskell treats lazy values? Would such a language even make sense? How would you program in such a language?

Let's explore! You can find all the code included in this post in a more useful form here.

Promise

Here's a very simple Promise implementation written in Scheme, with support for asynchronous resolving & error rejection, which we'll need in order to explore this weird proposition:

(define *promises* '())

(define (make-promise value state then handle thunk)
  (list '&promise value state then handle thunk))

;; Field accessors omitted.

(define (promise fun)
  (let* ((val '())
         (state 'pending)
         (on-resolve id)
         (on-reject id)
         (resolve (lambda (v)
                    (set! val v)
                    (set! state 'resolved)
                    (on-resolve val)))
         (reject (lambda (e)
                   (set! val e)
                   (set! state 'rejected)
                   (on-reject val)))
         (then (lambda (t)
                 (if (equal? state 'resolved)
                     (t val)
                     (set! on-resolve t))))
         (handle (lambda (h)
                   (if (equal? state 'rejected)
                       (h val)
                       (set! on-reject h))))
         (p (make-promise (lambda () val)
                          (lambda () state)
                          then
                          handle
                          (lambda () (fun resolve reject)))))
    (set! *promises* (cons p *promises*))
    p))

Continue reading

Lately I've been banging around a lot in order to get up to speed with Erlang/OTP and its various web-server libraries, and I figured I could share some of my findings here for future reference and in general for The Greater Good.

Test server

As you might have already noticed, this benchmark concerns two of the most well knows Erlang web-server libraries, MochiWeb and Cowboy, and it aims to explore their behaviour under some considerable load.

The server in question uses two communication protocols, HTTP and WebSocket, so as an added benefit we'll see how these two compare. Unfortunately, MochiWeb doesn't have a built-in support for WebSocket, so an external library was needed. The rather simple client API is defined as:

  • ht​tp://host/poll/N - an HTTP chunked reply with one chunk of data sent every N seconds,
  • ws://host/wspoll/N - a WebSocket connection with one chunk sent every N seconds.
Continue reading