Skip to content

feat(starry): wire qperf app runtime into Starry perf#1095

Merged
ZR233 merged 11 commits into
rcore-os:devfrom
cg24-THU:feat/starry-qperf-apps-runtime
Jun 6, 2026
Merged

feat(starry): wire qperf app runtime into Starry perf#1095
ZR233 merged 11 commits into
rcore-os:devfrom
cg24-THU:feat/starry-qperf-apps-runtime

Conversation

@cg24-THU

@cg24-THU cg24-THU commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Summary

This is the runtime companion PR for #1093.

  • expands cargo xtask starry perf so it accepts the options used by apps/OScope-harness perf-profile: workload markers, qperf callchain mode, symbol style, host timing/perf context, focused flamegraphs, raw QEMU args, and qperf metric forwarding
  • makes Starry qperf build prefer apps/qperf and fall back to tools/qperf, so the runtime works after feat(apps): add qperf and OScope harness #1093 is merged while still compiling independently on current dev
  • makes qperf postprocessing prefer apps/OScope-harness/harness.py and fall back to the older tools/starry-syscall-harness path
  • preserves --smp and adds macOS qperf plugin artifact handling
  • adds a non-Docker macOS fallback for StarryOS C build steps: if riscv64-linux-musl-gcc is missing or unusable, starry perf creates local Zig-based riscv64-linux-musl-gcc, ar, and ranlib wrappers plus bindgen include args

Why

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 fresh dev checkout with both PRs merged can run:

cargo xtask starry perf --case boot
python3 apps/OScope-harness/harness.py perf-profile --no-docker --arch riscv64 --format all
python3 apps/OScope-harness/harness.py ui --no-docker --host 127.0.0.1 --port 8765 --open

Validation

python3 apps/OScope-harness/harness.py perf-profile \
  --repo-root /Users/chaoge/workspace/OS/tgoskits-qperf-combined-validate \
  --no-docker --arch riscv64 --timeout 8 --format folded \
  --output-dir target/oscope-harness-validate-zig6

Result: ok, 628 qperf samples, with report artifacts under target/oscope-harness-validate-zig6/perf/riscv64/latest.

  • UI/knowledge graph smoke test:
python3 apps/OScope-harness/harness.py ui \
  --repo-root /Users/chaoge/workspace/OS/tgoskits-qperf-combined-validate \
  --no-docker --host 127.0.0.1 --port 8766
curl -fsS http://127.0.0.1:8766/
curl -fsS http://127.0.0.1:8766/api/status
curl -fsS http://127.0.0.1:8766/api/knowledge-graph

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-27 toolchain directly because the repository-pinned nightly-2026-05-28 rustup sync was stuck in a partial install state on this machine.

@cg24-THU
cg24-THU force-pushed the feat/starry-qperf-apps-runtime branch from 2d52012 to 4cea84b Compare June 3, 2026 14:45
@cg24-THU
cg24-THU force-pushed the feat/starry-qperf-apps-runtime branch from 4cea84b to 5a04daf Compare June 3, 2026 15:22

@ZR233 ZR233 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

复审 head 5a04daf6f3b661381f2fe9d9cc653afca4f33bc6。本 PR 和 #1093/#1039/#990 有 qperf/OScope 方向的重叠,但当前改动更偏 Starry perf runtime 配套,不是简单重复。

本地验证:git diff --check origin/dev...HEADcargo fmt --checkcargo xtask clippy --package axbuildcargo build --manifest-path tools/qperf/Cargo.toml --release --target-dir target/qperf-tools-reviewcargo 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 当作已生成结果继续返回成功。

Comment thread scripts/axbuild/src/starry/perf.rs Outdated
@cg24-THU
cg24-THU requested a review from ZR233 June 4, 2026 08:46

@mai-team-app mai-team-app Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

复审结果:APPROVE

