Skip to content

Conversation

@HynoR
Copy link
Contributor

@HynoR HynoR commented Dec 8, 2025

What this PR does / why we need it?

查找进程为了不必要的逻辑分配了更多的性能开销,本身每次proc.process 就会遍历一次链接,为了消化这么多遍历又用多线程来解决, 再加上锁和排序的开销,导致整体函数比较臃肿。

Summary of your change

  • 修改方案,从原本的gopsutil每个进程遍历+过滤链接,变成只gopsutil拿一次全部链接,然后自行用map 和进程 pid 对号入座。
  • 预分配切片大小减少扩容分配。
  • 移除多线程相关逻辑,直接单线程执行优化后的方案

单线程的新方案执行速度是原本多线程遍历的一倍,并且内存开支更低,gc 更稳定。
image

测试返回内容没有变化
image

Please indicate you've done the following:

  • Made sure tests are passing and test coverage is added if needed.
  • Made sure commit message follow the rule of Conventional Commits specification.
  • Considered the docs impact and opened a new docs issue or PR with docs changes if needed.

- Replaced goroutine-based processing with a direct loop for handling process data.
- Introduced context support for process and connection retrieval.
- Enhanced error handling and data structuring for process information.
- Improved SSH session retrieval by mapping users by host for better efficiency.
@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Dec 8, 2025

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Dec 8, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign zhengkunwang223 for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@HynoR HynoR marked this pull request as draft December 8, 2025 03:11
@HynoR HynoR marked this pull request as ready for review December 8, 2025 09:33
@zhengkunwang223
Copy link
Member

/LGTM

@zhengkunwang223 zhengkunwang223 merged commit 3a1b9fe into 1Panel-dev:dev-v2 Dec 8, 2025
0 of 3 checks passed
@f2c-ci-robot f2c-ci-robot bot added the lgtm label Dec 8, 2025
@HynoR HynoR deleted the pr@processdara branch December 8, 2025 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants