perf(health-report): skip leave-one-out in base snapshot#61
Conversation
The base snapshot feeds only the metric-changes delta, which reads codebase aggregates (Delta.compute) and never per-node block impact. It was running the full LOO over the entire base tree and throwing the nodes away — the dominant cost on large-repo PR runs. Build the snapshot with compute_nodes: false (and drop node_paths). Aggregates are byte-identical between the compute_nodes branches, so the report output is unchanged; only the wasted work is gone. Verified against a 1/10 subset of a large repo via --telemetry: nodes processed 744 -> 372 (base tree no longer re-analyzed for LOO), report output byte-identical except timestamp.
🟠 Code Health: C+ (63/100)
Metric Changes
%%{init: {'theme': 'neutral'}}%%
xychart-beta
title "Code Health Scores"
x-axis ["Readability", "Complexity", "Structure", "Duplication", "Naming", "Magic Numbers", "Combined Metrics"]
y-axis "Score" 0 --> 100
bar [94, 31, 88, 48, 96, 100, 65]
|
🔍 Top Likely Issues (cosine similarity)
🟢 Readability — A (94/100)Codebase averages: flesch_adapted=97.86, fog_adapted=4.81, avg_tokens_per_line=9.51, avg_line_length=35.68
🔴 Complexity — D- (31/100)Codebase averages: difficulty=41.04, effort=232179.42, volume=4018.73, estimated_bugs=1.34
🟢 Structure — A- (88/100)Codebase averages: branching_density=0.14, mean_depth=3.86, avg_function_lines=8.27, max_depth=9.20, max_function_lines=19.85, variance=6.86, avg_param_count=1.15, max_param_count=2.04
🟠 Duplication — C- (48/100)Codebase averages: redundancy=0.59, bigram_repetition_rate=0.54, trigram_repetition_rate=0.37
🟢 Naming — A (96/100)Codebase averages: entropy=0.89, mean=6.65, variance=18.81, avg_sub_words_per_id=1.17
🟢 Magic Numbers — A (100/100)Codebase averages: density=0.00
🔴 Combined Metrics — D (65/100)
🔴 Code Smells — D- (25/100)
🟡 Consistency — B+ (81/100)
🔴 Dependencies — E+ (19/100)
🟡 Documentation — B+ (83/100)
🟢 Error Handling — A- (92/100)
🟠 File Structure — C- (48/100)
🟡 Function Design — B+ (81/100)
🟢 Naming Conventions — A- (90/100)
🔴 Scope And Assignment — D- (28/100)
🟡 Testing — B+ (83/100)
🟢 Type And Value — A- (89/100)
🟡 Variable Naming — B (74/100)
|
kind: refactoring-tasks
|
After #61 removed leave-one-out from the base snapshot, an observed v1.8 run on a 714-file repo still spent ~6min there. Telemetry pinned it: the base snapshot was running run_codebase_metrics — dominated by near_duplicate_blocks_codebase, which is O(files^2)-ish (17.9s for 373 files alone). Like the LOO nodes, that output is never read: codebase metrics sit beside the aggregate, and the base snapshot feeds only Delta.compute, which reads ['codebase']['aggregate']. Add a skip_codebase_metrics opt and set it for the base snapshot. The aggregate (all the delta needs) is still built from every file. Proven identical: analyze_codebase(compute_nodes: false) with and without the skip yields a byte-equal ['codebase']['aggregate'] on position-db/lib; only the unread near_duplicate/similarity keys drop. Measured locally against the real position-db (714 base files): the base snapshot's analyze phase dropped from ~6min to ~24s. 921 tests green.
Was
Der base-snapshot fährt keine Block-Impact-LOO mehr (
compute_nodes: false).Warum
Der base-snapshot speist nur den Metric-Changes-Delta.
Delta.computeliest ausschließlich["codebase"]["aggregate"]— nie die per-node block-impact-Nodes. Trotzdem lief die volle LOO über den kompletten base-Tree und die Nodes wurden weggeworfen. Auf großen Repos war das der dominante Posten (auf product-db ~6,5min von ~10min).Korrektheit
analyzer.exbaut in beidencompute_nodes-Branches eine identische["codebase"]["aggregate"]— der einzige Unterschied ist derblock_impact-Stage. Der Delta kriegt also dieselben Aggregate. Verifiziert:--telemetryScope
Eine Stelle:
base_snapshot_for_view/4incli/health_report.ex. Head-Analyse unverändert. Die head-LOO selbst (Token-subtraktiv) ist ein separater, größerer Hebel — folgt als eigener PR.