fix(health): exclude Rust inline test code from perf findings - #1855
fix(health): exclude Rust inline test code from perf findings#1855NullSense wants to merge 1 commit into
Conversation
|
✅ Health of changed files: 5.3 → 6.2 (+0.9) 📋 At a glance ✅ Health gate: passed 📌 Before you merge
🔎 More signals (2)🗺️ Change map flowchart LR
subgraph PR ["Changed in this PR (3 with dependents)"]
f_packages_core_src_repowise_core_analysis_health_complexity_models_py[".../complexity/models.py 🔥"]:::changed
f_packages_core_src_repowise_core_analysis_health_complexity_walker_py[".../complexity/walker.py 🔥"]:::changed
f_packages_core_src_repowise_core_analysis_health_perf_gated_py[".../perf/gated.py 🔥"]:::changed
end
f_packages_core_src_repowise_core_analysis_health_complexity_class_analysis_py[".../complexity/class_analysis.py"]
f_packages_core_src_repowise_core_analysis_health_complexity_models_py --> f_packages_core_src_repowise_core_analysis_health_complexity_class_analysis_py
f_packages_core_src_repowise_core_analysis_health_complexity_cyclomatic_py[".../complexity/cyclomatic.py"]
f_packages_core_src_repowise_core_analysis_health_complexity_models_py --> f_packages_core_src_repowise_core_analysis_health_complexity_cyclomatic_py
f_packages_core_src_repowise_core_analysis_health_complexity_error_handling_py[".../complexity/error_handling.py"]
f_packages_core_src_repowise_core_analysis_health_complexity_models_py --> f_packages_core_src_repowise_core_analysis_health_complexity_error_handling_py
f_packages_core_src_repowise_core_analysis_health_complexity_perf_walk_py[".../complexity/perf_walk.py"]
f_packages_core_src_repowise_core_analysis_health_complexity_models_py --> f_packages_core_src_repowise_core_analysis_health_complexity_perf_walk_py
f_packages_core_src_repowise_core_analysis_health_biomarkers_base_py[".../biomarkers/base.py"]
f_packages_core_src_repowise_core_analysis_health_complexity_walker_py --> f_packages_core_src_repowise_core_analysis_health_biomarkers_base_py
f_packages_core_src_repowise_core_analysis_health_biomarkers_registry_py[".../biomarkers/registry.py"]
f_packages_core_src_repowise_core_analysis_health_complexity_walker_py --> f_packages_core_src_repowise_core_analysis_health_biomarkers_registry_py
f_packages_core_src_repowise_core_analysis_health_complexity___init___py[".../complexity/__init__.py"]
f_packages_core_src_repowise_core_analysis_health_complexity_walker_py --> f_packages_core_src_repowise_core_analysis_health_complexity___init___py
f_packages_core_src_repowise_core_analysis_health_engine_py[".../health/engine.py"]
f_packages_core_src_repowise_core_analysis_health_perf_gated_py --> f_packages_core_src_repowise_core_analysis_health_engine_py
f_packages_core_src_repowise_core_analysis_health_perf___init___py[".../perf/__init__.py"]
f_packages_core_src_repowise_core_analysis_health_perf_gated_py --> f_packages_core_src_repowise_core_analysis_health_perf___init___py
t_tests_unit_health_test_ff_track_iljk_structural_py(["✅ .../health/test_ff_track_iljk_structural.py"]):::guard
t_tests_unit_health_test_ff_track_iljk_structural_py -.-> f_packages_core_src_repowise_core_analysis_health_complexity_walker_py
classDef changed fill:#dbeafe,stroke:#1d4ed8,color:#1e3a5f
classDef warn fill:#fef3c7,stroke:#b45309,color:#78350f
classDef guard fill:#dcfce7,stroke:#15803d,color:#14532d
Solid arrows: code that imports the changed files (9 direct dependents, from the last indexed snapshot). Dashed: history/tests. 🔥 Hotspots touched (3)
👀 Suggested reviewers @RaghavChamadiya 📊 See the full report for this PR |
Ayush7614
left a comment
There was a problem hiding this comment.
Verified: pytest tests/unit/health/test_perf_rust_test_filter.py -q 9 passed, full tests/unit/health/ -q 1213 passed. Correctly adds rust_test_line_ranges via same-tree walk and gates collect_centrality_gated at the single choke point — measured 122→56 findings with only test-code hits removed. Shared attr helper _eh_rust_attr_is_test keeps perf and error-handling in sync, and span suppression avoids double-counting. LGTM.
Summary
perf.gated.collect_centrality_gated) flags Rust test helpers as production perf findings. It decides ahot_path_sync_io/nested_loop_quadratichit from only the walker's per-function facts and whether the file is hot/churny, and neither of those knows a function is test-only.FileComplexity.rust_test_line_ranges, computed once from the treewalk_filealready parses, and checks it at the one place both gated markers are produced.hot_path_sync_iofindings went from 122 to 56. All 66 removed findings were test code; all 56 remaining findings were production code, unchanged.Related Issues
None.
Test Plan
uv run pytest tests/unit/health/test_perf_rust_test_filter.py -q— 9 passeduv run pytest tests/unit/health/ -q— 1213 passeduv run ruff check .uv run repowise risk main..HEAD:impacted-tests/health --fileneed a completedrepowise initagainst this clone; that indexing run did not finish in time and is omitted rather than faked.)Checklist
Out of scope
perf.gated.collect_blocking_io_under_lock(the cross-function lock-to-I/O pass) reads the samePerfFnFacts.lock_call_targets/bare_sink_kindand could plausibly hit the identical false-positive shape for a test helper that locks and calls into a sink. I didn't extend the filter there. No measurement backs it, and it's a separate cross-function reachability pass, not the same choke point. Worth a follow-up if it turns out to matter in practice.Written with AI assistance; measurements and tests were run and verified locally.