[libc-commits] [libc] [libc] Scan the ports more fairly in the RPC server (PR #66680)
Joseph Huber via libc-commits
libc-commits at lists.llvm.org
Sat Sep 23 16:41:53 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) {
----------------
jhuber6 wrote:
Look at the greater scope. This isn't `handle_server` this is `try_open`. `handle_server` passes in `start` as the last position it found a port. If we instead always check starting at `N` we will then continuously check forever as long as there is work still being submitted faster to the RPC interface than it can consume it. We can potentially do that, but I was just thinking that it would be good to guarantee that this routine, when called by a blocking thread, will return in a specific number of checks.
https://github.com/llvm/llvm-project/pull/66680
More information about the libc-commits
mailing list