Add performance logging for qdk native wheel build diagnostics#3492
Add performance logging for qdk native wheel build diagnostics#3492domorale wants to merge 3 commits into
Conversation
af22ec3 to
0cc83c7
Compare
|
@microsoft-github-policy-service agree company="Microsoft" |
Optional Next Iteration Proposal (qdk native wheel diagnostics)Current iteration objective was to improve diagnostics for the qdk native wheel step using a dependency-free, OS-native approach. A potential next iteration is to evaluate optional Why consider this next iteration
Local experiment summary (same qdk native wheel path)
Interpretation:
Cost / tradeoff
DecisionNo change is proposed to current iteration scope in this PR by this comment. If the team wants to pursue this next iteration, we can do either:
If the team is satisfied with current status, we can keep this PR as-is and merge the dependency-free implementation. |
88de101 to
9222cea
Compare
|
Perf logging for the qdk native wheel build is now complete and validated. This PR:
Validation:
|
Add best-effort performance logging for the qdk native wheel build path. Log pre-build, post-build, and failure snapshots including: - platform - Python version - sanitized command - system memory state Keep diagnostics non-blocking and scoped to the qdk native wheel step only. Capture peak memory indicators during build execution with OS-native tooling: - Linux: /usr/bin/time -v - macOS: /usr/bin/time -l - Windows: snapshot logging with no built-in peak wrapper parity Move performance logging helpers into a dedicated module to keep build orchestration code focused.
…ntegration Follow up the perf logging refactor with clearer architecture and validation. - Switch peak-memory indicators to psutil process-tree sampling. - Keep diagnostics best-effort and non-blocking. - Keep psutil build-time only (no runtime dependency change). - Separate build-context reporting from system-memory snapshot phase reporting. - Move build perf tests to tests/build and integrate them into build.py qdk test flow. - Add psutil prereq version checks with install/update behavior. Validation: - python3 -m py_compile build.py prereqs.py performance_logging.py tests/build/test_performance_logging.py - python -m pytest tests/build -q - python build.py --qdk --test --no-check --no-check-prereqs Architecture validation (lazy imports and scoped psutil): - Fresh venv without psutil: wasm build succeeds (psutil not required for non-qdk targets) - Fresh venv without psutil: qdk build auto-installs psutil (installed on-demand) - Verified --no-check-prereqs doesn't prevent qdk psutil auto-install - Lazy import cost: ExecutionPolicy imported only on first run() call for perf logging path, then cached in sys.modules; plain-path subprocess calls avoid import entirely
- Use pathlib.Path.resolve() and .relative_to() for cleaner path logic - Use .as_posix() to ensure forward slashes on all platforms (including Windows) - Removed os.path module usage (expanduser, isabs, basename) - Applied DRY: extracted _detect_path_type() helper to replace 4 code repetitions Example: path_type = _detect_path_type(path) instead of manual conditional - Updated test mock: os.path.expanduser → pathlib.Path.home() Uses established QDK patterns (like _path_stem in _context.py) for cross-platform path parsing. All 23 tests pass including Windows path sanitization. Fixes test_sanitize_path_repo_root_and_home on Windows CI
9222cea to
bd86c16
Compare
| @@ -0,0 +1,393 @@ | |||
| import subprocess | |||
| import unittest | |||
There was a problem hiding this comment.
We use pytest for Python tests everywhere else in QDK. Would be good to use only one testing framework for all Python tests.
Is there a reason to prefer unittest over pytest for this test?
There was a problem hiding this comment.
No reason at all. I agree we should use pytest.
There was a problem hiding this comment.
I have the update in my local branch just using pytest. On monday we'll discuss with the team about the pros/cons of adding functionality and dependencies (psutil in this PR) to the QDK build.
Summary
Scope
Platform behavior
Validation
Risk
Current iteration scope
Potential follow-up (if needed)