Robert Eisele
Systems Engineer, Architect and DBA

Get the last percents out of lighttpd

lighttpd is one of the fastest webservers available, especially with aio. There are a lot of other fast and lightweight webservers but lighty is the most common.

I've developed a few modules for lighty (still not public) and saw a little facility to get more performance. The performance-gain is relative small in this case but why should we give it away?

Run the following two lines in your source directory before you compile your lighttpd webserver:

find . -name "*.c" -exec sed -ie 's/buffer_append_string\(([a-z0-9_]\+,[[:space:]]*".*")\)/BUFFER_APPEND_STRING_CONST\1/g' {} \;
find . -name "*.c" -exec sed -ie 's/buffer_copy_string\(([a-z0-9_]\+,[[:space:]]*".*")\)/BUFFER_COPY_STRING_CONST\1/g' {} \;

Who would like a little explanation: I think this is only an oversight because in most cases the main developers of lighty use BUFFER_[APPEND|COPY]_STRING_CONST which is a macro for constant strings. In some cases they use only the dynamic equivalent buffer_[append|copy]_string. So lighty must run strlen() to determine the size of a string where the lenght is already known. To check the length of only a "." (point) the loop inside strlen() ends very quickly. But lighty has some places where this "problem" is more critical - for example to combine HTML-components in connections.c.

Update:
The patch was included in the current release 1.4.20!

You might also be interested in the following

 

Sorry, comments are closed for this article. Contact me if you have an inventive contribution.