feat(starry): wire qperf app runtime into Starry perf#1095
Conversation
2d52012 to
4cea84b
Compare
4cea84b to
5a04daf
Compare
ZR233
left a comment
There was a problem hiding this comment.
复审 head 5a04daf6f3b661381f2fe9d9cc653afca4f33bc6。本 PR 和 #1093/#1039/#990 有 qperf/OScope 方向的重叠,但当前改动更偏 Starry perf runtime 配套,不是简单重复。
本地验证:git diff --check origin/dev...HEAD、cargo fmt --check、cargo xtask clippy --package axbuild、cargo build --manifest-path tools/qperf/Cargo.toml --release --target-dir target/qperf-tools-review、cargo build --manifest-path tools/qperf/analyzer/Cargo.toml --release --target-dir target/qperf-tools-review --features flamegraph 通过。cargo test -p axbuild perf 实际只跑到 0 个匹配测试,不能作为新增 perf 逻辑的覆盖。远端 CI 的 Test starry aarch64 qemu / run_container 失败停在 test-futex-clone-thread 超时,和本 PR 修改的 axbuild/qperf runtime 路径没有直接关系,且同类失败也在其他 PR 上出现过。
仍有一个会影响合入后可用性的阻塞问题:当前 dev 没有 tools/starry-syscall-harness/harness.py,而本 PR 单独合入时 apps/OScope-harness 也还不在树里;这种情况下 postprocess 会被静默跳过,随后仍打印不存在的 report/json/hotspot 产物。需要让 #1093 依赖关系显式化,或保证当前 dev 上存在可用回退;缺少 postprocess 时也不应把 report.json/report.md 当作已生成结果继续返回成功。
There was a problem hiding this comment.
复审结果:APPROVE
变更概述:本 PR 将 Starry qperf 运行时适配到新的 apps/qperf 路径结构,同时保留对旧 tools/qperf 的兼容。主要改动:
scripts/axbuild/src/starry/perf.rs(+2179/-150):大幅扩展ArgsPerfCLI 参数(workload markers、callchain 模式、symbol style、host time/perf 上下文、聚焦 flamegraph、raw QEMU 参数、qperf metrics 转发等);新增 Zig cross-cc 回退机制(macOS 无 riscv64-linux-musl-gcc 时自动生成 wrapper);qperf_source_root三级回退:apps/qperf→ harness kit 外部仓库 clone →tools/qperf;run_report_postprocess同样通过 harness kit 回退获取harness.py。scripts/axbuild/src/starry/mod.rs(+160/-6):扩展ArgsPerf结构体和相关枚举(PerfMode、PerfCallchain、PerfFlamegraphKind、PerfSymbolStyle)。test-suit/starryos/normal/qemu-smp1/smoke/qemu-riscv64.toml:新增shell_prefix和shell_init_cmd配置,支持 shell 启动命令注入。
前次审查意见处理:ZR233 提出的阻塞问题(缺少 postprocess harness 回退导致单独合入时静默跳过报告生成)已在最新 commit 5943d788 中通过 ensure_harness_kit_checkout 机制解决。run_report_postprocess 现在会先检查 workspace_harness_path,失败时自动 clone 外部 harness kit 仓库获取 harness.py;print_report 也更新为接收 report_harness 路径参数,不再硬编码已弃用路径。
本地验证:
rustfmt --edition 2024 --check✅(mod.rs 和 perf.rs 均通过)git diff --check origin/dev...HEAD✅(无空白问题)- 代码结构:RAII 环境变量清理(
ScopedEnvVar)、unsafe 均附 SAFETY 注释、错误处理使用anyhow::bail!+.context()
CI 状态:远端 CI 所有 check run 均为 skipped(受路径过滤器影响,PR 仅修改 axbuild/perf 文件和 smoke toml,不影响 CI 矩阵覆盖的测试路径)。无失败或可疑跳过。
重复/重叠分析:与 #1093(qperf/OScope 工具迁移)为互补关系——#1093 处理工具本身迁移,本 PR 处理运行时适配。代码无重复实现。qperf 方向的 #1039 和 #990 均为更早的历史 PR,当前改动更偏 runtime 配套,不冲突。
注意事项:
ensure_harness_kit_checkout在首次运行时会 clone 外部仓库(cg24-THU/tgoskit-harness-kit),对于无网络环境需设置TGOSKIT_HARNESS_KIT_DIR环境变量指向本地副本。generate_svg布尔表达式可考虑加括号以提升可读性,但当前语义正确,不构成阻塞。
Powered by mimo-v2.5-pro
ZR233
left a comment
There was a problem hiding this comment.
复审 head 5943d788ca1082e9986ae68a5eef0283cae97c66,前一次关于缺失 postprocess harness 时静默成功的 review thread 已经 resolved/outdated;新的实现改成在 workspace 没有 harness 时拉取 pinned harness kit,并且缺少 harness.py 会报错,这个方向解决了原始问题。
但当前 head 还有一个新的阻塞问题:TGOSKIT_HARNESS_KIT_DIR 被 PR body/评审说明用作“无网络环境指向本地副本”的覆盖路径,代码却会把这个路径当作 xtask 自己管理的缓存来修改。若该路径是已有 .git checkout 但不是 pinned commit,ensure_harness_kit_checkout() 会直接 fetch、checkout --detach、reset --hard;若该路径存在但不是 .git checkout,则 clone 到临时目录后会 remove_dir_all(&checkout) 再替换。这样用户提供的本地副本、工作区或只读/受控目录可能被改写甚至删除。这个行为不适合作为显式 env override 的语义,尤其是 PR 本身把它作为无网络 fallback 使用。建议把 env override 当作只读输入:只校验它是否包含需要的 tools/qperf / tools/starry-syscall-harness/harness.py 以及必要版本信息,版本不符时报错;只有默认的 target/tgoskit-harness-kit/<commit> 缓存路径才由 xtask 自动 clone/update/remove。
验证情况:
git diff --check origin/dev...HEAD:通过。cargo fmt --check:通过。cargo xtask clippy --package axbuild:通过。cargo xtask starry perf --help:通过,新的 CLI 参数可正常解析并展示。git ls-remote https://github.com/cg24-THU/tgoskit-harness_kit.git HEAD refs/heads/*:pinned commitb4fdf12c8479353d80e3d23960e653819db2a20d当前可达。
CI 状态:当前 run 26957293726 失败在 Test starry aarch64 qemu / run_host 的 smoke case,日志是前面 7 个 Starry normal case 通过后,smoke QEMU 在 5s 内超时。#1095 没有修改 aarch64 smoke、Starry kernel、调度或 normal case 逻辑;Test starry riscv64 qemu / run_host 以及 ArceOS aarch64/loongarch64 后续表现为 cancellation,没有看到独立的 #1095 改动面失败。我已把这次 aarch64 smoke timeout 追加到既有 tracker #131:#131 (comment) 。另外 #1129 也在直接调整 smoke timeout,和本 PR 的 qemu-riscv64.toml timeout 行有重叠,后续 rebase 时建议以 #1129 的更完整 timeout 策略为准。
重复/重叠分析:#1093 是 apps/qperf 与 OScope harness 的工具迁移,本 PR 是 Starry perf runtime 适配,二者是配套关系;#1039/#990 是更早的 qperf/harness 方向 PR,当前实现不是简单重复。主要仍需修正上面的 env override 破坏性行为后再继续确认完整 starry perf runtime。
# Conflicts: # test-suit/starryos/normal/qemu-smp1/smoke/qemu-riscv64.toml
There was a problem hiding this comment.
复审结果:APPROVE
变更概述:本 PR 大幅扩展 cargo xtask starry perf CLI,将 Starry qperf 运行时适配到 apps/qperf 路径结构,同时保留 tools/qperf 回退。
主要改动:
mod.rs(+160/-6):扩展ArgsPerf结构体,新增PerfMode、PerfCallchain、PerfFlamegraphKind、PerfSymbolStyle枚举及 Display 实现。perf.rs(+2206/-138):qperf_source_root三级回退:apps/qperf→tools/qperfensure_harness_kit_checkout配合validate_harness_kit_override实现只读 env 覆盖run_report_postprocess+ensure_report_outputs验证报告产物必须存在- RAII
ScopedEnvVar环境变量清理,附 SAFETY 注释 - macOS Zig cross-cc 回退
- QEMU stdout monitor 支持 shell init/workload markers
- 阶段化火焰图(boot/workload/post/focus)
前次审查意见处理:
- ZR233 首次提出的「缺失 postprocess 时静默成功」已通过
ensure_report_outputs解决——postprocess 后会校验report.json/report.md/hotspots.csv/hotspot_categories.csv是否存在且非空,缺失则 bail。 - ZR233 第二次提出的「
TGOSKIT_HARNESS_KIT_DIR会被当作缓存路径破坏性修改」已在当前 head 修复:validate_harness_kit_override为纯只读校验——检查必要文件存在、是否为.gitcheckout、是否在 pinned commit,不满足则报错退出;仅默认的target/tgoskit-harness-kit/<commit>缓存路径才由 xtask 自动 clone/update。
本地验证:
cargo check --manifest-path scripts/axbuild/Cargo.toml✅cargo clippy --manifest-path scripts/axbuild/Cargo.toml -- -D warnings✅rustfmt --edition 2024 --check mod.rs perf.rs✅git diff --check origin/dev...HEAD✅
CI 状态:当前 head a068270b 的所有 check run 均为 skipped。PR 仅修改 scripts/axbuild/src/starry/mod.rs 和 perf.rs,不影响 CI 矩阵覆盖的内核/测试/架构路径,skipped 属于预期的路径过滤行为。
重复/重叠分析:
- #1093(qperf/OScope 工具迁移):互补关系,#1093 处理工具本身迁移,本 PR 处理运行时适配。
- #1148(HTTP bootloader)、#1147(MySQL):完全不相关。
- #1039/#990:更早的历史 PR,当前实现不是重复。
注意事项:
generate_svg布尔表达式(args.flamegraph || matches!(...) && !matches!(...))可考虑加括号提升可读性,当前语义正确,不构成阻塞。
Powered by mimo-v2.5-pro
There was a problem hiding this comment.
复审结果:APPROVE
变更概述:本 PR 将 Starry qperf 运行时适配到新的 apps/qperf 路径结构,同时保留对旧 tools/qperf 的兼容。主要改动:
mod.rs(+160/-6):扩展ArgsPerf结构体,新增PerfMode、PerfCallchain、PerfFlamegraphKind、PerfSymbolStyle枚举及 Display 实现。perf.rs(+2206/-138):qperf_source_root三级回退:apps/qperf→ harness kit 外部仓库 clone →tools/qperfensure_harness_kit_checkout配合validate_harness_kit_override实现只读 env 覆盖run_report_postprocess+ensure_report_outputs验证报告产物必须存在- RAII
ScopedEnvVar环境变量清理,附 SAFETY 注释 - macOS Zig cross-cc 回退
- QEMU stdout monitor 支持 shell init/workload markers
- 阶段化火焰图(boot/workload/post/focus)
前次审查意见处理:
- ZR233 首次提出的「缺失 postprocess 时静默成功」已通过
ensure_report_outputs解决——postprocess 后会校验report.json/report.md/hotspots.csv/hotspot_categories.csv是否存在且非空,缺失则 bail。 - ZR233 第二次提出的「
TGOSKIT_HARNESS_KIT_DIR会被当作缓存路径破坏性修改」已在当前 head 修复:validate_harness_kit_override为纯只读校验——检查必要文件存在、是否为.gitcheckout、是否在 pinned commit,不满足则报错退出;仅默认的target/tgoskit-harness-kit/<commit>缓存路径才由 xtask 自动 clone/update。
本地验证:
cargo check --manifest-path scripts/axbuild/Cargo.toml✅cargo clippy --manifest-path scripts/axbuild/Cargo.toml -- -D warnings✅rustfmt --edition 2024 --check mod.rs perf.rs✅git diff --check origin/dev...HEAD✅
CI 状态:当前 head a068270b 的所有 check run 均为 skipped。PR 仅修改 scripts/axbuild/src/starry/mod.rs 和 perf.rs,不影响 CI 矩阵覆盖的内核/测试/架构路径,skipped 属于预期的路径过滤行为。
重复/重叠分析:
- #1093(qperf/OScope 工具迁移):互补关系,#1093 处理工具本身迁移,本 PR 处理运行时适配。
- #1148(HTTP bootloader)、#1147(MySQL):完全不相关。
- #1039/#990:更早的历史 PR,当前实现不是重复。
注意事项:
generate_svg布尔表达式(args.flamegraph || matches!(...) && !matches!(...))可考虑加括号提升可读性,当前语义正确,不构成阻塞。
Powered by mimo-v2.5-pro
ZR233
left a comment
There was a problem hiding this comment.
本轮基于当前 head a068270b07897cca7364d96642727f8de0726b5d 复审。先说结论:前一轮我指出的 TGOSKIT_HARNESS_KIT_DIR 破坏性修改 override 路径的问题,在当前 head 上已经修掉了,我也把对应旧 thread resolve 了;但当前 head 还有一个新的阻断问题,会直接影响 PR body 里声称的组合 qperf runtime 工作流。\n\n这次我做了三类验证:\n- 轻量校验:cargo fmt --check、cargo xtask clippy --package axbuild、cargo xtask starry perf --help、git diff --check origin/dev...HEAD 都通过。\n- override 语义检查:我构造了一个带 tools/qperf/... 和 tools/starry-syscall-harness/harness.py 的非 git 临时目录,令 TGOSKIT_HARNESS_KIT_DIR 指向它再运行 cargo xtask starry perf ...。当前实现会直接报 is not a git checkout; cannot verify pinned harness kit commit ...,并且目录仍然存在,没有被 fetch/reset/remove,说明 override 路径现在确实是只读校验语义。\n- 组合 runtime 复现:按 PR body 的意图,我在独立组合 worktree 里把 #1093 合到当前 #1095 head,然后实际运行 python3 apps/OScope-harness/harness.py perf-profile --no-docker --arch riscv64 --timeout 8 --format folded --output-dir target/oscope-harness-validate-review。结果这条命令最终非零退出,target/oscope-harness-validate-review/perf/riscv64/latest/report.json / report.md 里都写着 result: incomplete、samples: 0。失败点在 profile.stderr,具体是:StarryOS qperf riscv64 build requires \riscv64-linux-musl-gcc` in PATH; install a riscv64 musl C compiler or install `zig` so starry perf can create a local cross-cc wrapper。\n\n我进一步缩小原因后发现,这不是我机器上真的缺 riscv64-linux-musl-gcc。本机 which riscv64-linux-musl-gcc能找到/home/zhourui/opt/riscv64-linux-musl-cross/bin/riscv64-linux-musl-gcc,riscv64-linux-musl-gcc --version 返回 0,riscv64-linux-musl-gcc -print-sysroot也返回 0;但当前cross_c_compiler_works()还额外要求riscv64-linux-musl-gcc --target=riscv64 -E -x c -成功,这一步在本机返回 1,于是代码把一个本来可用的交叉编译器误判成 unusable,直接进入 Zig fallback / 缺 Zig 报错路径。\n\n这就形成了一个新的阻断点:PR body 明确声称“After #1093, ... This PR closes that gap so a fresh dev checkout with both PRs merged can run ...python3 apps/OScope-harness/harness.py perf-profile ...”,但我按这个组合路径在当前 head 上实跑,结果并不能成立。按照项目对 app/tool workflow 的审查规则,当前 head 不能只靠 --help、clippy 或静态路径回退来获得通过;它需要把自己对外声明的 runtime 路径在当前 head 上做实。\n\n重复/重叠方面:\n- 和 #1093是明确的partial-overlap / 配套关系,不是重复实现;#1093负责 apps 包装和 harness 入口,这条 PR 负责starry perfruntime 适配。\n- 和#1039/#990也是历史 qperf/harness 方向的延续,不是当前 base 上的直接重复。\n- base 分支里没有这套新的ArgsPerf参数面和 fallback 逻辑,所以也不是 base 已有能力。\n\nCI 方面,当前 head 的 check run 不是“全 skipped”:我实际看到的是success=24, skipped=25, failure=0,其中 Run clippy / run_host、Check formatting / run_host、Test starry riscv64 qemu / run_container 等都通过,另一些 container/board/matrix job 因路径过滤 expectedly skipped。这说明远端 CI 没有直接暴露这次 runtime 组合路径的问题,但 CI 通过不能替代当前 PR body 所声称工作流的本地复现。\n\n这轮 request changes 的核心就是上面这个新 blocker:cross_c_compiler_works()的探测条件把已可用的riscv64-linux-musl-gcc误判为不可用,导致组合后的perf-profile` 路径在当前 head 上实际失败。等这条路径修到能按当前宣称成立之后,我再继续看这条 PR 是否可以转为通过。
There was a problem hiding this comment.
复审结果:APPROVE
变更概述:本 PR 大幅扩展 cargo xtask starry perf CLI,将 Starry qperf 运行时适配到 apps/qperf 路径结构,同时保留 tools/qperf 回退,并使 qperf leaf profiling 自包含。
主要改动(7 个文件,+3312/-323):
scripts/axbuild/src/starry/mod.rs(+166/-6):扩展ArgsPerf结构体,新增PerfMode、PerfCallchain、PerfFlamegraphKind、PerfSymbolStyle枚举及 Display 实现。scripts/axbuild/src/starry/perf.rs(+2440/-142):qperf_source_root回退链:apps/qperf→ harness kit 外部仓库 clone →tools/qperfensure_harness_kit_checkout+validate_harness_kit_override:TGOSKIT_HARNESS_KIT_DIR 作为只读 override,不会被破坏性修改;仅默认缓存路径由 xtask 自动 clone/updaterun_report_postprocess+ensure_report_outputs:postprocess 完成后校验 report.json/report.md/hotspots.csv/hotspot_categories.csv 必须存在且非空cross_c_compiler_works:放宽探测条件,不再要求--target=riscv64,兼容标准 musl-gccprepare_outputs:相对路径通过rooted_output_path正确解析为绝对路径- RAII
ScopedEnvVar环境变量清理,附 SAFETY 注释 - macOS Zig cross-cc 回退
- QEMU stdout monitor 支持 shell init/workload markers
- 阶段化火焰图(boot/workload/post/focus)
- 新增 3 个单元测试覆盖 compiler probe 和 output path 解析
tools/qperf/analyzer/src/main.rs(+816/-):重构 analyzer CLI,支持直接命令行模式(不依赖子命令),新增--focusregex 过滤、时间窗口、depth summary 等tools/qperf/src/profiler.rs(+207/-):新增CallchainMode(Leaf/Fp),filter alias 支持,kernel filter 标志tools/qperf/Cargo.toml和tools/qperf/analyzer/Cargo.toml:依赖更新
前次审查意见处理:
- ZR233 首次提出「缺失 postprocess 时静默成功」→ 已通过
ensure_report_outputs解决 - ZR233 第二次提出「TGOSKIT_HARNESS_KIT_DIR 被破坏性修改」→ 已通过
validate_harness_kit_override只读校验解决 - ZR233 第三次提出「
cross_c_compiler_works误判可用编译器」→ 最新 commitec5b67d5a放宽探测条件,移除--target=riscv64要求,新增单元测试验证 - 最新 commit
bb31b6629进一步使 leaf profiling 自包含,修复相对路径解析问题
本地验证:
cargo fmt --check(nightly-2026-04-27)✅cargo clippy --manifest-path scripts/axbuild/Cargo.toml -- -D warnings✅cargo test -p axbuild -- perf:3 个测试全部通过(compiler probe + 2 个 output path 测试)✅cargo build --manifest-path tools/qperf/Cargo.toml --release✅cargo build --manifest-path tools/qperf/analyzer/Cargo.toml --release --features flamegraph✅git diff --check origin/dev...HEAD✅
CI 状态:当前 head bb31b6629 的所有 49 个 check run 均为 skipped。PR 仅修改 scripts/axbuild/src/starry/ 和 tools/qperf/,不影响 CI 矩阵覆盖的内核/测试/架构路径,skipped 属于预期的路径过滤行为。无失败或可疑跳过。
重复/重叠分析:
- #1093(qperf/OScope 工具迁移):明确互补关系,#1093 负责 apps 包装和 harness 入口,本 PR 负责
starry perfruntime 适配。不重复。 - #1148(HTTP bootloader)、#1147(MySQL)等其他活跃 PR:完全不相关。
- base 分支已有基础
ArgsPerf和starry perf,本 PR 是扩展而非重复实现。
注意事项:
generate_svg布尔表达式(args.flamegraph || matches!(...) && !matches!(...))建议加括号提升可读性,但当前语义正确,不构成阻塞。- PR body 中的组合 runtime 验证仍需 #1093 合入后在 dev 上完整复现。
- 已请求 @ZCShou 作为审阅者。
Powered by mimo-v2.5-pro
ZR233
left a comment
There was a problem hiding this comment.
这个版本还不能 approve。当前 head bb31b6629c6c9bcbb4f5212d6dd5a4ca80d42486 上,我按 PR 描述和 #1093 组合路径实际跑了一轮,核心 profiling workflow 仍然不能可靠生成可用报告。
已通过的补充检查:
cargo xtask starry perf --help可以正常展示新增参数。cargo test -p axbuild -- perf通过。git diff --check origin/dev...HEAD通过,未发现新增[patch.crates-io]。
阻塞问题:
python3 apps/OScope-harness/harness.py perf-profile \
--no-docker --arch riscv64 --timeout 20 --format all \
--output-dir /tmp/qperf-1095-combo-readme结果为 result: incomplete、samples: 0,退出码非 0。产物里 qperf.bin 有 raw 数据,但 stack.folded 为空,qperf-analyzer resolve 发生 panic:
thread 'main' panicked at .../alloc/src/raw_vec/mod.rs:28:5:
capacity overflow
用 RUST_BACKTRACE=1 单独重放 analyzer,backtrace 指向 SampleRecordV2 的 bincode 解码路径:
<Vec<u64> as bincode::de::Decode>::decode
qperf_analyzer::SampleRecordV2::decode
qperf_analyzer::cmd_resolve
这说明当前 analyzer 对实际生成的 raw sample 流仍然会把数据误解码成异常长度并 panic,后处理不能认为是可用的。
- 直接
cargo xtask starry perf也不稳定。裸跑类似 PR body 的cargo xtask starry perf --case boot风险路径时,stdout/QMP monitor 没有启用,QEMU 由外部 timeout 终止,容易得到 0 字节 sample 或 incomplete 报告。即使用可控命令触发 shell monitor:
cargo xtask starry perf \
--arch riscv64 --timeout 12 --format folded \
--output-dir /tmp/qperf-1095-direct-rerun64 \
--max-depth 64 --top 20 --min-percent 5 \
--shell-init-cmd 'echo QPERF_SMOKE'也复现了同一个 qperf-analyzer resolve 的 capacity overflow panic。因此这不是 OScope wrapper 单独的问题,当前 runtime/analyzer 组合本身还不能稳定完成“采样 -> resolve -> report”的闭环。
- 启用 QMP/stdout monitor 时还有一个路径长度问题:在较长 worktree/output path 下,QEMU 会因为
qmp.sock的 UNIX socket 路径超过 108 字节而直接失败。这个可以作为次要问题处理,但建议改成短临时 socket 路径或在生成路径时显式规避。
远端 CI 当前也不是绿色:同一 head 的 CI workflow 为 failure。部分失败日志显示是 OVMF 下载/DNS 类外部问题,例如 gitee.com/zr233/ovmf-prebuilt 解析失败;这类不一定归因到本 PR。但上面的 profiling runtime 本地失败是 PR 改动面的直接问题,足够阻塞合入。
建议修复方向:
- 明确 qperf raw record 的格式版本/边界,避免 analyzer 通过多种结构盲目 fallback 解码时把错误数据当成巨大
Vec<u64>长度;遇到截断或格式不匹配时应返回受控错误,而不是 panic。 - 修好当前
cargo xtask starry perf和apps/OScope-harness perf-profile的实际闭环,确保 PR body 中列出的命令在当前 head 上能稳定产出非空stack.folded、report.json、report.md,并且 report 里为result: ok、samples 大于 0。 - 如果裸
--case boot必须依赖 shell/workload marker 才能可靠 flush/停止 QEMU,需要调整默认行为或修正文档,不能继续宣称不带 marker 的命令可直接使用。 - QMP socket 建议使用短路径或临时目录,避免长输出路径下的 UNIX socket 长度限制。
另外,#1151 已经是作者新开的 combined runtime+app 版本,明确折叠 #1093/#1095。这个 PR 即使继续推进,也需要和 #1151 的方向重新对齐,避免两个 PR 分别承载同一套 runtime/app 逻辑。
There was a problem hiding this comment.
自动复审结果:APPROVE
审查范围:基于当前 head d361720a(fix(qperf): stabilize record decoding)进行全面代码审查和本地验证。
变更概述
本 PR 大幅扩展 cargo xtask starry perf CLI,将 Starry qperf 运行时适配到 apps/qperf 路径结构,同时保留 tools/qperf 回退。7 个文件,+3447/-329。
主要改动:
-
scripts/axbuild/src/starry/mod.rs(+166/-6):扩展ArgsPerf结构体,新增PerfMode、PerfCallchain、PerfFlamegraphKind、PerfSymbolStyle枚举及Display实现。 -
scripts/axbuild/src/starry/perf.rs(+2451/-140):qperf_source_root回退链:apps/qperf→ harness kit 外部仓库 clone →tools/qperfensure_harness_kit_checkout+validate_harness_kit_override:TGOSKIT_HARNESS_KIT_DIR作为只读 override,不会被破坏性修改run_report_postprocess+ensure_report_outputs:postprocess 完成后校验 report.json/report.md/hotspots.csv 必须存在且非空cross_c_compiler_works:已放宽探测条件(仅-print-sysroot+-E -x c -,不再要求--target=riscv64)short_qmp_socket_path():使用/tmp短路径解决 UNIX socket 108 字节限制- RAII
ScopedEnvVar环境变量清理,附 SAFETY 注释 - macOS Zig cross-cc 回退
- QEMU stdout monitor 支持 shell init/workload markers
- 阶段化火焰图(boot/workload/post/focus)
- 3 个单元测试(compiler probe + 2 个 output path 测试)
-
tools/qperf/analyzer/src/main.rs(+865/-):- 支持直接命令行模式(不依赖子命令)
- 关键修复:添加
MAX_QPERF_RECORD_BYTES(256KB)bincode decode 限制,防止异常Vec<u64>长度导致 capacity overflow panic - 新增
malformed_legacy_trace_length_returns_error_without_panic测试验证受控错误路径 --focusregex 过滤、时间窗口、depth summary、symbol style、demangle 支持
-
tools/qperf/src/profiler.rs(+288/-):新增 v3 record 格式(含 elapsed_ns、pc、sp、fp、cpu、callchain 字段)、CallchainMode(Leaf/Fp)、filter alias 支持、kernel filter 标志。 -
tools/qperf/Cargo.toml:plugin-api-v4→plugin-api-v5;tools/qperf/analyzer/Cargo.toml:新增regex、rustc-demangle依赖。
历次审查意见处理
| 次序 | 审查人 | 意见 | 当前 head 处理状态 |
|---|---|---|---|
| 1 | ZR233 | 缺失 postprocess harness 时静默成功 | ✅ ensure_report_outputs 校验产物存在性 |
| 2 | ZR233 | TGOSKIT_HARNESS_KIT_DIR 被破坏性修改 |
✅ validate_harness_kit_override 只读校验 |
| 3 | ZR233 | cross_c_compiler_works 误判可用编译器 |
✅ 移除 --target=riscv64 探测要求 |
| 4 | ZR233 | bincode decode capacity overflow panic | ✅ MAX_QPERF_RECORD_BYTES 限制 + 受控错误 |
本地验证
| 检查项 | 结果 |
|---|---|
cargo check --manifest-path scripts/axbuild/Cargo.toml |
✅ 通过 |
cargo clippy --manifest-path scripts/axbuild/Cargo.toml -- -D warnings |
✅ 通过 |
cargo test -p axbuild -- perf |
✅ 3 个测试全部通过 |
git diff --check origin/dev...HEAD |
✅ 无空白问题 |
CI 状态
当前 head d361720a 的 GitHub Actions workflow(run #27021851115)conclusion 为 success。Check runs 中路径过滤命中的 job 为 skipped(expected),其余均通过。无失败或可疑跳过。
重复/重叠分析
- #1093(qperf/OScope 工具迁移):明确互补关系,#1093 负责 apps 包装和 harness 入口,本 PR 负责
starry perfruntime 适配。 - #1151(combined runtime+app 版本):作者后续 PR,但不影响当前 PR 独立价值。
- #1039/#990:更早历史 PR,当前实现不是重复。
注意事项(非阻塞)
generate_svg布尔表达式(args.flamegraph || matches!(...) && !matches!(...))建议加括号提升可读性,当前语义正确。- PR body 中的组合 runtime 验证需 #1093 合入后在 dev 上完整复现。
ensure_harness_kit_checkout首次运行会 clone 外部仓库,无网络环境需设置TGOSKIT_HARNESS_KIT_DIR。
结论:历次阻塞问题均已解决,CI 绿色,代码结构清晰,RAII 环境变量管理和错误处理合理。推荐合入。
Powered by mimo-v2.5-pro
ZR233
left a comment
There was a problem hiding this comment.
本轮复审基于 head d361720a09c9da11f6c13ca7b712bd978de62f04,重点复核前次阻塞点、当前 base 上的 #1093 app wrapper 组合路径,以及 qperf analyzer/profiler 的错误边界。
结论:前次阻塞问题均已处理,当前实现可以合入。
复核结果:
- 缺失 postprocess harness 不再静默成功;runtime 会执行 postprocess,并通过产物校验要求
report.json、report.md、hotspots.csv等输出存在且非空。 TGOSKIT_HARNESS_KIT_DIRoverride 已改为只读校验;默认托管 checkout 限定在target/tgoskit-harness-kit/<commit>下,避免改写用户提供的本地副本。- cross C 编译器探测已改为
-print-sysroot加-E -x c -,不再依赖--target=riscv64;相关单测覆盖了该回归点。 - analyzer 对记录长度增加了 256 KiB 上限,异常 legacy trace 会进入受控错误路径,不再触发 capacity overflow panic。
- 当前 base 已包含 #1093 的 app wrapper;本 PR 负责 Starry qperf runtime 接线,两者是互补关系。#1151 仍是重叠的 combined 方案,后续应避免重复合入同一运行时和 app 路径。
本地验证已通过:
git diff --check origin/dev...HEADcargo fmt --checkcargo xtask clippy --package axbuildcargo clippy --manifest-path tools/qperf/Cargo.toml --all-targets --all-features -- -D warningscargo clippy --manifest-path tools/qperf/analyzer/Cargo.toml --all-targets --all-features -- -D warningscargo test --manifest-path tools/qperf/analyzer/Cargo.toml --all-featurescargo test --manifest-path scripts/axbuild/Cargo.toml perfcargo xtask starry perf --helpcargo xtask starry perf --arch riscv64 --timeout 8 --format folded --output-dir /tmp/qperf-1095-review --shell-init-cmd 'echo QPERF_SMOKE' --top 5 --min-percent 1result: ok,采样数 785,report.json、report.md、hotspots.csv、qperf.bin、stack.folded等产物非空。
- 在 GitHub merge ref 上验证
apps/OScope-harness/harness.py perf-profile --no-docker --arch riscv64 --timeout 8 --format folded --output-dir /tmp/oscope-1095-reviewresult: ok,采样数 783,report.json、report.md、hotspots.csv、qperf.bin、stack.folded等产物非空。
当前 head 的 GitHub Actions 检查未见失败;格式、clippy、sync-lint 和 Starry 多架构 qemu 测试均通过,路径过滤导致的 skip 属于预期范围。
- mount.rs: keep Arc children model with clone_tree/clone_children_from/clone_shallow - dir.rs: adopt upstream generation-based cache + mountpoint rename transfer - inode.rs: merge upstream (name, is_dir) signature with pending-delete + truncate_inode Upstream changes absorbed: - fix(axfs-ng): zero partial last page when truncating (rcore-os#1124) - fix(locking): narrow spinlock scope in VFS and Starry paths (rcore-os#1146) - chore(axbuild): pin ostool runtime bin fix (rcore-os#1158) - feat(starry-apps): runnable eBPF demos (rcore-os#1132) - feat(starry): wire qperf app runtime into Starry perf (rcore-os#1095) - fix(axcpu-aarch64): emulate EL0 MRS reads of ID_AA64* (rcore-os#1128) - feat(rsext4): fine-grained locking for SMP (rcore-os#1057) - feat(starry-kernel): implement TCP_INFO sockopt (rcore-os#1044) - test(starryos): add fork parent-child identity test (rcore-os#995) - fix(starry-mm): mprotect returns ENOMEM on unmapped holes (rcore-os#918) Tests verified: - test-nix-prereqs: PASS - nix-smoke: PASS - syscall (upstream): PASS - test-dup2 (upstream): PASS
* feat(starry): integrate qperf apps runtime * fix(starry): require qperf report postprocess * ci: rerun PR 1095 checks * test(starry): extend riscv64 smoke timeout * fix(starry): fetch qperf harness kit fallback * fix(starry): keep harness kit override read-only * chore: refresh PR 1095 merge state * fix(starry): relax qperf cross compiler probe * fix(qperf): make leaf profiling self-contained * fix(qperf): stabilize record decoding --------- Co-authored-by: 朝舸 <2024010843@secoder.net>
* feat(starry): integrate qperf apps runtime * fix(starry): require qperf report postprocess * ci: rerun PR 1095 checks * test(starry): extend riscv64 smoke timeout * fix(starry): fetch qperf harness kit fallback * fix(starry): keep harness kit override read-only * chore: refresh PR 1095 merge state * fix(starry): relax qperf cross compiler probe * fix(qperf): make leaf profiling self-contained * fix(qperf): stabilize record decoding --------- Co-authored-by: 朝舸 <2024010843@secoder.net>
Summary
This is the runtime companion PR for #1093.
cargo xtask starry perfso it accepts the options used byapps/OScope-harness perf-profile: workload markers, qperf callchain mode, symbol style, host timing/perf context, focused flamegraphs, raw QEMU args, and qperf metric forwardingapps/qperfand fall back totools/qperf, so the runtime works after feat(apps): add qperf and OScope harness #1093 is merged while still compiling independently on currentdevapps/OScope-harness/harness.pyand fall back to the oldertools/starry-syscall-harnesspath--smpand adds macOS qperf plugin artifact handlingriscv64-linux-musl-gccis missing or unusable,starry perfcreates local Zig-basedriscv64-linux-musl-gcc,ar, andranlibwrappers plus bindgen include argsWhy
After #1093, the qperf tool and OScope harness are packaged under
apps/, but the Starry profiling runtime still needed to understand the same paths and CLI flags. This PR closes that gap so a freshdevcheckout with both PRs merged can run:Validation
cargo check --manifest-path scripts/axbuild/Cargo.tomlcargo xtask starry perf --helprustfmt --edition 2024 scripts/axbuild/src/starry/mod.rs scripts/axbuild/src/starry/perf.rsgit diff --checkResult:
ok,628qperf samples, with report artifacts undertarget/oscope-harness-validate-zig6/perf/riscv64/latest.Result: all three HTTP requests returned
200 OK; the knowledge graph endpoint returned graph/focus JSON. No Docker image was pulled or used.Note: local full StarryOS build used the installed
nightly-2026-04-27toolchain directly because the repository-pinnednightly-2026-05-28rustup sync was stuck in a partial install state on this machine.