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

rm at fabula.de rm at fabula.de
Tue May 3 14:53:44 PDT 2005


On Tue, May 03, 2005 at 03:22:52PM -0600, Gary Byers wrote:
> >Of course, since OpenMCL has a nice FFI interface it would be trivial to
> >call sendfile from it .... but that would be cheatin' :-)
> >
> >
> >Cheers Ralf Mattes
> 
> 
> Hmm.  I was just about to recommend cheating (using sendfile) if it's
> available (it's available on Linux, but doesn't seem to be there on
> Darwin/OSX).

I think it got added to the Linux kernel API after that notorious 
Win/Linux server comparison ...

> Apache seems to try to use sendfile if it's available, and apparently
> tries to partially emulate it if it isn't.  (I'm not sure what's
> involved in that emulation; at a minimum, it'd probably involve having
> the file and socket share a single userspace buffer.)

Well, one can't emulate the kernel-space only property and _That_ seems
to acount for a lot of bottleneck (but only under high load! I hope 
it's clear to everyone that even thinking about performance issues on
this level is only neccessary for sites with a _lot_ of traffic. Even
on one of my customers main servers (rather large newspaper) that wouldn't
probably make a lot of perceptable difference. Hmm, once you start serving
lot's of images, then i'd worry. But Lispers probably don't server porn :-/

> If Apache's cheating (doing something other than an #_fread/#_fwrite
> loop), it seems pretty reasonable for Christan's server to do so as
> well.  I imagine that a lot of effort's been put into getting Apache
> to cheat efficiently, and that it'd be worth looking into exactly
> how it does that.
> 
> If one has one's hands on a CL STREAM s, the generic function
> (CCL::STREAM-DEVICE s direction) - where "direction" is one of
> :INPUT, :OUTPUT, or NIL - returns the underlying file descriptor.
> (Yes, this should be exported and documented.)  You can cheat a bit
> by doing something like:

> [snip]

Ah, i was waiting for that trick. I didn't know how to get the
underlying file descriptor. Thank's for that post.

 RalfD



More information about the Openmcl-devel mailing list