Repository navigation
Description
CommandHub::register_client (bin/src/command/server.rs:370) builds every command-socket client
channel with a literal initial capacity:
let channel = Channel::new(stream, 4096, self.config.max_command_buffer_size);The ceiling comes from configuration. The initial capacity does not. command_buffer_size is an
operator-facing global, and this is the one channel kind it never reaches.
The asymmetry is the defect, not the number
The three channel kinds the binary builds:
- supervisor↔worker —
bin/src/worker.rs:119and:315,bin/src/upgrade.rs:204and:303,
bin/src/command/server.rs:500:command_buffer_size,max_command_buffer_size. - the CLI's own channel —
bin/src/ctl/mod.rs:261-264:config.command_buffer_size,
config.max_command_buffer_size. - the command-socket client channel —
bin/src/command/server.rs:370:4096,
config.max_command_buffer_size.
So a global whose name promises to size the command buffers is silently inert for one of its three
consumers, and nothing in the configuration file says so.
That is not something documentation can repair, only describe. doc/configure_admin_ops.md §5.2 has
to carve the exception out by hand in the middle of the command_buffer_size table row — the role
cell is 55 words, most of them spent saying which channels obey the key and which one does not —
because there is no rule to state.
The reallocation cost is the weak argument and should not be the one carrying this
From 4096 to the 2_000_000 default ceiling is nine doublings: grow_size
(command/src/channel.rs:254) is min(current_capacity * 2, max_buffer_size). Nine reallocations,
amortised against protobuf encoding and the socket writes of a state save response, are noise.
"Raise 4096" on performance grounds is not worth a change and is not what this asks for.
What does weigh: the accept loop has no connection cap. bin/src/command/server.rs:620-622:
while let Ok((stream, _addr)) = self.unix_listener.accept() {
self.register_client(stream);
}Whatever the per-client initial capacity is, it multiplies across concurrently registered sessions.
That is an argument for the number being deliberate, visible and operator-reachable — in either
direction — not for it being larger.
Suggested resolution
Derive it or make it configurable, rather than raise it. Two shapes, and they answer different
questions:
- Derive from the existing key:
min(config.command_buffer_size, config.max_command_buffer_size).
The global then means what its name says for all three channel kinds, and §5.2's exception clause
disappears instead of having to be maintained. - Give the client channel its own key, if
4096is a deliberate choice for a session kind that
is many-per-process while the other two are one-or-few. The exception is then named in the
configuration rather than implicit in the source.
What should not stay is a global that is inert for one of its three consumers with no way to tell
from the configuration.
Priority
Low. The command socket is created 0o600 (fs::set_permissions, bin/src/command/mod.rs:100), so
reaching that accept loop already requires the same UID as the sozu process, and
command_allowed_uids (bin/src/command/requests.rs:295) narrows it further at the request layer.
This is a configuration-coherence defect, not a reachable resource one.
What I verified, and what I did not
Verified by reading the tree at 595920e91c4528f0554410b904b45d543c88e467: the literal 4096 and
the configured ceiling at bin/src/command/server.rs:370; the uncapped accept loop at
bin/src/command/server.rs:620-622; every other Channel::new/Channel::generate site, enumerated
with grep -rn 'Channel::new\|Channel::generate' --include='*.rs' ., confirming that the supervisor↔worker
and CLI channels take command_buffer_size and that bin/src/command/server.rs:370 is the only
production site that does not; the doubling in grow_size at command/src/channel.rs:254; and the
0o600 socket mode at bin/src/command/mod.rs:100.
Not verified: I did not measure the reallocation cost of a state save response, nor benchmark
4096 against a derived value — "nine doublings is noise" is arithmetic over grow_size, not a
measurement. I also did not trace whether 4096 was chosen deliberately or inherited, and I did not
check whether any operator has actually set command_buffer_size expecting it to apply here.
Activity
docs(command): record why the client channel ignores command_buffer_size
docs(command): record why the client channel ignores command_buffer_size
docs(command): record why the client channel ignores command_buffer_size
docs(command): record why the client channel ignores command_buffer_size
docs(command): record why the client channel ignores command_buffer_size
docs(command): record why the client channel ignores command_buffer_s…