Repository navigation
feat(process): processMemory.summarize 汇总压缩/换出内存、GPU 显存与 CPU、GPU 占用 - #45
Merged
Merged
Conversation
- 进程行新增 compressedBytes(已压缩或写到磁盘、不在 bytes 里)、gpuMemoryBytes(bytes 不含的显存)、cpuTime(微秒)与 gpuEngines(各引擎忙碌微秒) - 请求新增 sampledAt、previous 与 logicalProcessors;响应返回 baseline,宿主下次原样带回,由 Core 计算两次读取之间的 CPU、GPU 百分比 - 汇总、各类别、各条目带同样的可选数值:要么都有,要么都没有;GPU 取最忙引擎,CPU 默认 100 为一个处理器,给 logicalProcessors 时按全部处理器折算且不超过 100 - 新增共享 fixture 用例与单测,更新 rust-core-api.md
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.
关联
状态栏内存详情原来只显示“内存中”一个数(macOS 物理占用、Windows 专用工作集),用户在 Windows 上看到 Lithe 只占 108 MB,怀疑漏算。实际没有漏算,只是被系统压缩或换出的部分、Windows 的专用显存都不在这个数里,也看不到 CPU 和 GPU 占用。这个 PR 让
processMemory.summarize同时汇总三端统一口径的“内存中”和“压缩/换出”、显存,以及两次读取之间的 CPU、GPU 占用百分比;百分比的计算放在 Core,宿主只提供累计计数器。桌面端改动在配套 PR 1lck/Lithe-IDEA#1933,固定在本 PR 的 commitc7213c2,本 PR 合入后改为 main 上的 commit。也是 1lck/Lithe-IDEA#1925 建议方案的第 1、2 步:进程表带累计 CPU 时间、两次采样之间的 CPU 占比在 Core 计算。运行窗口曲线的迁移不在本 PR。
改动
compressedBytes:系统压缩或写到磁盘的部分,bytes不包含它。gpuMemoryBytes:bytes不包含的显存,例如 Windows 的专用显存。cpuTime:进程启动以来的用户态加内核态 CPU 时间,单位微秒。gpuEngines:{ engine, busyTime },各 GPU 引擎为该进程忙碌的微秒数。sampledAt:读表时刻,取只增不减的时钟,单位微秒。previous:上一次响应返回的baseline,宿主原样带回。logicalProcessors:给出时 CPU 按全部处理器折算,和任务管理器一致;不给时 100 表示一个处理器忙满,和活动监视器、top一致。compressedBytes、gpuMemoryBytes、cpuPercent、gpuPercent。同一个数要么三处都有,要么都没有。baseline: { sampledAt, processes }:实例内带计数器的进程,每个进程每个引擎一行。sampledAt、没有previous,或sampledAt不晚于基线时,不返回百分比。logicalProcessors为 0 时返回invalid_request。bytes的含义写成三端统一:在内存中的部分。排序仍只按bytes。rust/crates/process/src/memory.rs,新增对应单元测试。rust/contracts/rust-core-api.md:命令表的说明和 “processMemory.summarize” 一节同步更新。rust/fixtures/process-lifecycle/memory-summary-v1.json新增 6 个用例:logicalProcessors为 0 时返回无效请求验证
cargo test --manifest-path rust/Cargo.toml -p lithe-process -p lithe-core:837 个测试全部通过,包括共享样例的回放。cargo fmt --all -- --check、cargo clippy -p lithe-process -p lithe-core --all-targets -- -D warnings、scripts/rust-core/verify-rust-core-comments.sh:都通过。LITHE_CORE_RUST_DIR指向本分支,跑了scripts/desktop/desktop-go.sh test覆盖 core、sysinfo、workbench 三个包,都通过;它们读同一份共享样例。不涉及插件契约、能力版本或插件函数协议,所以不需要更新协议记录。