haproxy/src
Ubuntu b1adf03df9 MEDIUM: backend: use a trylock when trying to grab an idle connection
In conn_backend_get() we can cause some extreme contention due to the
idle_conns_lock. Indeed, even though it's per-thread, it still causes
high contention when running with many threads. The reason is that all
threads which do not have any idle connections are quickly skipped,
till the point where there are still some, so the first reaching that
point will grab the lock and the other ones wait behind. From this
point, all threads are synchronized waiting on the same lock, and
will follow the leader in small jumps, all hindering each other.

Here instead of doing this we're using a trylock. This way when a thread
is already checking a list, other ones will continue to next thread. In
the worst case, a high contention will lead to a few new connections to
be set up, but this may actually be what is required to avoid contention
in the first place. With this change, the contention has mostly
disappeared on this lock (it's still present in muxes and transport
layers due to the takeover).

Surprisingly, checking for emptiness of the tree root before taking
the lock didn't address any contention.

A few improvements are still possible and desirable here. The first
one would be to avoid seeing all threads jump to the next one. We
could have each thread use a different prime number as the increment
so as to spread them across the entire table instead of keeping them
synchronized. The second one is that the lock in the muck layers
shouldn't be needed to check for the tasklet's context availability.
2021-03-05 08:30:08 +01:00
..
51d.c CLEANUP: Use ist2(const void*, size_t) whenever possible 2021-03-01 15:44:20 +01:00
acl.c CLEANUP: tree-wide: replace free(x);x=NULL with ha_free(&x) 2021-02-26 21:21:09 +01:00
action.c MINOR: resolvers: renames some resolvers specific types to not use dns prefix 2021-02-13 09:43:18 +01:00
activity.c BUG/MINOR: activity: take care of late wakeups in "show tasks" 2021-01-29 15:07:07 +01:00
applet.c CLEANUP: include: tree-wide alphabetical sort of include files 2020-06-11 10:18:59 +02:00
arg.c CLEANUP: tree-wide: replace free(x);x=NULL with ha_free(&x) 2021-02-26 21:21:09 +01:00
auth.c CLEANUP: tree-wide: replace free(x);x=NULL with ha_free(&x) 2021-02-26 21:21:09 +01:00
backend.c MEDIUM: backend: use a trylock when trying to grab an idle connection 2021-03-05 08:30:08 +01:00
base64.c REORG: include: move base64.h, errors.h and hash.h from common to to haproxy/ 2020-06-11 10:18:56 +02:00
cache.c CLEANUP: Use istadv(const struct ist, const size_t) whenever possible 2021-03-03 05:07:10 +01:00
calltrace.c BUILD: trace: include tools.h 2020-09-25 17:54:48 +02:00
cfgparse-global.c CLEANUP: Compare the return value of XXXcmp() functions with zero 2021-01-04 10:09:02 +01:00
cfgparse-listen.c CLEANUP: tree-wide: replace free(x);x=NULL with ha_free(&x) 2021-02-26 21:21:09 +01:00
cfgparse-ssl.c CLEANUP: tree-wide: replace free(x);x=NULL with ha_free(&x) 2021-02-26 21:21:09 +01:00
cfgparse-tcp.c MINOR: tcp: add support for defer-accept on FreeBSD. 2021-02-13 09:05:02 +01:00
cfgparse-unix.c MINOR: listener: create a new struct "settings" in bind_conf 2020-09-16 20:13:13 +02:00
cfgparse.c CLEANUP: config: replace a few free() with ha_free() 2021-02-26 21:21:21 +01:00
channel.c CLEANUP: channel: fix comment in ci_putblk. 2021-02-13 09:43:17 +01:00
check.c CLEANUP: Use the ist() macro whenever possible 2021-03-05 08:28:53 +01:00
chunk.c CLEANUP: include: tree-wide alphabetical sort of include files 2020-06-11 10:18:59 +02:00
cli.c CLEANUP: tree-wide: replace free(x);x=NULL with ha_free(&x) 2021-02-26 21:21:09 +01:00
compression.c CLEANUP: Compare the return value of XXXcmp() functions with zero 2021-01-04 10:09:02 +01:00
connection.c MINOR: backend: handle reuse for conns with no server as target 2021-03-03 11:31:19 +01:00
da.c CLEANUP: config: Return ERR_NONE from config callbacks instead of 0 2020-11-13 16:26:10 +01:00
debug.c CLEANUP: tasks: use a less confusing name for task_list_size 2021-02-24 17:42:04 +01:00
dgram.c REORG: dgram: rename proto_udp to dgram 2020-06-11 10:18:59 +02:00
dict.c CLEANUP: tree-wide: replace free(x);x=NULL with ha_free(&x) 2021-02-26 21:21:09 +01:00
dns.c CLEANUP: dns: Remove useless test on ns->dgram in dns_connect_nameserver() 2021-03-04 16:58:36 +01:00
dynbuf.c MINOR: dynbuf: pass offer_buffers() the number of buffers instead of a threshold 2021-02-20 12:38:18 +01:00
eb32sctree.c REORG: ebtree: move the include files from ebtree to include/import/ 2020-06-11 09:31:11 +02:00
eb32tree.c REORG: ebtree: move the include files from ebtree to include/import/ 2020-06-11 09:31:11 +02:00
eb64tree.c REORG: ebtree: move the include files from ebtree to include/import/ 2020-06-11 09:31:11 +02:00
ebimtree.c CLEANUP: include: tree-wide alphabetical sort of include files 2020-06-11 10:18:59 +02:00
ebistree.c REORG: ebtree: move the include files from ebtree to include/import/ 2020-06-11 09:31:11 +02:00
ebmbtree.c REORG: ebtree: move the include files from ebtree to include/import/ 2020-06-11 09:31:11 +02:00
ebpttree.c REORG: ebtree: move the include files from ebtree to include/import/ 2020-06-11 09:31:11 +02:00
ebsttree.c REORG: ebtree: move the include files from ebtree to include/import/ 2020-06-11 09:31:11 +02:00
ebtree.c BUG/MEDIUM: ebtree: use a byte-per-byte memcmp() to compare memory blocks 2020-06-16 11:30:33 +02:00
ev_epoll.c CLEANUP: tree-wide: replace free(x);x=NULL with ha_free(&x) 2021-02-26 21:21:09 +01:00
ev_evports.c CLEANUP: tree-wide: replace free(x);x=NULL with ha_free(&x) 2021-02-26 21:21:09 +01:00
ev_kqueue.c CLEANUP: tree-wide: replace free(x);x=NULL with ha_free(&x) 2021-02-26 21:21:09 +01:00
ev_poll.c CLEANUP: tree-wide: replace free(x);x=NULL with ha_free(&x) 2021-02-26 21:21:09 +01:00
ev_select.c CLEANUP: tree-wide: replace free(x);x=NULL with ha_free(&x) 2021-02-26 21:21:09 +01:00
extcheck.c CLEANUP: tree-wide: replace free(x);x=NULL with ha_free(&x) 2021-02-26 21:21:09 +01:00
fcgi-app.c CLEANUP: Use the ist() macro whenever possible 2021-03-05 08:28:53 +01:00
fcgi.c CLEANUP: include: tree-wide alphabetical sort of include files 2020-06-11 10:18:59 +02:00
fd.c CLEANUP: tree-wide: replace free(x);x=NULL with ha_free(&x) 2021-02-26 21:21:09 +01:00
filters.c BUG/MEDIUM: filters/htx: Fix data forwarding when payload length is unknown 2021-01-26 09:53:52 +01:00
fix.c CLEANUP: assorted typo fixes in the code and comments 2020-12-21 11:24:48 +01:00
flt_http_comp.c MAJOR: htx: Remove the EOM block type and use HTX_FL_EOM instead 2021-01-28 16:37:14 +01:00
flt_spoe.c BUG/MEDIUM: spoe: Kill applets if there are pending connections and nbthread > 1 2021-03-01 15:10:19 +01:00
flt_trace.c CLEANUP: Use istadv(const struct ist, const size_t) whenever possible 2021-03-03 05:07:10 +01:00
freq_ctr.c BUG/MINOR: freq_ctr: fix a wrong delay calculation in next_event_delay() 2021-02-09 17:52:50 +01:00
frontend.c MINOR: frontend: add client timeout sample fetch 2020-12-11 12:01:07 +01:00
h1_htx.c MINOR: h1: Raise the chunk size limit up to (2^52 - 1) 2021-01-28 16:37:14 +01:00
h1.c MEDIUM: h1: add a WebSocket key on handshake if needed 2021-01-28 16:37:14 +01:00
h2.c CLEANUP: Replace for loop with only a condition by while 2021-03-05 08:28:53 +01:00
haproxy.c CLEANUP: tree-wide: replace free(x);x=NULL with ha_free(&x) 2021-02-26 21:21:09 +01:00
hash.c REORG: include: move base64.h, errors.h and hash.h from common to to haproxy/ 2020-06-11 10:18:56 +02:00
hlua_fcn.c BUG/MINOR: hlua: Don't strip last non-LWS char in hlua_pushstrippedstring() 2021-03-03 19:48:12 +01:00
hlua.c OPTIM: server: switch the actconn list to an mt-list 2021-02-18 10:06:45 +01:00
hpack-dec.c CLEANUP: Use isttest(const struct ist) whenever possible 2021-03-03 05:07:10 +01:00
hpack-enc.c CLEANUP: include: tree-wide alphabetical sort of include files 2020-06-11 10:18:59 +02:00
hpack-huff.c REORG: include: move hpack*.h to haproxy/ and split hpack-tbl 2020-06-11 10:18:57 +02:00
hpack-tbl.c CLEANUP: include: tree-wide alphabetical sort of include files 2020-06-11 10:18:59 +02:00
http_acl.c CLEANUP: acl: don't reference the generic pattern deletion function anymore 2020-11-05 19:27:09 +01:00
http_act.c BUG/MINOR: http-rules: Always replace the response status on a return action 2021-02-19 18:03:59 +01:00
http_ana.c CLEANUP: Use the ist() macro whenever possible 2021-03-05 08:28:53 +01:00
http_conv.c MINOR: http-conv: Don't check if argument list is set in sample converters 2021-01-29 13:26:02 +01:00
http_fetch.c CLEANUP: Use IST_NULL whenever possible 2021-03-01 15:44:28 +01:00
http_htx.c CLEANUP: tree-wide: replace free(x);x=NULL with ha_free(&x) 2021-02-26 21:21:09 +01:00
http_rules.c CLEANUP: Compare the return value of XXXcmp() functions with zero 2021-01-04 10:09:02 +01:00
http.c MINOR: http: Add HTTP 501-not-implemented error message 2021-01-21 15:21:12 +01:00
htx.c CLEANUP: Use istadv(const struct ist, const size_t) whenever possible 2021-03-03 05:07:10 +01:00
lb_chash.c MINOR: lb/chash: use a read lock in chash_get_server_hash() 2020-10-17 20:15:49 +02:00
lb_fas.c OPTIM: lb-first: do not take the server lock on take_conn/drop_conn 2021-02-18 10:06:45 +01:00
lb_fwlc.c OPTIM: lb-leastconn: do not unlink the server if it did not change 2021-02-18 10:06:45 +01:00
lb_fwrr.c MINOR: backend: replace the lbprm lock with an rwlock 2020-10-17 18:51:41 +02:00
lb_map.c MINOR: lb/map: use seek lock and read locks where appropriate 2020-10-17 19:04:27 +02:00
listener.c CLEANUP: Use the ist() macro whenever possible 2021-03-05 08:28:53 +01:00
log.c CLEANUP: Use isttest(const struct ist) whenever possible 2021-03-03 05:07:10 +01:00
lru.c
mailers.c CLEANUP: tree-wide: replace free(x);x=NULL with ha_free(&x) 2021-02-26 21:21:09 +01:00
map.c CLEANUP: tree-wide: replace free(x);x=NULL with ha_free(&x) 2021-02-26 21:21:09 +01:00
mqtt.c CLEANUP: assorted typo fixes in the code and comments 2020-12-21 11:24:48 +01:00
mux_fcgi.c CLEANUP: Use the ist() macro whenever possible 2021-03-05 08:28:53 +01:00
mux_h1.c CLEANUP: Use the ist() macro whenever possible 2021-03-05 08:28:53 +01:00
mux_h2.c CLEANUP: Use isttest(const struct ist) whenever possible 2021-03-03 05:07:10 +01:00
mux_pt.c MINOR: xprt/mux: export all *_io_cb functions so that "show fd" resolves them 2021-01-20 17:17:39 +01:00
mworker-prog.c CLEANUP: tree-wide: replace free(x);x=NULL with ha_free(&x) 2021-02-26 21:21:09 +01:00
mworker.c CLEANUP: tree-wide: replace free(x);x=NULL with ha_free(&x) 2021-02-26 21:21:09 +01:00
namespace.c REORG: include: move the error reporting functions to from log.h to errors.h 2020-06-11 10:18:59 +02:00
pattern.c CLEANUP: tree-wide: replace free(x);x=NULL with ha_free(&x) 2021-02-26 21:21:09 +01:00
payload.c MINOR: config: Deprecate and ignore tune.chksize global option 2020-11-27 10:30:23 +01:00
peers.c MINOR: peers/cli: do not dump the peers dictionaries by default on "show peers" 2021-02-12 17:00:52 +01:00
pipe.c CLEANUP: include: tree-wide alphabetical sort of include files 2020-06-11 10:18:59 +02:00
pool.c MEDIUM: pools: add CONFIG_HAP_NO_GLOBAL_POOLS and CONFIG_HAP_GLOBAL_POOLS 2021-03-05 08:30:08 +01:00
proto_quic.c CLEANUP: assorted typo fixes in the code and comments 2021-01-06 17:32:03 +01:00
proto_sockpair.c MINOR: protocol: add a pair of check_events/ignore_events functions at the ctrl layer 2020-12-11 17:02:50 +01:00
proto_tcp.c MINOR: tcp: add support for defer-accept on FreeBSD. 2021-02-13 09:05:02 +01:00
proto_udp.c MINOR: udp: export udp_suspend_receiver() and udp_resume_receiver() 2020-12-08 18:10:18 +01:00
proto_uxst.c MINOR: protocol: add a pair of check_events/ignore_events functions at the ctrl layer 2020-12-11 17:02:50 +01:00
protocol.c CLEANUP: tree-wide: replace free(x);x=NULL with ha_free(&x) 2021-02-26 21:21:09 +01:00
proxy.c BUILD: proxy: Missing header inclusion for quic_transport_params_init() 2021-03-02 09:45:49 +01:00
qpack-tbl.c CLEANUP: qpack: Wrong comment about the draft for QPACK static header table. 2021-01-04 12:31:28 +01:00
queue.c MINOR: lb/api: let callers of take_conn/drop_conn tell if they have the lock 2021-02-18 10:06:45 +01:00
quic_cc_newreno.c MINOR: quic: Add traces to congestion avoidance NewReno callback. 2020-12-23 11:57:26 +01:00
quic_cc.c MINOR: quic: Import C source code files for QUIC protocol. 2020-12-23 11:57:26 +01:00
quic_frame.c CLEANUP: assorted typo fixes in the code and comments 2021-01-06 16:26:50 +01:00
quic_sock.c MINOR: quic: QUIC socket management finalization. 2020-12-23 11:57:26 +01:00
quic_tls.c MINOR: quic: Update the initial salt to that of draft-29. 2020-12-23 11:57:26 +01:00
raw_sock.c MINOR: raw_sock: Report the number of bytes emitted using the splicing 2020-07-15 14:08:14 +02:00
regex.c OPTIM: regex: PCRE2 use JIT match when JIT optimisation occured. 2020-08-14 07:53:40 +02:00
resolvers.c CLEANUP: tree-wide: replace free(x);x=NULL with ha_free(&x) 2021-02-26 21:21:09 +01:00
ring.c MINOR: ring: adds new ring_init function. 2021-02-13 09:43:17 +01:00
sample.c BUG/MINOR: sample: secure convs that accept base64 string and var name as args 2021-02-23 17:21:46 +01:00
server_state.c BUG/MINOR: server-state: Don't load server-state file for disabled backends 2021-03-04 16:49:10 +01:00
server.c CLEANUP: Use the ist() macro whenever possible 2021-03-05 08:28:53 +01:00
session.c BUG/MINOR: session: atomically increment the tracked sessions counter 2021-02-16 18:08:12 +01:00
sha1.c BUILD: use inttypes.h instead of stdint.h 2019-04-01 07:44:56 +02:00
shctx.c REORG: include: split global.h into haproxy/global{,-t}.h 2020-06-11 10:18:58 +02:00
signal.c REORG: include: move the error reporting functions to from log.h to errors.h 2020-06-11 10:18:59 +02:00
sink.c CLEANUP: tree-wide: replace free(x);x=NULL with ha_free(&x) 2021-02-26 21:21:09 +01:00
sock_inet.c MINOR: protocol: add a ->set_port() helper to address families 2020-12-04 15:08:00 +01:00
sock_unix.c CLEANUP: protocol: remove the now unused <handler> field of proto_fam->bind() 2020-10-15 21:47:56 +02:00
sock.c CLEANUP: tree-wide: replace free(x);x=NULL with ha_free(&x) 2021-02-26 21:21:09 +01:00
ssl_ckch.c CLEANUP: tree-wide: replace free(x);x=NULL with ha_free(&x) 2021-02-26 21:21:09 +01:00
ssl_crtlist.c CLEANUP: tree-wide: replace free(x);x=NULL with ha_free(&x) 2021-02-26 21:21:09 +01:00
ssl_sample.c MINOR: ssl-sample: Don't check if argument list is set in sample fetches 2021-01-29 13:26:24 +01:00
ssl_sock.c BUG/MINOR: ssl: don't truncate the file descriptor to 16 bits in debug mode 2021-03-05 08:30:08 +01:00
ssl_utils.c CLEANUP: ssl: ssl_sock_crt2der semicolon and spaces 2020-08-07 15:38:40 +02:00
stats.c CLEANUP: Use the ist() macro whenever possible 2021-03-05 08:28:53 +01:00
stick_table.c MINOR: stick-tables/counters: add http_fail_cnt and http_fail_rate data types 2021-02-10 12:27:01 +01:00
stream_interface.c MEDIUM: http-ana: Deal with L7 retries in HTTP analysers 2021-01-28 16:37:14 +01:00
stream.c MINOR: stream: use ABORT_NOW() and not abort() in stream_dump_and_crash() 2021-03-05 08:30:08 +01:00
task.c MINOR: task: only limit TL_HEAVY tasks but not others 2021-02-26 12:00:53 +01:00
tcp_act.c BUG/MINOR: tcp-act: Don't forget to set the original port for IPv4 set-dst rule 2021-03-01 11:28:54 +01:00
tcp_rules.c CLEANUP: Compare the return value of XXXcmp() functions with zero 2021-01-04 10:09:02 +01:00
tcp_sample.c MINOR: listener: prefer to retrieve the socket's settings via the receiver 2020-09-16 22:08:07 +02:00
tcpcheck.c CLEANUP: Use the ist() macro whenever possible 2021-03-05 08:28:53 +01:00
thread.c BUG/MINOR: threads: Fixes the number of possible cpus report for Mac. 2021-01-15 11:58:46 +01:00
time.c CLEANUP: assorted typo fixes in the code and comments 2020-07-06 14:34:32 +02:00
tools.c CLEANUP: tree-wide: replace free(x);x=NULL with ha_free(&x) 2021-02-26 21:21:09 +01:00
trace.c CLEANUP: Use isttest(const struct ist) whenever possible 2021-03-03 05:07:10 +01:00
uri_auth.c CLEANUP: Compare the return value of XXXcmp() functions with zero 2021-01-04 10:09:02 +01:00
vars.c CLEANUP: vars: always zero the pointers after a free() 2021-02-26 21:21:21 +01:00
version.c BUILD: Fix build by including haproxy/global.h 2020-06-16 23:36:04 +02:00
wdt.c CLEANUP: config: Return ERR_NONE from config callbacks instead of 0 2020-11-13 16:26:10 +01:00
wurfl.c CLEANUP: Use ist2(const void*, size_t) whenever possible 2021-03-01 15:44:20 +01:00
xprt_handshake.c MINOR: xprt/mux: export all *_io_cb functions so that "show fd" resolves them 2021-01-20 17:17:39 +01:00
xprt_quic.c CLEANUP: tree-wide: replace free(x);x=NULL with ha_free(&x) 2021-02-26 21:21:09 +01:00