OPTIM: lua: don't use expensive functions to parse headers in the HTTP applet
authorWilly Tarreau <w@1wt.eu>
Wed, 23 Aug 2017 09:24:47 +0000 (11:24 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 23 Aug 2017 14:11:38 +0000 (16:11 +0200)
commita329463655af8bc3e286f50c437727f21865b550
tree29367943f5801937ca78ad7fbc0cc59e11d63790
parent85cb0aecf5b29d09d151086858bdcbe0e6f183fc
OPTIM: lua: don't use expensive functions to parse headers in the HTTP applet

In the HTTP applet, we have to parse the response headers provided by
the application and to produce a response. strcasecmp() is expensive,
and chunk_append() even more as it uses a format string.

Here we check the string length before calling strcasecmp(), which
results in strcasecmp() being called only on the relevant header in
practise due to very few collisions on the name lengths, effectively
dividing the number of calls by 3, and we replace chunk_appendf()
with memcpy() as we already know the string lengths.

Doing just this makes the "hello-world" applet 5% faster, reaching
41400 requests/s on a core i5-3320M.
src/hlua.c