]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MEDIUM: pattern: make the pattern LRU cache thread-local and lockless
authorWilly Tarreau <w@1wt.eu>
Wed, 23 Oct 2019 04:59:31 +0000 (06:59 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 23 Oct 2019 05:27:25 +0000 (07:27 +0200)
commit403bfbb130f9fb31e52d441ebc1f8227f6883c22
tree5564e74dca7c7e16e88d0fec627da9abb738090f
parent28c63c15f572a1afeabfdada6a0a4f4d023d05fc
BUG/MEDIUM: pattern: make the pattern LRU cache thread-local and lockless

As reported in issue #335, a lot of contention happens on the PATLRU lock
when performing expensive regex lookups. This is absurd since the purpose
of the LRU cache was to have a fast cache for expressions, thus the cache
must not be shared between threads and must remain lockless.

This commit makes the LRU cache thread-local and gets rid of the PATLRU
lock. A test with 7 threads on 4 cores climbed from 67kH/s to 369kH/s,
or a scalability factor of 5.5.

Given the huge performance difference and the regression caused to
users migrating from processes to threads, this should be backported at
least to 2.0.

Thanks to Brian Diekelman for his detailed report about this regression.
doc/configuration.txt
include/common/hathreads.h
src/pattern.c