lists at necoro.eu
Thu Apr 18 22:03:33 CEST 2013
serving huge files through cgit does not really play well with lighttpd
-- lighty's RAM consumption skyrockets, because it seems to have to load
the file into memory and is not freeing it thereafter, especially with
multiple concurrent requests.
Fortunately a couple of servers implement the X-Sendfile extension (or
synonyms thereof) that allow to pass a path to the webserver which then
serves it directly like every other static file.
Lighty even implements an X-Sendfile2 extension that enables us to pass
a _range_ of a file to serve, which is ideal to serve cgit cache files
directly. So quite some time ago I wrote a patch for cgit that uses
X-Sendfile2. As the patch was clumsy and hard to understand, I tried to
rewrite it, but then noticed that I was doing a wrong thing all along:
If I understood the caching code correctly (which I most likely haven't)
this might fail, as the cache file to serve might be replaced by some
new content (read: might even be some complete other page) inbetween
sending the path to the server and the server sending the file.
So my questions are:
a) Is it possible to use X-Sendfile2 with the current cache implementation?
b) If not: Is it worthwhile to figure out a new scheme to do so, i.e.
where it can be guaranteed that a cache file is not altered between
sending the response and the server serving it?
c) If yes: Should one remove the cache-key from the file, s.t. one can
use "normal" X-Sendfile to serve the file as-is?
My current view is pessimistic, because from my understanding the
a) no, there is no lock on simple serving
b) no, because if there were a lock, there would be no possibility to
remove it, as a CGI application does not get feedback from the server (a
I'd be very glad if anyone could tell me I'm wrong :)
More information about the CGit