[Openmcl-devel] Transfer the contents of a file to a tcp stream

Christian Nybø chr at nybo.no
Tue May 3 12:18:16 PDT 2005


Hello,

If there is a better place for user-level questions on openmcl, please 
let me know.

Could you suggest how to speed up a transfer of the contents of a file 
to a tcp stream?  My code looks like this:

(defun print-file-to-output-stream (in out)
   "Read from in and write to out."
   (with-open-file (is in :element-type 'unsigned-byte)
     (let* ((buffer-size
	    (slot-value
	     (slot-value
	      (slot-value out 'ccl::ioblock)
	      'ccl::outbuf)
	     'ccl::size))
	   (buffer (make-array buffer-size
			       :element-type 'unsigned-byte)))
       (declare (type fixnum buffer-size)
	       (optimize (speed 3) (safety 0)))
       (tagbody read-seq
	 (if (= (ccl::stream-write-ivector
		 out buffer 0
		 (ccl::stream-read-ivector
		  is buffer 0
		  buffer-size))
		buffer-size)
	     (go read-seq)
	     (force-output out))))))

It seems that apache in comparison serves a file at about twice the 
speed as my own server.  Any ideas on how to speed it up?

Asking apache for the file:
chr at macchr/~/downloads/ccl$ wget 
http://localhost/%7Echr/nasa-zambia.jpeg
21:15:27 (6.35 MB/s) - `nasa-zambia.jpeg.79' saved [2538796/2538796]

Asking my own cl server for the file:
chr at macchr/~/downloads/ccl$ wget http://localhost:8000/nasa-zambia.jpeg
21:15:41 (3.91 MB/s) - `nasa-zambia.jpeg.80' saved [2538796/2538796]

-- 
chr




More information about the Openmcl-devel mailing list