From 9392b43e3cd91260d359af02587457895b93f105 Mon Sep 17 00:00:00 2001 From: Herbert Wolverson Date: Mon, 6 Mar 2023 15:58:57 +0000 Subject: [PATCH] Proper fix for submitting IP/CPU/Queue mapping batches. * Bring the per-client buffer size back down to a reasonable 2k. * Divide submission batches into groups and submit those. It's still MASSIVELY faster, but it can't fall victim to guessing the number of batches incorrectly. --- src/rust/lqos_bus/src/bus/unix_socket_server.rs | 2 +- src/rust/lqos_python/src/lib.rs | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/rust/lqos_bus/src/bus/unix_socket_server.rs b/src/rust/lqos_bus/src/bus/unix_socket_server.rs index 8a1137f9..e209f67b 100644 --- a/src/rust/lqos_bus/src/bus/unix_socket_server.rs +++ b/src/rust/lqos_bus/src/bus/unix_socket_server.rs @@ -12,7 +12,7 @@ use tokio::{ use super::BUS_SOCKET_DIRECTORY; -const READ_BUFFER_SIZE: usize = 2048000; +const READ_BUFFER_SIZE: usize = 20_480; /// Implements a Tokio-friendly server using Unix Sockets and the bus protocol. /// Requests are handled and then forwarded to the handler. diff --git a/src/rust/lqos_python/src/lib.rs b/src/rust/lqos_python/src/lib.rs index a38ccfd0..c90ba177 100644 --- a/src/rust/lqos_python/src/lib.rs +++ b/src/rust/lqos_python/src/lib.rs @@ -178,11 +178,15 @@ impl BatchedCommands { } pub fn submit(&mut self) -> PyResult { + const MAX_BATH_SIZE: usize = 512; // We're draining the request list out, which is a move that // *should* be elided by the optimizing compiler. let len = self.batch.len(); - let batch: Vec = self.batch.drain(0..).collect(); - run_query(batch).unwrap(); + while !self.batch.is_empty() { + let batch_size = usize::min(MAX_BATH_SIZE, self.batch.len()); + let batch: Vec = self.batch.drain(0..batch_size).collect(); + run_query(batch).unwrap(); + } Ok(len) } }