]> git.ipfire.org Git - thirdparty/haproxy.git/commit
OPTIM: mux-h2: use tasklet_wakeup_after() in h2s_notify_recv()
authorWilly Tarreau <w@1wt.eu>
Sat, 12 Oct 2024 10:43:34 +0000 (12:43 +0200)
committerWilly Tarreau <w@1wt.eu>
Sat, 12 Oct 2024 15:17:51 +0000 (17:17 +0200)
commitfcab647613189b99a3c7310a5efaa92f8cb55ecc
tree8a0b4ee7b37bc97eaa5c8a8319a634a9ee025f6c
parent04ce6536e15148c574a1589e5975cf21b3862ece
OPTIM: mux-h2: use tasklet_wakeup_after() in h2s_notify_recv()

This reduces the avg wakeup latency of sc_conn_io_cb() from 1900 to 51us.
The L2 cache misses from from 1.4 to 1.2 billion for 20k req. But the
perf is not better. Also there are situations where we must not perform
such wakeup, these may only be done from h2_io_cb, hence the test on the
next_tasklet pointer and its reset when leaving the function. In practice
all callers to h2s_close() or h2s_destroy() can reach that code, this
includes h2_detach, h2_snd_buf, h2_shut etc.

Another test with 40 concurrent connections, transferring 40k 1MB objects
at different concurrency levels from 1 to 80 also showed a 21% drop in L2
cache misses, and a 2% perf improvement:

Before:
   329,510,887,528  instructions
    50,907,966,181  branches
       843,515,912  branch-misses
     2,753,360,222  cache-misses
    19,306,172,474  L1-icache-load-misses
    17,321,132,742  L1-dcache-load-misses
       951,787,350  LLC-load-misses

      44.660469000 seconds user
      62.459354000 seconds sys

   => avg perf: 373 MB/s

After:
   331,310,219,157  instructions
    51,343,396,257  branches
       851,567,572  branch-misses
     2,183,369,149  cache-misses
    19,129,827,134  L1-icache-load-misses
    17,441,877,512  L1-dcache-load-misses
       906,923,115  LLC-load-misses

      42.795458000 seconds user
      62.277983000 seconds sys

   => avg perf: 380 MB/s

With small requests, it's the L1 and L3 cache misses which reduced by
3% and 7% respectively, and the performance went up by 3%.
src/mux_h2.c