scripts: 优化 tproxy.sh 启动速度减少子进程 fork#16
Open
Fanju6 wants to merge 1 commit into
Open
Conversation
- 使用 Shell 原生参数代换(如 `${var%/*}`、`${var##*/}`)替代外部 `dirname` 和 `basename` 工具。
- 在网卡接口遍历循环使用内建的 `read` 重定向读取替代子 shell `cat`消除循环中的 fork 开销。
- 将内核特征检查优化为一次性读取并缓存至 `ENABLED_CONFIGS` 变量,改用模式匹配完成检测,将 `grep` 的 fork 次数从 12 次降为1 次。
- 优化 root 身份校验逻辑,读取内建的 `$UID` 变量以避开 `id` 进程拉起。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
-使用 Shell 原生参数代换(如${var%/*}、${var##*/})替代外部dirname和basename工具。read重定向读取替代子 shellcat消除循环中的 fork 开销。ENABLED_CONFIGS变量,改用模式匹配完成检测,将grep的 fork 次数从 12 次降为1 次。$UID变量以避开id进程拉起。