Skip to content

scripts: 优化 tproxy.sh 启动速度减少子进程 fork#16

Open
Fanju6 wants to merge 1 commit into
CHIZI-0618:mainfrom
Fanju6:main
Open

scripts: 优化 tproxy.sh 启动速度减少子进程 fork#16
Fanju6 wants to merge 1 commit into
CHIZI-0618:mainfrom
Fanju6:main

Conversation

@Fanju6
Copy link
Copy Markdown
Contributor

@Fanju6 Fanju6 commented May 30, 2026

- 使用 Shell 原生参数代换(如 ${var%/*}${var##*/})替代外部 dirnamebasename 工具。

  • 在网卡接口遍历循环使用内建的 read 重定向读取替代子 shell cat消除循环中的 fork 开销。
  • 将内核特征检查优化为一次性读取并缓存至 ENABLED_CONFIGS 变量,改用模式匹配完成检测,将 grep 的 fork 次数从 12 次降为1 次。
  • 优化 root 身份校验逻辑,读取内建的 $UID 变量以避开 id 进程拉起。

- 使用 Shell 原生参数代换(如 `${var%/*}`、`${var##*/}`)替代外部 `dirname` 和 `basename` 工具。
- 在网卡接口遍历循环使用内建的 `read` 重定向读取替代子 shell `cat`消除循环中的 fork 开销。
- 将内核特征检查优化为一次性读取并缓存至 `ENABLED_CONFIGS` 变量,改用模式匹配完成检测,将 `grep` 的 fork 次数从 12 次降为1 次。
- 优化 root 身份校验逻辑,读取内建的 `$UID` 变量以避开 `id` 进程拉起。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant