[Feature] 运行窗口 CPU/内存曲线改用原生进程表与 Core 汇总,删除 ps/PowerShell 采样

Đang mở
#1,925 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
45/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
go, rust, typescript
Lĩnh vực
desktop, performance

Hướng nghiên cứu

Read desktop/internal/workbench/run_performance.go and the sysinfo.Process implementations under desktop/internal/sysinfo/ to trace the existing sampling path. Then inspect the Rust Core processMemory.summarize entry point and its shared fixtures; the issue calls for coverage of PID reuse, cycles, and process exit. Done means the run window uses native process data and Core aggregation, its memory figures match the status bar, and the old SampleProcessTree parsing code and related tests are removed.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

refactor review: high
Problem to solve / 要解决的问题

运行窗口的 CPU/内存曲线(desktop/internal/workbench/run_performance.go 的 startRunSampling)通过 pluginservice.SampleProcessTree 采样,实现在 desktop/internal/pluginservice/processsample.go、processsample_unix.go、processsample_windows.go:

  • 每个运行中的任务每 2 秒启动一次外部命令读整张进程表:macOS/Linux 是 ps -axo pid=,ppid=,pcpu=,rss=,Windows 是 powershell ... Get-CimInstance Win32_Process。PowerShell 冷启动本身就要几百毫秒和几十 MB 内存,多个运行同时存在时成倍增加。
  • 内存口径是 RSS(Windows 是 WorkingSetSize),和活动监视器、任务管理器“内存”列不同。状态栏内存详情已改为 macOS 物理占用(ri_phys_footprint)、Windows 专用工作集(desktop/internal/sysinfo/process*.go 的 sysinfo.Processes),同一个进程在两处会显示不同的数字。
  • 按父进程汇总进程树(parsePSTable、parseWindowsTable)和 CPU 占比的计算写在 Go 平台层,属于可共享逻辑,按 develop-lithe 第三节应在 Rust Core。

判定依据:全仓库搜索 SampleProcessTree,唯一调用方是 run_performance.go:34;parsePSTable、psCommand、parseWindowsTable 只被这条路径使用。保留它的代价:每 2 秒一次子进程启动的开销、两处内存数字不一致,以及一份未进 Core 的进程树汇总逻辑。

Proposed solution / 建议方案
  1. sysinfo.Process 增加累计 CPU 时间(macOS proc_pid_rusage 的 ri_user_time + ri_system_time,Windows GetProcessTimes,Linux /proc/<pid>/stat 的 utime+stime),三端都不启动子进程。
  2. 进程树汇总和两次采样之间的 CPU 占比计算放进 Rust Core(可以扩展 processMemory.summarize 以某个根进程为范围,或新增一条命令),共享 fixture 覆盖进程号复用、环和进程退出。
  3. 运行曲线改用原生进程表和 Core 的结果,内存口径与状态栏内存详情一致;删除 SampleProcessTree、parsePSTable、psCommand、parseWindowsTable 和 Windows 的 windowsCPU 缓存及对应测试。

风险:运行曲线的内存数字会从 RSS 变为物理占用/专用工作集,通常比原来小;需要在运行窗口的说明里同步口径。

Target platform / 目标平台

Cross-platform / 跨平台

Area / 模块

Run / 运行

Priority / 优先级

P2 / 后续考虑:目前不着急,可安排到后续版本

Alternatives considered / 已考虑的替代方案

保留 ps/PowerShell,只把内存列换成同一口径:ps 拿不到物理占用,PowerShell 的启动开销也还在,所以不采用。

Additional context / 补充信息

状态栏内存详情改用原生进程表和 Core processMemory.summarize 的改动在分支 fix/memory-popover。那次改动删除了状态栏专用的 SampleProcessMemory,没有改运行曲线,因为曲线还需要 CPU 时间,而这需要单独设计 Core 接口。

Checklist / 提交前检查
  • I searched existing issues for duplicates. / 我已搜索现有 Issue,确认没有重复建议。
Ngôn ngữ chính
TypeScript
Star
1.8k
Fork
151
Merge trung bình
3 giờ 48 phút
Pull request đã merge (30 ngày)
571

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của 1lck/Lithe-IDEA

Tất cả issue của 1lck/Lithe-IDEA

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.