From 50c73900872ba8c1e1a791a0dcee69190f9ab25e Mon Sep 17 00:00:00 2001 From: crusaderky Date: Tue, 31 Oct 2023 19:56:22 +0100 Subject: [PATCH] Faster small buffers --- distributed/comm/tcp.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/distributed/comm/tcp.py b/distributed/comm/tcp.py index 79e8046743d..189b130678b 100644 --- a/distributed/comm/tcp.py +++ b/distributed/comm/tcp.py @@ -418,8 +418,11 @@ def _add_frames_header( frames_nbytes = [header_nbytes, *frames_nbytes] frames_nbytes_total += header_nbytes - if frames_nbytes_total < 2**17: # 128kiB - # small enough, send in one go + if frames_nbytes_total < 2**17 or ( # 128 kiB total + frames_nbytes_total < 2**25 # 32 MiB total + and frames_nbytes_total // len(frames) < 2**15 # 32 kiB mean + ): + # very small or very fragmented; send in one go frames = [b"".join(frames)] frames_nbytes = [frames_nbytes_total]