[libc-commits] [libc] [libc] Scan the ports more fairly in the RPC server (PR #66680)

Johannes Doerfert via libc-commits libc-commits at lists.llvm.org
Sat Sep 23 16:35:09 PDT 2023


================
@@ -560,9 +562,9 @@ template <uint16_t opcode> LIBC_INLINE Client::Port Client::open() {
 template <uint32_t lane_size>
 [[clang::convergent]] LIBC_INLINE
     cpp::optional<typename Server<lane_size>::Port>
-    Server<lane_size>::try_open() {
+    Server<lane_size>::try_open(uint32_t start) {
   // Perform a naive linear scan for a port that has a pending request.
-  for (uint32_t index = 0; index < process.port_count; ++index) {
+  for (uint32_t index = start; index < process.port_count; ++index) {
----------------
jdoerfert wrote:

So, I am not seeing this to run through all N ports. Let's see the last picked one is N-2, then index is N-1, and this checks only a single port, namely N-1. Before, it always checked N ports, but always starting at 0. What we want is N (=all) ports are checked, but starting at the last picked index so you can't starve a port since the one we picked last is checked last in the next run. My proposal was to run N checks, nothing unbounded.

https://github.com/llvm/llvm-project/pull/66680


More information about the libc-commits mailing list