Integrating QSBR with libuv
Ondřej Surý via lttng-dev <[email protected]> Wed, 16 Jul 2025 06:09:22 +0200
| Newsgroups | org.lttng.lists.lttng-dev |
|---|---|
| Message-ID | <[email protected]> |
--Apple-Mail-9E68AFA5-920A-425B-9A53-6E4953BE8C5C Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable <html><head><meta http-equiv=3D"content-type" content=3D"text/html; charset=3D= utf-8"></head><body dir=3D"auto"><div>Hi,</div><div><br></div><div>currently= , the BIND 9 design involves multiple threads with per-thread event loop fro= m libuv (uv_loop).</div><div><br></div><div>We are using the default rcu var= iant, but it seems like an ideal place to switch to QSBR as we can call quie= scent state periodically before polling on the loop.</div><div><br></div><di= v>This comes with one trouble though. The incoming traffic is distributed us= ing SO_REUSEPORT load-balancing in the kernel and if the hashing algorithm i= s too simple or the traffic just hashes only into 1..n-1 threads, the memory= reclamation will never trigger (means indefinite wait for synchronize_rcu()= or indefinite queue in the call_rcu).</div><div><br></div><div>Now, I have b= asically two solutions I can think of:</div><div><br></div><div>1. Bring the= threads offline before polling and online after polling. This has two probl= ems: a) there=E2=80=99s overhead related to calling thread_offline/thread_on= line and it is unclear to me how big overhead this is; b) currently, there i= s no way to bring the thread online before libuv callbacks are called - = ;<a href=3D"https://github.com/libuv/libuv/issues/4839#issuecomment-30764932= 38">https://github.com/libuv/libuv/issues/4839</a></div><div><br></div><div>= 2. Add short per event loop periodic timer that would call the quiescent sta= te every <n> ms, but I have a vague recollection that unneeded periodi= c timers mess with the power management as they wake up the process even whe= n it would be otherwise completely idle.</div><div><br></div><div>The bonus t= hird option is to give up on this because there are lower hanging fruits to i= mprove the performance than the membarrier vs QSBR. That=E2=80=99s certainly= true, but it is an interesting software engineering problem, so I am not re= ady to give this up easily ;). And coming up with a solution to this could l= ead to at least a blog post that more project could benefit from a solution t= o this. (For a moment, pausing from the grim world we live in now where ever= y idea gets sucked into LLM and venture capital.)</div><div><br></div>Ondrej= <br id=3D"lineBreakAtBeginningOfSignature"><div dir=3D"ltr"><span style=3D"b= ackground-color: rgba(255, 255, 255, 0);">--</span><div><span style=3D"backg= round-color: rgba(255, 255, 255, 0);">Ond=C5=99ej Sur=C3=BD (He/Him)</span><= /div></div></body></html>= --Apple-Mail-9E68AFA5-920A-425B-9A53-6E4953BE8C5C--