From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id A3C98BC69 for ; Sat, 1 Sep 2007 00:16:40 +0200 (CEST) Received: from furbychan.cocan.org (furbychan.cocan.org [80.68.91.176]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l7VMGdUm031378 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Sat, 1 Sep 2007 00:16:40 +0200 Received: from rich by furbychan.cocan.org with local (Exim 3.35 #1 (Debian)) id 1IREn9-0007mn-00 for ; Fri, 31 Aug 2007 23:16:39 +0100 Date: Fri, 31 Aug 2007 23:16:38 +0100 To: caml-list@inria.fr Subject: virt-top Message-ID: <20070831221638.GA17638@furbychan.cocan.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.9i From: Richard Jones X-Miltered: at concorde with ID 46D89348.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 runtime:01 ncurses:01 ocaml:01 gentoo:01 ncurses:01 emacs:01 toolchain:01 binaries:01 unix:01 rewrite:01 dynamically:01 short:01 strings:01 compiling:02 http://et.redhat.com/~rjones/virt-top/ Virt-top is a practical measurement tool for monitoring the performance of virtual machines. Unix users can think 'top' for Xen, QEMU, etc. At some point I want to write a paper about my experiences with writing this in OCaml, but in brief: Pros: * I've had several comments about how easy the binary is to install -- it doesn't require lots of runtime infrastructure like an equivalent Python program might. It's just a native binary which is dynamically linked to libvirt.so & ncurses.so. People who aren't paying close attention probably think I've written a C program. * The program is incredibly short considering the amount of stuff which it does -- just 1000 LoC. * The program takes a tiny fraction of processor / memory than people are used to. And it doesn't leak memory. (Believe me, these are baffling new "features" compared to similar Python programs). * Not having to worry about the usual C hassles (memory management, strings, errors etc.) makes programming much simpler. I know because today I mistakenly started another project using C, and realised what a grind it was -- a quick rewrite of that one in OCaml was necessary. And now for the CONS: * I have to provide binaries for most people, because compiling the program is practically impossible for most users. * Porting it to new platforms is hard, because of lack of comprehensive OCaml support on things like FreeBSD / Solaris/ Gentoo /... [I'm working on rectifying this and the above, but could do with help from any FreeBSD and _especially_ Solaris users out there]. * Lack of library support is so acute that I've had to structure the program in several "layers" so that, for example, only extlib & ocaml-curses is absolutely required (it'd be hard to imagine a top-like program which didn't use ncurses), but users can still build from source with other OCaml libraries missing, although they will get reduced functionality. [See: http://hg.et.redhat.com/virt/applications/virt-top--devel?f=81bcc3563dc7;file=virt-top/README] * Most people look at the code in confusion. I still haven't had a single patch from anyone, and that is disappointing (and more importantly, against the kind of open involvement which Red Hat requires). * Tools: Common text editors don't know what to do with the .ml files. Even emacs doesn't have tuareg-mode by default. This extends throughout the whole toolchain. For example source control tools can't annotate the code (http://hg.et.redhat.com/virt/applications/virt-top--devel?f=2f31261c9437;file=virt-top/virt_top.ml - q.v.), and automake doesn't understand what to do with .ml files. So do we want to make functional programming available to the masses? It's all the "stupid" stuff like the above which needs the effort to fix. Rich. -- Richard Jones Red Hat