执行摘要
本次PR修复了CI清理脚本killall_sglang无法匹配主服务器进程sglang serve的问题,通过修改正则表达式确保进程被正确杀死,避免端口占用残留。变更简单但关键,提升了CI稳定性。
功能与动机
killall_sglang脚本用于在CI测试后清理SGLang进程,但原有正则模式仅匹配子进程(如sglang::*),而主进程命令行格式为/usr/local/bin/python3 /usr/local/bin/sglang serve ...,导致主进程遗漏。这会造成HTTP端口占用,影响后续测试运行。PR body明确指出:“The root process (which owns the uvicorn HTTP server and the listening port) is the only one missed.”
实现拆解
仅修改一个文件:python/sglang/cli/killall.py。
关键变更:将正则表达式从
r"sglang::|sglang\\.launch_server|sglang\\.bench|sglang\\.data_parallel|sglang\\.srt|sgl_diffusion::"
更新为
r"sglang::|sglang\\.launch_server|sglang\\.bench|sglang\\.data_parallel|sglang\\.srt|sgl_diffusion::|sglang serve"
添加|sglang serve以匹配主进程。
评论区精华
reviewer gemini-code-assist[bot]提出两点重要反馈:
“Please update the shell script as well to ensure local cleanup works as expected.”
“consider if other CLI subcommands like sglang bench should be included; the current regex matches sglang.bench (with a dot) for python -m, but misses the CLI wrapper sglang bench (with a space).”
这揭示了脚本间不一致和子命令覆盖不全的潜在问题,但本次PR未采纳这些建议。
风险与影响
- 风险:若未同步更新shell脚本
scripts/killall_sglang.sh,本地环境可能清理不彻底;正则仍可能遗漏其他CLI子命令(如sglang bench带空格形式)。
- 影响:CI测试后端口释放更可靠,减少因进程残留导致的失败;对核心服务无影响。
关联脉络
从近期历史PR看,多个PR涉及CI稳定性修复(如#22083修复死锁、#21735修复内存泄漏),本次PR是这一趋势的延续,聚焦于进程清理环节。与#15562(添加使用统计)等PR无直接关联,但共同维护了测试环境的健壮性。
参与讨论