feat(cli): add startup performance profiler#3232
Conversation
Add a lightweight startup profiler activated via QWEN_CODE_PROFILE_STARTUP=1 environment variable. When enabled, it collects performance.now() timestamps at 7 key phases in main() and writes a JSON report to ~/.qwen/startup-perf/. This provides the measurement foundation needed to validate subsequent startup optimizations (#3011). Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
📋 Review SummaryThis PR introduces a lightweight startup performance profiler that records timing checkpoints during CLI initialization when enabled via 🔍 General Feedback
🎯 Specific Feedback🟡 High
🟢 Medium
🔵 Low
✅ Highlights
|
- Add module-level JSDoc explaining purpose and usage - Fix sessionId inconsistency: default to 'unknown' in both JSON and filename - Add comment clarifying sequential checkpoint assumption in phase calculation - Add comment in index.ts explaining why initStartupProfiler must run first Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Two test config stubs were missing getSessionId, causing CI failures after the startup profiler called config.getSessionId() in main(). Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Code Coverage Summary
CLI Package - Full Text ReportCore Package - Full Text ReportFor detailed HTML reports, please see the 'coverage-reports-22.x-ubuntu-latest' artifact from the main CI run. |
wenshao
left a comment
There was a problem hiding this comment.
Review submitted via Qwen Code /review
wenshao
left a comment
There was a problem hiding this comment.
Review of the startup profiler PR. Found 1 Suggestion and 1 Nice to have issue. The profiler code itself is clean and well-structured.
— qwen3.6-plus via Qwen Code /review
- Use report.sessionId for filename instead of raw parameter to ensure consistency between filename and JSON content - Make initStartupProfiler() idempotent by calling resetStartupProfiler() at entry, preventing state leaks across repeated calls Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Record process.uptime() at T0 to capture the time from Node.js process start to initStartupProfiler() call. This covers the module loading phase which is not measured by performance.now() checkpoints. Initial measurement shows module loading takes ~1342ms (94% of total startup time), confirming that barrel exports and eager dependency loading are the primary optimization targets. Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
wenshao
left a comment
There was a problem hiding this comment.
No issues found. LGTM! ✅ — qwen3.6-plus via Qwen Code /review
Summary
packages/cli/src/utils/startupProfiler.ts) activated viaQWEN_CODE_PROFILE_STARTUP=1environment variablemain()ingemini.tsxwith 7 checkpoints at key startup phases:main_entry,after_load_settings,after_parse_arguments,after_sandbox_check,after_load_cli_config,after_initialize_app,before_render~/.qwen/startup-perf/with per-phase durations, platform info, and session IDCloses #3219
Parent: #3011
Review feedback addressed
'unknown'in both filename and JSON), added phase calculation comments, added comment in index.ts (1901a00)getSessionIdto 2 config mocks ingemini.test.tsx(70951b9)report.sessionIdfor filename instead of raw parameter; makeinitStartupProfiler()idempotent viaresetStartupProfiler()at entry (853bef1)Test plan
QWEN_CODE_PROFILE_STARTUP=1 SANDBOX=1produces correct JSON reportgemini.test.tsx— 11 tests pass (config mock fix)Co-authored-by: Qwen-Coder qwen-coder@alibabacloud.com