mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-15 16:04:37 +00:00
8d38805d3d
Currently the task scheduler suffers from an O(n) lookup when skipping tasks that are not for the current thread. The reason is that eb32_lookup_ge() has no information about the current thread so it always revisits many tasks for other threads before finding its own tasks. This is particularly visible with HTTP/2 since the number of concurrent streams created at once causes long series of tasks for the same stream in the scheduler. With only 10 connections and 100 streams each, by running on two threads, the performance drops from 640kreq/s to 11.2kreq/s! Lookup metrics show that for only 200000 task lookups, 430 million skips had to be performed, which means that on average, each lookup leads to 2150 nodes to be visited. This commit backports the principle of scope lookups for ebtrees from the ebtree_v7 development tree. The idea is that each node contains a mask indicating the union of the scopes for the nodes below it, which is fed during insertion, and used during lookups. Then during lookups, branches that do not contain any leaf matching the requested scope are simply ignored. This perfectly matches a thread mask, allowing a thread to only extract the tasks it cares about from the run queue, and to always find them in O(log(n)) instead of O(n). Thus the scheduler uses tid_bit and task->thread_mask as the ebtree scope here. Doing this has recovered most of the performance, as can be seen on the test below with two threads, 10 connections, 100 streams each, and 1 million requests total : Before After Gain test duration : 89.6s 4.73s x19 HTTP requests/s (DEBUG) : 11200 211300 x19 HTTP requests/s (PROD) : 15900 447000 x28 spin_lock time : 85.2s 0.46s /185 time per lookup : 13us 40ns /325 Even when going to 6 threads (on 3 hyperthreaded CPU cores), the performance stays around 284000 req/s, showing that the contention is much lower. A test showed that there's no benefit in using this for the wait queue though. |
||
---|---|---|
.. | ||
acl.h | ||
action.h | ||
applet.h | ||
arg.h | ||
auth.h | ||
backend.h | ||
cache.h | ||
capture.h | ||
channel.h | ||
checks.h | ||
cli.h | ||
compression.h | ||
connection.h | ||
counters.h | ||
dns.h | ||
fd.h | ||
filters.h | ||
freq_ctr.h | ||
global.h | ||
h1.h | ||
hdr_idx.h | ||
hlua.h | ||
lb_chash.h | ||
lb_fas.h | ||
lb_fwlc.h | ||
lb_fwrr.h | ||
lb_map.h | ||
listener.h | ||
log.h | ||
mailers.h | ||
map.h | ||
obj_type.h | ||
pattern.h | ||
peers.h | ||
pipe.h | ||
port_range.h | ||
proto_http.h | ||
proto_udp.h | ||
protocol.h | ||
proxy.h | ||
queue.h | ||
sample.h | ||
server.h | ||
session.h | ||
shctx.h | ||
signal.h | ||
spoe.h | ||
ssl_sock.h | ||
stats.h | ||
stick_table.h | ||
stream_interface.h | ||
stream.h | ||
task.h | ||
template.h | ||
vars.h |