Replies: 1 comment
|
Your timing matches an unconditional server-side sleep, not a client-side SSE parsing delay. In the current time.Sleep(flag.ApiGracefulShutdownTimeout)That is here: OpenSandbox/components/execd/pkg/web/controller/command.go Lines 71 to 121 in 48b0215 The completion callback is signalled only after the final event writer returns. OpenSandbox/components/execd/pkg/web/controller/sse.go Lines 187 to 215 in 48b0215 So, for stdout/stderr/completion delivery inside execd itself, the extra second is not waiting for an acknowledgement or draining a queue. It is a fixed tail delay after the event has been written and flushed. There is an interesting history detail. PR #1216 added an explicit completion channel plus a ping-goroutine shutdown barrier to fix the actual response-writer race. Its commit message says it replaces the fixed sleep with explicit cancel-and-wait, and the code comment at lines 71-73 says the handler should return immediately to avoid fixed tail latency. The old sleep nevertheless remains at line 121. The new adjacent comment gives a second rationale, allowing downstream components such as the egress sidecar to synchronize, but there is no downstream acknowledgement tied to that sleep. See 97a450a For the configuration questions:
For latency-sensitive commands that do not change that downstream state, |
Uh oh!
There was an error while loading. Please reload this page.
Description
I noticed that foreground
command_runcalls have an almost constant ~1 second overhead, even for commands that complete almost immediately, such as:In my tests, filesystem APIs such as
file_read,file_write, andfile_create_directoriesusually complete within about 10–15 ms, whilecommand_runconsistently takes around 1.01 s.After breaking down the HTTP/SSE timing, most of the extra latency appears after the command has already completed and the final SSE events have been sent.
The execd documentation mentions:
and the corresponding environment variable:
Questions
I would like to understand the design rationale behind this default 1 second delay:
Why is a 1 second tail-drain window needed after the final command SSE event has already been sent?
What specific issue is this grace period intended to prevent?
Is it safe and supported to set:
for latency-sensitive workloads?
4. If
0sis not recommended, would a smaller value such as50msor100msnormally be sufficient?5. Is the 1 second default mainly a conservative compatibility/reliability choice, or is there a known case that actually requires a delay this long?
Observed timing
The command itself appears to finish very quickly, but the HTTP/SSE request remains open for approximately another second.
Conceptually, the timing looks like:
This makes very short shell commands have roughly the same ~1.01 s latency regardless of the actual command execution time.
Environment
opensandbox): 0.1.15/commandexecutionThanks! I mainly want to understand whether this 1 second delay is required for correctness, or whether reducing/disabling it is an expected configuration for latency-sensitive scenarios.
All reactions