perf(health-report): skip codebase metrics in base snapshot#63
Conversation
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.
🟠 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.81, fog_adapted=4.82, avg_tokens_per_line=9.53, avg_line_length=35.74
🔴 Complexity — D- (31/100)Codebase averages: difficulty=41.25, effort=235309.34, volume=4053.68, estimated_bugs=1.35
🟢 Structure — A- (88/100)Codebase averages: branching_density=0.14, mean_depth=3.86, avg_function_lines=8.30, max_depth=9.21, max_function_lines=19.95, variance=6.85, avg_param_count=1.16, max_param_count=2.05
🟠 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.83, 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
|
Was
Der base-snapshot überspringt jetzt auch
run_codebase_metrics(skip_codebase_metricsopt).Warum
#61 (v1.7) entfernte die LOO aus dem base-snapshot. Ein beobachteter v1.8-Lauf auf product-db (714 Files, PR #282) verbrachte dort aber immer noch ~6min. Telemetrie hat's festgenagelt: der base-snapshot fuhr weiter
run_codebase_metrics— dominiert vonnear_duplicate_blocks_codebase, das O(Files²)-artig ist (17,9s allein für 373 Files → bei 714 quadratisch ~6min).Wie schon die LOO-Nodes ist dieser Output ungelesen: codebase-metrics sitzen neben dem aggregate, und der base-snapshot speist nur
Delta.compute, das ausschließlich['codebase']['aggregate']liest.Korrektheit (bewiesen, nicht angenommen)
analyze_codebase(compute_nodes: false)mit und ohne skip liefert eine byte-gleiche['codebase']['aggregate']auf position-db/lib — nur die ungelesenen near_duplicate/similarity-Keys fallen weg. Verifiziert per direktem Vergleich.Messung (lokal gegen die echte position-db, 714 base-Files)
Kontext
Dritter und letzter base-snapshot-Posten nach #60 (base-ref scoping) und #61 (LOO skip). Der base-snapshot baut jetzt nur noch das, was der Delta wirklich liest.