[hunchentoot-devel] Static file handling performance

Andrei Stebakov lispercat at gmail.com
Fri Jun 20 16:56:33 UTC 2008


I had to come up with some way to cache dynamic files that I have to serve,
so I ended up with a bunch of static files which I served by a simple
function:
(defun file-to-string (path)
  "Reads a file into a string"
  (if (probe-file path)
      (with-open-file (in path)
        (let ((str (make-string (file-length in))))
          (read-sequence str in)
          str))))

The performance was very good, but then I thought that it's not the proper
way to serve static files as there is a hunchentoot function
handle-static-file.
When I started using the hunchentoot's function the response time almost
tripled and when I run "top" program to monitor CPU usage it jumps up to 60%
(on my PIII 600 MHz) CPU,
whereas using file-to-string CPU usage stays with 2% (maybe because the
serving time is much shorter top doesn't catch that CPU peak).
My question is what could be the reason I see this behaviour? (I am using
SBCL 1.0.15 with latest dependences of hunchentoot-0.15.7)

Thank you,
Andrew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/tbnl-devel/attachments/20080620/cc9aef5d/attachment.html>


More information about the Tbnl-devel mailing list