On 1/12/06, Tom Fakes <tom@craz8.com> wrote:>
> The rails send_file method does not use the OS sendfile() call. It opens
> the file, reads in a buffer full (default is 4K), and writes it out to the
> client.
>
> I don''t know if the CGI, FCGI, SCGI protocols have a way for an
application
> to return a filename to the web server, and have it send the file using OS
> level calls. I''m guessing this is hard, since at least FCGI apps
may not
> even be running on the same machine!
The rails app would call Linux sendfile() directly, there should be no
need to involve the web server. Linux sendfile() only need a handle
for the network socket and a handle for the file. Rails should have
both of these. First Rails would write out the HTTP headers to the
socket and then call sendfile() to send the rest of the file.
But I don''t know enough about how FCGI is implemented, does Rail have
a socket handle directly to the client or is it a socket to the server
which then forwards the data to the client. Either way sendfile()
should be a win since it will reduce the CPU usage of the rails app.
>
>
> -----Original Message-----
> From: rails-bounces@lists.rubyonrails.org
> [mailto:rails-bounces@lists.rubyonrails.org] On Behalf Of Jon Smirl
> Sent: Thursday, January 12, 2006 6:42 AM
> To: rails@lists.rubyonrails.org
> Subject: [Rails] ActionController#send_file
>
> Looking at the code for ActionController#send_file I see that it is
> using ruby to send the file contents. Linux supports a sendfile() OS
> call. The implementation of Linux sendfile() is extremely fast and
> very CPU efficient, far faster than what can be done in user space.
>
> Does Windows support a sendfile() equivalent call? I haven''t been
> working with ruby long enough to know how it handles things like this
> on a per platform basis, how is it done?
>
> --
> Jon Smirl
> jonsmirl@gmail.com
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
--
Jon Smirl
jonsmirl@gmail.com