feat(execd): tune jupyter idle polling and sse completion wait#577
Conversation
There was a problem hiding this comment.
Pull request overview
This PR reduces execd’s SSE tail latency and makes Jupyter “idle” post-processing polling configurable, targeting an observed execution latency regression in sandboxed environments.
Changes:
- Add a configurable Jupyter idle polling interval via
EXECD_JUPYTER_IDLE_POLL_INTERVAL/--jupyter-idle-poll-interval. - Replace the fixed
300mspost-idle polling sleep with the configured interval in Jupyter streaming execution. - Update SSE endpoints (
RunCode,RunInSession) to wait forOnExecuteComplete(best-effort) instead of always sleeping a fixed graceful shutdown window.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
| components/execd/pkg/web/controller/codeinterpreting.go | Switch SSE tail behavior from unconditional sleep to best-effort completion wait. |
| components/execd/pkg/jupyter/execute/execute.go | Make post-idle polling interval configurable rather than hard-coded. |
| components/execd/pkg/flag/parser.go | Add env/CLI parsing for the new Jupyter idle poll interval. |
| components/execd/pkg/flag/flags.go | Add the new global flag variable for Jupyter idle polling interval. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Could you fix those go linter error by |
|
I fixed two blockers: the golangci-lint failure and the C# E2E error-contract regression. |
Thanks for your GREAT submission. I will review it and merge it as soon as possible. |
Hello,Jiping, What is the latest available execd image version? |
I’ll take care of it today or tomorrow. |
Summary
This PR improves execd's Jupyter execution stream handling and SSE tail latency behavior.
Changes included:
EXECD_JUPYTER_IDLE_POLL_INTERVAL/--jupyter-idle-poll-interval300mspost-idle polling sleep with the configured poll intervalRunCodeandRunInSessionto wait forOnExecuteCompleteas a best-effort signal instead of always sleeping for a fixed graceful shutdown windowBackground
This change was motivated by an execution latency regression observed on code execution nodes.
Based on local observation:
60ms2.4sAfter tracing the slow path, the added tail latency was mainly caused by fixed waiting behavior in the execd execution flow. With this change, the observed latency was
reduced to around
100msin the same scenario.Motivation
Previously:
300msintervalThis change makes the Jupyter idle polling behavior configurable and reduces unnecessary fixed response tail latency for SSE endpoints.
Testing
Executed under
components/execd:go test ./pkg/flaggo test ./pkg/jupyter/executego test ./...go test -race ./...golangci-lint run -v ./...Results:
go test ./pkg/flag: passgo test ./pkg/jupyter/execute: passgo test ./...: fails on existingpkg/web/controller TestReadMetricsgo test -race ./...: fails on existingpkg/web/controller TestReadMetricsand an existing race inpkg/runtimegolangci-lint run -v ./...: reports existinggocognitcomplexity issue atpkg/jupyter/execute/execute.go:117Notes
components/execd.