<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Hi,</div><div><br></div><div>currently, the BIND 9 design involves multiple threads with per-thread event loop from libuv (uv_loop).</div><div><br></div><div>We are using the default rcu variant, but it seems like an ideal place to switch to QSBR as we can call quiescent state periodically before polling on the loop.</div><div><br></div><div>This comes with one trouble though. The incoming traffic is distributed using SO_REUSEPORT load-balancing in the kernel and if the hashing algorithm is 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 basically 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 problems: a) there’s overhead related to calling thread_offline/thread_online and it is unclear to me how big overhead this is; b) currently, there is no way to bring the thread online before libuv callbacks are called - <a href="https://github.com/libuv/libuv/issues/4839#issuecomment-3076493238">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 state every <n> ms, but I have a vague recollection that unneeded periodic timers mess with the power management as they wake up the process even when it would be otherwise completely idle.</div><div><br></div><div>The bonus third option is to give up on this because there are lower hanging fruits to improve the performance than the membarrier vs QSBR. That’s certainly true, but it is an interesting software engineering problem, so I am not ready to give this up easily ;). And coming up with a solution to this could lead to at least a blog post that more project could benefit from a solution to this. (For a moment, pausing from the grim world we live in now where every idea gets sucked into LLM and venture capital.)</div><div><br></div>Ondrej<br id="lineBreakAtBeginningOfSignature"><div dir="ltr"><span style="background-color: rgba(255, 255, 255, 0);">--</span><div><span style="background-color: rgba(255, 255, 255, 0);">Ondřej Surý (He/Him)</span></div></div></body></html>