变更概述:本 PR 将 Starry qperf 运行时适配到新的 apps/qperf 路径结构,同时保留对旧 tools/qperf 的兼容。主要改动:

  1. scripts/axbuild/src/starry/perf.rs(+2179/-150):大幅扩展 ArgsPerf CLI 参数(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/qperfrun_report_postprocess 同样通过 harness kit 回退获取 harness.py
  2. scripts/axbuild/src/starry/mod.rs(+160/-6):扩展 ArgsPerf 结构体和相关枚举(PerfModePerfCallchainPerfFlamegraphKindPerfSymbolStyle)。
  3. test-suit/starryos/normal/qemu-smp1/smoke/qemu-riscv64.toml:新增 shell_prefixshell_init_cmd 配置,支持 shell 启动命令注入。

前次审查意见处理:ZR233 提出的阻塞问题(缺少 postprocess harness 回退导致单独合入时静默跳过报告生成)已在最新 commit 5943d788 中通过 ensure_harness_kit_checkout 机制解决。run_report_postprocess 现在会先检查 workspace_harness_path,失败时自动 clone 外部 harness kit 仓库获取 harness.pyprint_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 ZR233 mentioned this pull request Jun 4, 2026
3 tasks

@ZR233 ZR233 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

复审 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() 会直接 fetchcheckout --detachreset --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 commit b4fdf12c8479353d80e3d23960e653819db2a20d 当前可达。

CI 状态:当前 run 26957293726 失败在 Test starry aarch64 qemu / run_hostsmoke 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。

Comment thread scripts/axbuild/src/starry/perf.rs

@mai-team-app mai-team-app Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

复审结果:APPROVE

变更概述:本 PR 大幅扩展 cargo xtask starry perf CLI,将 Starry qperf 运行时适配到 apps/qperf 路径结构,同时保留 tools/qperf 回退。

主要改动

  1. mod.rs(+160/-6):扩展 ArgsPerf 结构体,新增 PerfModePerfCallchainPerfFlamegraphKindPerfSymbolStyle 枚举及 Display 实现。
  2. perf.rs(+2206/-138):
    • qperf_source_root 三级回退:apps/qperftools/qperf
    • ensure_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 为纯只读校验——检查必要文件存在、是否为 .git checkout、是否在 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.rsperf.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

@mai-team-app mai-team-app Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

复审结果:APPROVE

变更概述:本 PR 将 Starry qperf 运行时适配到新的 apps/qperf 路径结构,同时保留对旧 tools/qperf 的兼容。主要改动:

  1. mod.rs(+160/-6):扩展 ArgsPerf 结构体,新增 PerfModePerfCallchainPerfFlamegraphKindPerfSymbolStyle 枚举及 Display 实现。
  2. perf.rs(+2206/-138):
    • qperf_source_root 三级回退:apps/qperf → harness kit 外部仓库 clone → tools/qperf
    • ensure_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 为纯只读校验——检查必要文件存在、是否为 .git checkout、是否在 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.rsperf.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 ZR233 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

本轮基于当前 head a068270b07897cca7364d96642727f8de0726b5d 复审。先说结论:前一轮我指出的 TGOSKIT_HARNESS_KIT_DIR 破坏性修改 override 路径的问题,在当前 head 上已经修掉了,我也把对应旧 thread resolve 了;但当前 head 还有一个新的阻断问题,会直接影响 PR body 里声称的组合 qperf runtime 工作流。\n\n这次我做了三类验证:\n- 轻量校验:cargo fmt --checkcargo xtask clippy --package axbuildcargo xtask starry perf --helpgit 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: incompletesamples: 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-gccriscv64-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_hostCheck formatting / run_hostTest 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 是否可以转为通过。

Comment thread scripts/axbuild/src/starry/perf.rs Outdated

@mai-team-app mai-team-app Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

复审结果:APPROVE

变更概述:本 PR 大幅扩展 cargo xtask starry perf CLI,将 Starry qperf 运行时适配到 apps/qperf 路径结构,同时保留 tools/qperf 回退,并使 qperf leaf profiling 自包含。

主要改动(7 个文件,+3312/-323):

  1. scripts/axbuild/src/starry/mod.rs(+166/-6):扩展 ArgsPerf 结构体,新增 PerfModePerfCallchainPerfFlamegraphKindPerfSymbolStyle 枚举及 Display 实现。
  2. scripts/axbuild/src/starry/perf.rs(+2440/-142):
    • qperf_source_root 回退链:apps/qperf → harness kit 外部仓库 clone → tools/qperf
    • ensure_harness_kit_checkout + validate_harness_kit_override:TGOSKIT_HARNESS_KIT_DIR 作为只读 override,不会被破坏性修改;仅默认缓存路径由 xtask 自动 clone/update
    • run_report_postprocess + ensure_report_outputs:postprocess 完成后校验 report.json/report.md/hotspots.csv/hotspot_categories.csv 必须存在且非空
    • cross_c_compiler_works:放宽探测条件,不再要求 --target=riscv64,兼容标准 musl-gcc
    • prepare_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 解析
  3. tools/qperf/analyzer/src/main.rs(+816/-):重构 analyzer CLI,支持直接命令行模式(不依赖子命令),新增 --focus regex 过滤、时间窗口、depth summary 等
  4. tools/qperf/src/profiler.rs(+207/-):新增 CallchainMode(Leaf/Fp),filter alias 支持,kernel filter 标志
  5. tools/qperf/Cargo.tomltools/qperf/analyzer/Cargo.toml:依赖更新

前次审查意见处理

  • ZR233 首次提出「缺失 postprocess 时静默成功」→ 已通过 ensure_report_outputs 解决
  • ZR233 第二次提出「TGOSKIT_HARNESS_KIT_DIR 被破坏性修改」→ 已通过 validate_harness_kit_override 只读校验解决
  • ZR233 第三次提出「cross_c_compiler_works 误判可用编译器」→ 最新 commit ec5b67d5a 放宽探测条件,移除 --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 perf runtime 适配。不重复。
  • #1148(HTTP bootloader)、#1147(MySQL)等其他活跃 PR:完全不相关。
  • base 分支已有基础 ArgsPerfstarry perf,本 PR 是扩展而非重复实现。

注意事项

  • generate_svg 布尔表达式(args.flamegraph || matches!(...) && !matches!(...))建议加括号提升可读性,但当前语义正确,不构成阻塞。
  • PR body 中的组合 runtime 验证仍需 #1093 合入后在 dev 上完整复现。
  • 已请求 @ZCShou 作为审阅者。

Powered by mimo-v2.5-pro

@ZR233 ZR233 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个版本还不能 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]

