Avoid preallocating fat querybuf after big-arg steal (#5052)
Sole Author: Patrick Ribbsaeter (@patrickswedish) · Immutable Commit SHA: 42518fbfd71a8426fd8e3f3b0bea8567c3fff162
Networking buffer fix replacing eager multi-megabyte SDS_NOINIT preallocation after zero-copy big-arg extraction in parseMultibulk() with tight buffer sizing, eliminating O(N) memmove stalls.

PR #5052
100% CI GREEN · 28/28
42518fb
Immutable Git SHA
C
Systems
28/28 CI Green
CI & Test Matrix
01 · Engineering problem
The failure mode
After stealing c->querybuf for a big bulk argument (>= 32 KB), parseMultibulk() preallocated a new c->querybuf of size c->bulklen + 2, preventing buffer trimming and causing O(N) memmove stalls on trailing pipelined commands.
02 · Technical response
What changed
- 01Replaced fat SDS_NOINIT preallocation with sdsempty() after extracting the big argument and copying trailing pipelined bytes into a compact buffer.
- 02Updated tests/unit/querybuf.tcl with memory-bound assertions across pipelined big-arg streams.
03 · Verified outcome
Evidence-backed result
- ✓Passed 39/39 Valkey CI checks on commit 42518fbfd71a8426fd8e3f3b0bea8567c3fff162.
04 · Cryptographic Git record
Immutable source evidence
Independent open-source engineering authored solely by Patrick Ribbsaeter (@patrickswedish). Company and project names identify the public repository context only under nominative fair use. No employment, client, vendor, or partnership relationship is implied unless explicitly stated.