Visitar URL original
scripts: count_w25_b1b_tus.sh — reproducible W25 §1b baseline · SonicField/cpython@40dd82e · GitHub
Skip to content

Commit 40dd82e

Browse files
committed
scripts: count_w25_b1b_tus.sh — reproducible W25 §1b baseline
Per pythia python#80 python#4 [chat 2026-04-22 19:12Z] + supervisor [chat L2105] python#4 assignment: count_emit_methods.sh closes /144 vector specifically; no analogous script for §1b TU counts (the count that lapsed 4 times today: /144, /38 INVOKE_*, /24 §1b, /5 §1a). This script anchors W25 §1b TU baseline mechanically: - Enumerates TUs in Python/jit/hir/ that include hir_basic_block_c.h - Categorizes each as "with extern decls" (Step B cleanup target) vs "type-only" (no-op for Step B) - Uses the narrow lint pattern from spec §3 Step C — same pattern Step B's lint gate will install Reference values verified at HEAD e6a8a2d (post-W25-Step-A, push 65): TOTAL: 17 §1b TUs WITH extern decls (lint-pattern match): 7 (Step B cleanup targets) TYPE-ONLY: 10 (no-op for Step B) DISCREPANCY from spec §1b table (9 with externs / 8 type-only at b808cda): spec used BROADER grep (any "extern.*hir_") which counts non-API externs (e.g. hir_liveness_* in refcount_env_c.c). This script uses the NARROW lint-pattern grep matching spec §3 Step C — the actual gate Step B will install. refcount_env_c.c + refcount_pass_c.c correctly classified as type-only-for-Step-B (their non-API externs won't fail the lint gate). This shifts Step B planning: 7 cleanup-target TUs (not 9), still 5-10 small commits per spec §3. Pythia python#80 python#4 + python#1 substance closed: - python#1 stale 17/9/8 count post-Step-A: re-verified 17/7/10 at HEAD - python#4 method-specific scripts: pattern broadened — now 2 baseline scripts (count_emit_methods.sh + count_w25_b1b_tus.sh). Future consolidation to scripts/count_phoenix_baselines.sh dispatcher possible if more baselines accrue. Authorization chain: - pythia python#80 python#4 surfaced gap: chat L2104 - supervisor python#4 assignment: chat L2105
1 parent e6a8a2d commit 40dd82e

1 file changed

Lines changed: 103 additions & 0 deletions

File tree

‎scripts/count_w25_b1b_tus.sh‎

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
#!/bin/bash
2+
# count_w25_b1b_tus.sh — reproducible W25 §1b TU baseline.
3+
#
4+
# Enumerates TUs in Python/jit/hir/ that include hir_basic_block_c.h
5+
# (the W25 §1b set) and categorizes them by whether they have local
6+
# extern decls of API functions (Step B cleanup targets) vs type-only
7+
# inclusion (likely no-op for Step B).
8+
#
9+
# Usage:
10+
# scripts/count_w25_b1b_tus.sh [HIR_DIR]
11+
# (default path: Python/jit/hir/ relative to repo root)
12+
#
13+
# Output:
14+
# - Total TUs including hir_basic_block_c.h
15+
# - Per-TU extern-decl count (sorted descending)
16+
# - Subtotal: TUs with extern decls (real Step B cleanup targets)
17+
# - Subtotal: TUs without extern decls (type-only inclusion, no-op for Step B)
18+
#
19+
# Origin: pythia #80 #4 [chat 2026-04-22 19:12Z] flagged that
20+
# count_emit_methods.sh is method-specific; the /N-class lapse pattern
21+
# (4 occurrences in one session: /144, /38 INVOKE_*, /24 §1b, /5 §1a)
22+
# needs pattern-general reproducible scripts. This anchors §1b TU
23+
# counts the same way count_emit_methods.sh anchors emit-method counts.
24+
#
25+
# Reference values: at HEAD e6a8a2d0fb (post-W25-Step-A, push 65):
26+
# total: 17 §1b TUs
27+
# with extern decls (lint-pattern match): 7 (Step B cleanup targets)
28+
# type-only: 10 (no-op for Step B)
29+
#
30+
# Spec §1b table at line 60-72 used a BROADER grep (any "extern.*hir_")
31+
# yielding higher per-TU counts (9 with externs / 8 type-only at b808cdada4).
32+
# This script uses the NARROW lint-pattern grep matching spec §3 Step C —
33+
# the actual gate that Step B will install. Differences:
34+
# - refcount_env_c.c + refcount_pass_c.c have non-API externs (e.g.
35+
# hir_liveness_*) that broad grep counts but lint-pattern excludes.
36+
# They're correctly classified as type-only-for-Step-B.
37+
#
38+
# The lint pattern matches spec §3 Step C grep:
39+
# ^extern[[:space:]]+.*hir_(c_|cfg_|block_|bb_|edge_|func_|instr_)
40+
# (excludes hir_c_api.h itself + builder.cpp legitimate bridges)
41+
42+
set -euo pipefail
43+
44+
HIR_DIR="${1:-Python/jit/hir}"
45+
46+
if [[ ! -d "$HIR_DIR" ]]; then
47+
echo "ERROR: $HIR_DIR not found" >&2
48+
exit 1
49+
fi
50+
51+
# Step 1: enumerate all TUs that include hir_basic_block_c.h
52+
mapfile -t b1b_tus < <(
53+
grep -l 'cinderx/Jit/hir/hir_basic_block_c\.h' \
54+
"$HIR_DIR"/*.c "$HIR_DIR"/*.cpp 2>/dev/null \
55+
| sort
56+
)
57+
58+
total=${#b1b_tus[@]}
59+
60+
# Step 2: per-TU extern-decl count using spec §3 Step C lint pattern
61+
echo "=== W25 §1b TU baseline ($HIR_DIR at $(git rev-parse --short HEAD 2>/dev/null || echo 'no-git')) ==="
62+
echo
63+
echo "Per-TU extern API decl counts (spec §3 Step C lint pattern):"
64+
echo
65+
66+
with_externs=0
67+
type_only=0
68+
declare -a with_externs_list
69+
declare -a type_only_list
70+
71+
for tu in "${b1b_tus[@]}"; do
72+
base=$(basename "$tu")
73+
# Skip self-canonical headers (lint excludes these)
74+
if [[ "$base" == "hir_c_api.h" || "$base" == "builder.cpp" ]]; then
75+
continue
76+
fi
77+
count=$(grep -cE '^extern[[:space:]]+.*hir_(c_|cfg_|block_|bb_|edge_|func_|instr_)' "$tu" 2>/dev/null || true)
78+
count=${count:-0}
79+
if (( count > 0 )); then
80+
with_externs=$(( with_externs + 1 ))
81+
with_externs_list+=("$count $base")
82+
else
83+
type_only=$(( type_only + 1 ))
84+
type_only_list+=("$base")
85+
fi
86+
done
87+
88+
# Sort by extern count desc
89+
printf '%s\n' "${with_externs_list[@]}" | sort -rn | while read -r count name; do
90+
printf " %3d %s\n" "$count" "$name"
91+
done
92+
93+
echo
94+
echo "TUs WITHOUT extern API decls (type-only inclusion, no-op for Step B):"
95+
for name in "${type_only_list[@]}"; do
96+
echo " $name"
97+
done
98+
99+
echo
100+
echo "=== SUMMARY ==="
101+
echo "TOTAL §1b TUs: $total"
102+
echo " WITH extern decls (Step B cleanup targets): $with_externs"
103+
echo " TYPE-ONLY inclusion (no-op for Step B): $type_only"

0 commit comments

Comments
 (0)