You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sdssplitargs() builds each argument one byte at a time via sdscatlen(), which uses greedy doubling allocation. This leaves significant unused space in each SDS string — for a 600-byte value, ~400 bytes are wasted.
Add sdsRemoveFreeSpace() after sdssplitargs() in processInlineBuffer() to trim each argument before wrapping it in an robj.
Measured with 1M SET commands with 600-byte values piped via redis-cli --pipe in inline format:
Before: 1,021 MB vs 655 MB for RESP (55.9% overhead)
Low Risk
Single-path memory optimization in inline parsing with no protocol or auth changes; behavior unchanged aside from lower per-argument allocation.
Overview
Inline command parsing (processInlineBuffer) now trims each argument SDS with sdsRemoveFreeSpace() right after sdssplitargs(), before arguments are wrapped in robjs.
sdssplitargs() grows strings greedily byte-by-byte, which left large unused capacity per argument (especially for big values). That extra memory showed up as much higher RSS for pipelined inline traffic than RESP; after trimming, inline usage aligns with the RESP baseline.
Reviewed by Cursor Bugbot for commit 24c18b1. Bugbot is set up for automated code reviews on this repo. Configure here.
When the argv value is small, this PR actually doesn't have any effect. But why would someone use Inline to send commands of 600 bytes?
AFAIK, inline was only used for simple manual commands.
One scenario where larger inline payloads could occur is redis-cli --pipe with plaintext input, which goes through the inline parser. There is nothing prevents users from piping plaintext with larger values. That said, I don't have evidence this is common in practice. If you don't think it's worth it, I'm happy to withdraw the PR.
One scenario where larger inline payloads could occur is redis-cli --pipe with plaintext input, which goes through the inline parser. There is nothing prevents users from piping plaintext with larger values. That said, I don't have evidence this is common in practice. If you don't think it's worth it, I'm happy to withdraw the PR.
This change touches performance-sensitive code paths. Adding the action:run-benchmark label will trigger the CE Performance suite so we can see the impact before merge.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR is based on valkey-io/valkey#1213.
sdssplitargs() builds each argument one byte at a time via sdscatlen(), which uses greedy doubling allocation. This leaves significant unused space in each SDS string — for a 600-byte value, ~400 bytes are wasted.
Add sdsRemoveFreeSpace() after sdssplitargs() in processInlineBuffer() to trim each argument before wrapping it in an robj.
Measured with 1M SET commands with 600-byte values piped via
redis-cli --pipein inline format:Co-authored-by: muelstefamzn muelstef@amazon.com
Note
Low Risk
Single-path memory optimization in inline parsing with no protocol or auth changes; behavior unchanged aside from lower per-argument allocation.
Overview
Inline command parsing (
processInlineBuffer) now trims each argument SDS withsdsRemoveFreeSpace()right aftersdssplitargs(), before arguments are wrapped inrobjs.sdssplitargs()grows strings greedily byte-by-byte, which left large unused capacity per argument (especially for big values). That extra memory showed up as much higher RSS for pipelined inline traffic than RESP; after trimming, inline usage aligns with the RESP baseline.Reviewed by Cursor Bugbot for commit 24c18b1. Bugbot is set up for automated code reviews on this repo. Configure here.