Go to the first, previous, next, last section, table of contents.

Native Code

The benefits of compiling to native code in a system like Muq are typically grossly overestimated, but there are times when it can make all the difference in the world. For example, if you are writing a realtime sound-processing app and need to do 256-sample Fast Fourier Transforms lightning-fast.

I'd like to handle this by introducing a NativeFunction object class into Muq, with the C source code as one property. The Muq server can easily invoke gcc to compile the function into a .so file and then dynamically link it in.

This requires total trust of the person providing the code, of course, but that is normal when downloading and executing any binary app anyhow. The main use I see for this facility is in standard libraries maintained by a few trusted people, so public-key signatures on the distributed code (and a per-server list of trusted signatures) should be sufficient to keep the security problems within bounds.

The main point of this mechanism is to allow access to C-level performance in Muq library code which needs it without requiring the Muq server as a whole to be re-linked, stopped, and restarted, as is typically done on today's servers in such a situation.

A facility allowing one to compile to native code -without- requiring complete trust would be great, but experience to date with Java (and Lisp) suggest strongly that in the end one usually winds up giving up either security (e.g., Lisp's compiler safety settings) or else performance (e.g., Java just insists on doing array bounds checking on each array access, killing performance in almost every situation where it matters).

This project is probable a weekend or two, and I doubt anyone but me is going to do it.

On the code efficiency front, there's a lot to like about what the Self folks did: Some good papers on their optimizations (which they claim brought them to 2-4x the speed of commercial Smalltalk, and about half the speed of C) are at http://www.sunlabs.com/research/self. The project died in 1995, alas -- overdosed on elegance?

Go to the first, previous, next, last section, table of contents.