Subject: Re: Deploying Common Lisp applications
From: rpw3@rpw3.org (Rob Warnock)
Date: Mon, 23 May 2005 23:21:08 -0500
Newsgroups: comp.lang.lisp
Message-ID: <4qqdnb72wo0pNg_fRVn-tQ@speakeasy.net>
Cameron MacKinnon  <cmackin+nn@clearspot.net> wrote:
+---------------
| GP lisper wrote:
| > The advantages of core files have been pointed out, the suggestion to
| >  have all your scripts in one core looks good.
| 
| Lisp "core files" are a wonderful idea which can markedly speed
| application load time and memory requirements in some instances. But
| your support for the suggestion that a user with N independent scripts
| just load 'em all up and dump a core probably looks, to typical UNIX/C
| developers, ... [stupid].
+---------------

There *is* an intermediate approach...

Make one specialized core file [or more, maybe, but in any case a
very small number] that has all of your "usual suspect" utility and
support library functions, and then write your CL scripts as calls of
these. Since the size of each script will be small (since the scripts
are now mostly just "glue" between library functions), you can even run
them purely interpreted, probably faster even than LOADing FASL files.
[Well, this is true for CMUCL, but maybe not for SBCL.]

Example: I have a CMUCL image "cgi.core" that has my CGI query-parsing
tools in it, the "HTOUT" HTML-generation macros, the "PG" PostgreSQL
binding, and a bunch of miscellaneous tools and widgets I've found to
be handy in general-purpose CGI scripting and Unix shell scripting.
Simple interpreted scripts using this image take only ~20 ms to run
on an Athlon 1600+ (1.4 GHz) under FreeBSD, e.g.:

    $ cat ./foo
    #!/usr/local/bin/cmucl -core /usr/local/lib/cmucl/lib/cgi.core
    (format t "Hello, world!~%")
    $ time ./foo
    Hello, world!
    0.006u 0.013s 0:00.02 50.0%     252+5160k 0+0io 0pf+0w
    $ 

[Yes, the core contains a reader macro for "#!".]

Loading additional FASL libraries can take 30-100 ms (or more), so if
you find something being used by several scripts just add it to the
base core [if it's not *too* big].


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607