I did some tests with httperf:<br><br><b>First test with file-to-string function:</b><br><br>Total: connections 100 requests 100 replies 89 test-duration 67.869 s<br><br>Connection rate: 1.5 conn/s (678.7 ms/conn, <=1 concurrent connections)<br>
Connection time [ms]: min 492.0 avg 638.7 max 1151.0 median 572.5 stddev 150.4<br>Connection time [ms]: connect 1.3<br>Connection length [replies/conn]: 1.000<br><br>Request rate: 1.5 req/s (678.7 ms/req)<br>Request size [B]: 93.0<br>
<br>Reply rate [replies/s]: min 1.0 avg 1.3 max 1.8 stddev 0.2 (13 samples)<br>Reply time [ms]: response 511.0 transfer 126.4<br>Reply size [B]: header 368.0 content 21324.0 footer 0.0 (total 21692.0)<br>Reply status: 1xx=0 2xx=89 3xx=0 4xx=0 5xx=0<br>
<br>CPU time [s]: user 28.77 system 38.89 (user 42.4% system 57.3% total 99.7%)<br>Net I/O: 27.9 KB/s (0.2*10^6 bps)<br><br>Errors: total 11 client-timo 11 socket-timo 0 connrefused 0 connreset 0<br>Errors: fd-unavail 0 addrunavail 0 ftab-full 0 other 0<br>
<br><br><br><b>Second test with handle-static-file:</b><br><br>Total: connections 100 requests 100 replies 16 test-duration 93.867 s<br><br>Connection rate: 1.1 conn/s (938.7 ms/conn, <=1 concurrent connections)<br>Connection time [ms]: min 594.0 avg 807.4 max 1393.0 median 690.5 stddev 240.2<br>
Connection time [ms]: connect 0.6<br>Connection length [replies/conn]: 1.000<br><br>Request rate: 1.1 req/s (938.7 ms/req)<br>Request size [B]: 93.0<br><br>Reply rate [replies/s]: min 0.0 avg 0.2 max 1.0 stddev 0.3 (18 samples)<br>
Reply time [ms]: response 637.1 transfer 166.0<br>Reply size [B]: header 348.0 content 21324.0 footer 0.0 (total 21672.0)<br>Reply status: 1xx=0 2xx=16 3xx=0 4xx=0 5xx=0<br><br>CPU time [s]: user 40.12 system 53.39 (user 42.7% system 56.9% total 99.6%)<br>
Net I/O: 3.7 KB/s (0.0*10^6 bps)<br><br>Errors: total 84 client-timo 79 socket-timo 0 connrefused 0 connreset 5<br>Errors: fd-unavail 0 addrunavail 0 ftab-full 0 other 0<br><br>As can be seen from the second test there were lots of time-out requests. Also as I was watching the CPU usage (with top) during first test CPU load was ~2%, during second test the CPU load was ~90% with memory constantly growing and shrinking (probably GC was causing this load). Also during some of handle-static-file tests I ran into heap allocation problems so I had to unload the lisp image and restart it.<br>
Well, it could be just my particular system's problem.<br><br>Andrew<br><br><div class="gmail_quote">On Fri, Jun 20, 2008 at 2:20 PM, Edi Weitz <<a href="mailto:edi@agharta.de">edi@agharta.de</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">On Fri, 20 Jun 2008 12:56:33 -0400, "Andrei Stebakov" <<a href="mailto:lispercat@gmail.com">lispercat@gmail.com</a>> wrote:<br>
<br>
> I had to come up with some way to cache dynamic files that I have to<br>
> serve, so I ended up with a bunch of static files which I served by<br>
> a simple function:<br>
> (defun file-to-string (path)<br>
> "Reads a file into a string"<br>
> (if (probe-file path)<br>
> (with-open-file (in path)<br>
> (let ((str (make-string (file-length in))))<br>
> (read-sequence str in)<br>
> str))))<br>
><br>
> The performance was very good, but then I thought that it's not the<br>
> proper way to serve static files as there is a hunchentoot function<br>
> handle-static-file.<br>
> When I started using the hunchentoot's function the response time<br>
> almost tripled and when I run "top" program to monitor CPU usage it<br>
> jumps up to 60% (on my PIII 600 MHz) CPU, whereas using<br>
> file-to-string CPU usage stays with 2% (maybe because the serving<br>
> time is much shorter top doesn't catch that CPU peak).<br>
<br>
</div>How did you measure the response time? Which version of FLEXI-STREAMS<br>
are you using? Did you try with the development version?<br>
<div class="Ih2E3d"><br>
> My question is what could be the reason I see this behaviour? (I am<br>
> using SBCL 1.0.15 with latest dependences of hunchentoot-0.15.7)<br>
<br>
</div>Look at the source code of handle-static-file. It uses a fixed size<br>
buffer which is likely smaller than your file.<br>
_______________________________________________<br>
tbnl-devel site list<br>
<a href="mailto:tbnl-devel@common-lisp.net">tbnl-devel@common-lisp.net</a><br>
<a href="http://common-lisp.net/mailman/listinfo/tbnl-devel" target="_blank">http://common-lisp.net/mailman/listinfo/tbnl-devel</a><br>
</blockquote></div><br>