阻塞问题:

  1. PR body 里宣称 fresh dev 合并 #1093/#1095 后可运行的 OScope 路径,本地复现不成立。我在 #1095 当前 head 上无冲突叠加 #1093 后运行:
python3 apps/OScope-harness/harness.py perf-profile \
  --no-docker --arch riscv64 --timeout 20 --format all \
  --output-dir /tmp/qperf-1095-combo-readme

结果为 result: incompletesamples: 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,后处理不能认为是可用的。

  1. 直接 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 resolvecapacity overflow panic。因此这不是 OScope wrapper 单独的问题,当前 runtime/analyzer 组合本身还不能稳定完成“采样 -> resolve -> report”的闭环。

  1. 启用 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 perfapps/OScope-harness perf-profile 的实际闭环,确保 PR body 中列出的命令在当前 head 上能稳定产出非空 stack.foldedreport.jsonreport.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 逻辑。

@cg24-THU
cg24-THU requested a review from ZR233 June 5, 2026 15:48

@mai-team-app mai-team-app Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

自动复审结果:APPROVE

审查范围:基于当前 head d361720a(fix(qperf): stabilize record decoding)进行全面代码审查和本地验证。


变更概述

本 PR 大幅扩展 cargo xtask starry perf CLI,将 Starry qperf 运行时适配到 apps/qperf 路径结构,同时保留 tools/qperf 回退。7 个文件,+3447/-329。

主要改动

  1. scripts/axbuild/src/starry/mod.rs(+166/-6):扩展 ArgsPerf 结构体,新增 PerfModePerfCallchainPerfFlamegraphKindPerfSymbolStyle 枚举及 Display 实现。

  2. scripts/axbuild/src/starry/perf.rs(+2451/-140):

    • qperf_source_root 回退链:apps/qperf → harness kit 外部仓库 clone → tools/qperf
    • ensure_harness_kit_checkout + validate_harness_kit_overrideTGOSKIT_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 测试)
  3. 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 测试验证受控错误路径
    • --focus regex 过滤、时间窗口、depth summary、symbol style、demangle 支持
  4. tools/qperf/src/profiler.rs(+288/-):新增 v3 record 格式(含 elapsed_ns、pc、sp、fp、cpu、callchain 字段)、CallchainMode(Leaf/Fp)、filter alias 支持、kernel filter 标志。

  5. tools/qperf/Cargo.tomlplugin-api-v4plugin-api-v5tools/qperf/analyzer/Cargo.toml:新增 regexrustc-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 perf runtime 适配。
  • #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 ZR233 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

本轮复审基于 head d361720a09c9da11f6c13ca7b712bd978de62f04,重点复核前次阻塞点、当前 base 上的 #1093 app wrapper 组合路径,以及 qperf analyzer/profiler 的错误边界。

结论:前次阻塞问题均已处理,当前实现可以合入。

复核结果:

  • 缺失 postprocess harness 不再静默成功;runtime 会执行 postprocess,并通过产物校验要求 report.jsonreport.mdhotspots.csv 等输出存在且非空。
  • TGOSKIT_HARNESS_KIT_DIR override 已改为只读校验;默认托管 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...HEAD
  • cargo fmt --check
  • cargo xtask clippy --package axbuild
  • cargo clippy --manifest-path tools/qperf/Cargo.toml --all-targets --all-features -- -D warnings
  • cargo clippy --manifest-path tools/qperf/analyzer/Cargo.toml --all-targets --all-features -- -D warnings
  • cargo test --manifest-path tools/qperf/analyzer/Cargo.toml --all-features
  • cargo test --manifest-path scripts/axbuild/Cargo.toml perf
  • cargo xtask starry perf --help
  • cargo 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 1
    • result: ok,采样数 785,report.jsonreport.mdhotspots.csvqperf.binstack.folded 等产物非空。
  • 在 GitHub merge ref 上验证 apps/OScope-harness/harness.py perf-profile --no-docker --arch riscv64 --timeout 8 --format folded --output-dir /tmp/oscope-1095-review
    • result: ok,采样数 783,report.jsonreport.mdhotspots.csvqperf.binstack.folded 等产物非空。

当前 head 的 GitHub Actions 检查未见失败;格式、clippy、sync-lint 和 Starry 多架构 qemu 测试均通过,路径过滤导致的 skip 属于预期范围。

@ZR233
ZR233 merged commit 8d9c6b3 into rcore-os:dev Jun 6, 2026
49 checks passed
@github-actions github-actions Bot mentioned this pull request Jun 5, 2026
silicalet added a commit to silicalet/tgoskits that referenced this pull request Jun 6, 2026
- 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
@github-actions github-actions Bot mentioned this pull request Jun 9, 2026
aptacc2421 pushed a commit to aptacc2421/tgoskits that referenced this pull request Jun 14, 2026
* 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>
luodeb pushed a commit that referenced this pull request Jun 30, 2026
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants