Repository navigation
fix(desktop): 内存详情的 CPU/GPU 占用至少按 1 秒计算 - #2103
Merged
Merged
Conversation
刚打开状态栏内存详情时,工作台会紧挨着读两次进程表(打开时一次,插件名称 读完后又一次),相隔只有几十毫秒。Core 以前只要间隔大于 0 就计算占用率, 主进程 CPU 会显示到 166%、GPU 到 28%,过几秒才恢复。 - PINNED_CORE_REVISION 升到 Lithe-core-rust fix/process-memory-min-interval 的 8dd6c70:processMemory.summarize 不比较相隔不足 1 秒的两张表,过近的 读数改按基线里的 earlier 计数计算,并原样返回基线。#80 的注释改写为已合入 main 5202d3b。 - core.MemoryBaseline 增加 Earlier(新类型 MemoryCounters),宿主照常原样 发回;更新 CPUPercent/GPUPercent 的注释。 - desktop.memory.helpFigures 中英文说明改为“相隔至少 1 秒的两次读取之间的 占用率”。 - 功能矩阵 memory-monitor 的验证动作与说明同步新规则,状态保持 pending。 - 新增 Agent 笔记 bug-fix/2026-11-17-memory-usage-minimum-window.md。
TestVisualMemoryDetails 在完整读数的场景里把指针停在标题旁的 ⓘ 上, 按提示文字等于 memoryHelp 找到该控件,等待提示显示后截图 memory-details-help-<主题>.png;截图与说明放入 docs/assets/memory-details/。
xiaoyumuxi
marked this pull request as ready for review
November 17, 2026 12:07
24 of 32 tasks
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.
关联 Issue / Linked issue
PR 类型 / Type
改动说明 / What changes
背景 / Why
状态栏内存详情的 CPU、GPU 占用率,是两次读取进程表之间累计时间的差除以间隔。刚打开详情时,工作台会紧挨着读两次:打开时读一次,插件名称在后台读完后又清空采样时间再读一次,相隔只有几十毫秒。这段时间里主要是读取本身(每次约 3 ms 单核)和面板打开的开销,Core 却按持续占用计算,于是主进程 CPU 显示到 160% 以上、GPU 约 28%,等 2 秒后的下一次采样才恢复。
修复放在 Core(#81):
processMemory.summarize不再比较相隔不足 1 秒的两张表。宿主照常把上次返回的基线原样发回,不需要自己判断间隔。改动 / Changes
Core 固定版本(
scripts/desktop/build-desktop-core.sh)PINNED_CORE_REVISION从81a6ecf(Fix staging/unstaging of files in changes group checkbox #80 的分支)升到8dd6c70(Core add: add comments to the rust core #81 的分支,基于 main5202d3b)。规则如下:earlier= 上一个基线的计数earlier计算(earlier也须早于读数至少 1 秒,否则不给)earlier5202d3b”(与旧固定版本81a6ecf的源码树相同)。宿主类型(
desktop/internal/core/process_memory.go)MemoryBaseline增加Earlier *MemoryCounters(json:"earlier,omitempty"),新类型MemoryCounters{SampledAt, Processes}。宿主只负责原样发回;少了这个字段,Core 返回的earlier会在 Go 解码时丢失,过近的读数就拿不到占用率。CPUPercent、GPUPercent的注释改为“自至少早 1 秒的计数以来”。界面文案(
shared/i18n/locales/{zh-CN,en-US}.json、desktop/internal/i18n/shared.generated.go)desktop.memory.helpFigures改为“CPU 和 GPU 是相隔至少 1 秒的两次读取之间的占用率……” / “CPU and GPU are the use between two readings at least a second apart…”。功能矩阵(
shared/platform-feature-matrix/features/memory-monitor.json)earlier计算且基线不变。两端状态保持pending。Agent Note
.agents/notes/implemented/bug-fix/2026-11-17-memory-usage-minimum-window.md:记录规则为什么放在 Core、宿主不要自己丢弃或合并读数,以及考虑过的三个备选方案。无头截图(
desktop/internal/workbench/memory_details_visual_test.go、docs/assets/memory-details/)TestVisualMemoryDetails在完整读数的场景里,用提示文字等于memoryHelp找到 ⓘ,把指针停在上面,等提示显示后截图memory-details-help-<主题>.png。截图和 README 的说明行一并提交。不在本 PR 范围内 / Out of scope
desktop/internal/workbench/memory_monitor.go的readMemoryNames)也不变:它的作用是让名称尽快显示,过近读数的占用率现在由 Core 的规则处理。PINNED_CORE_REVISION换成 add: add comments to the rust core #81 在 main 上的合并提交,最后合本 PR。类型专属:fix
复现与根因
git log -S或git blame查):Usage::since只要求间隔大于 0:Lithe-core-rust fix(search): restore Search Everywhere scrolling #45(40711b1)。0f95f4765),在toggleMemoryDetails和readMemoryNames的应用回调里。检查项
rust/crates/process/src/memory.rs的a_table_read_too_soon_after_the_baseline_keeps_it_and_has_no_percentages(读数晚于基线 0、50 ms、999.999 ms)。修复前得到cpu_percent: Some(100.0)并开始新基线;修复后没有占用率,基线原样返回。共享 fixturememory-summary-v1.json新增两例,宿主TestProcessMemorySummarizeFollowsTheContractFixture经链接的 Core 回放通过。MemoryBaseline和processMemory.summarize在宿主只有desktop/internal/core/process_memory.go和desktop/internal/workbench/memory_monitor.go:172(把summary.Baseline原样作为下一次的Previous)。插件和 SDK 不调用这个命令。.agents/notes/implemented/bug-fix/记录:2026-11-17-memory-usage-minimum-window.md范围检查 / Scope checks
功能矩阵 / Feature matrix
shared/platform-feature-matrix/features/memory-monitor.json:两端的实现状态和验证状态、证据路径、owner、验证动作都如实填写;没有运行验证的保持pending./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh;改了平台实现路径的,还运行了./scripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/main HEAD.artifacts/下生成的矩阵视图插件归属 / Plugin ownership
develop-lithe第三节“插件归属与宿主零依赖”的自查命令,结果为空shared/i18n/;插件的构建步骤、资源路径和补丁没有写进docs/ci-builds.md、Agent Note 或 SkillUI 验证 / UI evidence
LITHE_VISUAL_OUTPUT_DIR=… ./scripts/desktop/desktop-go.sh test -tags vivahead,lithevisual ./internal/workbench -run '^TestVisualMemoryDetails$' -count=1 -timeout 180s6ec0952docs/assets/memory-details/)统一日志系统 / Structured logging
N/A:没有新增或改动生命周期里程碑、操作终态、降级、恢复或失败路径。读数过近只是不给占用率,不是失败。
界面文案 / i18n
shared/i18n/补齐中英词条,运行node scripts/i18n/generate-i18n.mjs并提交生成结果,没有手改生成文件;Viva 代码通过desktop/internal/i18n/的接口读取node scripts/i18n/verify-app-language-localization.mjs和node scripts/i18n/generate-i18n.mjs --check,没有放宽脚本或扩大豁免名单逻辑归属 / Logic placement
earlier规则在 Core add: add comments to the rust core #81,契约文档和memory-summary-v1.json在同一个 Core PR 更新;宿主只原样传回基线性能与内存 / Performance and memory
设置 / Settings
N/A:没有新增或修改设置项。
插件契约 / Plugin contract
N/A:没有改插件契约、能力版本或插件函数协议,也没有新增或修改宿主方法。
PINNED_CORE_REVISION的升级只为了processMemory.summarize的新规则;该命令的文档和 fixture 在 Core #81 的rust/contracts/rust-core-api.md、rust/fixtures/process-lifecycle/memory-summary-v1.json里同步更新。发行包与资源 / Bundle and resources
N/A:没有新增或修改运行时资源和资源构建步骤(截图只放在
docs/assets/,不进发行包)。仍运行了./scripts/desktop/verify/verify-runtime-bundle-immutability.sh,通过。无用代码与重构 / Dead code and refactoring
refactor标签的 Issue:未发现验证 / Verification
cargo test --locked -p lithe-processcargo test --locked -p lithe-core process_memorymemory-summary-v1.json)cargo clippy --locked -p lithe-process -p lithe-core --all-targets -- -D warnings(本机与--target x86_64-pc-windows-msvc)cargo fmt --all -- --check、scripts/rust-core/verify-rust-core-comments.sh process、node scripts/rust-core/verify-platform-tests.mjs./scripts/desktop/desktop-go.sh test ./internal/core ./internal/workbench(链接 Core8dd6c70)LITHE_VISUAL_OUTPUT_DIR=… ./scripts/desktop/desktop-go.sh test -tags vivahead,lithevisual ./internal/workbench -run '^TestVisualMemoryDetails$' -count=1 -timeout 180snode scripts/i18n/verify-app-language-localization.mjs、node scripts/i18n/generate-i18n.mjs --check./scripts/agent-notes/verify-agent-notes.sh./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh、verify-platform-feature-matrix-change.sh origin/main HEAD./scripts/desktop/verify/verify-runtime-bundle-immutability.shdevelop-lithe第三节插件归属自查命令gofmt -l(改动的 Go 文件)未能执行的检查和原因:
pending。提交前确认 / Final checks
main创建;目标分支:feat、fix、docs 为main,release 以发布流程要求为准(基于e45c8c049).build/、target/、dist/、.artifacts/等产物,没有凭据、个人路径和未脱敏的日志或截图