# PR #20668 完整报告

- 仓库：`sgl-project/sglang`
- 标题：refactor: Remove dead code from utils/common.py
- 合并时间：2026-03-22 12:54
- 原文链接：http://prhub.com.cn/sgl-project/sglang/pull/20668

---

## 执行摘要

本 PR 移除了 `utils/common.py` 中的死代码，包括多个未使用的函数和导入，以减少代码噪音并提升可维护性。变更已验证安全，无任何功能影响，属于常规维护性质。

## 功能与动机

`sglang/srt/utils/common.py` 模块中累积了多个在先前 PR 中失去调用者的函数，例如 `get_float_env_var` 和 `decode_video_base64`，这些代码成为死代码，增加了维护负担。移除它们可以保持模块精简，避免未来开发时的混淆，并遵循代码清洁的最佳实践。

## 实现拆解

在 `python/sglang/srt/utils/common.py` 中，删除了以下未使用的符号：

| 符号 | 用途 | 移除原因 |
|------|------|----------|
| `get_float_env_var` | 环境变量处理 | 已迁移到 `environ.py` (#14501) |
| `decode_video_base64` | 视频解码 | 被 `load_video` 替代 (#5888) |
| `pytorch_profile` 和 `step_counter` | 性能分析 | 分析路径已移除 (#1652) |
| `dump_to_file` | 数据转储 | 被 tensor dump hook 替代 (#10566) |
| `maybe_torch_compile` 和 `is_triton_3` | Torch 编译 | 直接使用 `torch.compile` (#3039) |

同时移除了未使用的导入 `from torch.profiler import ...`。通过全仓库 grep 验证无残留引用。

## 评论区精华

review 中仅有一个 bot 评论支持此变更：

> "This pull request removes several unused functions and variables from `utils/common.py`, which is a good refactoring practice to reduce code noise and improve maintainability."

无其他讨论或争议，变更被迅速接受。

## 风险与影响

风险极低：删除的是已验证无调用者的死代码，不会影响现有功能。已通过全仓库 grep 验证无引用，确保安全。对用户无感知，仅提升代码库质量；对团队减少维护开销，提高模块可读性。

## 关联脉络

本 PR 清理的死代码源于以下历史 PR 的变更，显示了代码库的持续演进：
- #14501: 将环境变量处理迁移到 `environ.py`，使 `get_float_env_var` 成为死代码。
- #5888: 用 `load_video` 替代 `decode_video_base64`。
- #1652: 移除性能分析路径，使 `pytorch_profile` 和 `step_counter` 失效。
- #10566: 引入 tensor dump hook 替换 `dump_to_file`。
- #3039: 直接使用 `torch.compile`，废弃 `maybe_torch_compile` 和 `is_triton_3`。

这些关联 PR 共同促进了代码现代化，本 PR 是清理遗留代码的后续步骤。