Skip to content

Commit a2407ce

Browse files
committed
fix(schedule): four defects found reviewing bmi_schedule, all reachable
深度 review 这条分支时发现的,四条都能走到,其中两条会让构建**无输出地卡死**。 ## 1. 默认配置下 detach-codegen 的并发**完全没有上限** 模块自己的注释写着「真正的并发由信号量限制,永远不是 -j」—— 而 `resolve_jobs` 在用户没给 `--jobs` 时返回 0(「不说话,用后端默认」), 于是 `compilerCap = 0` → `acquire_token` 直接返回空 → **信号量被禁用**, 生成的图里是 `sched_cap = 0`。 detach 之后编译器一发布 BMI 就交还 ninja 槽位,所以 ninja 的 -j 已经不是上限了。 结果:**ninja 有多快就起多少个编译器,没有任何东西在数**,而单个模块编译峰值接近 1GB。这是模块自己列的 hazard 2,而它在**默认路径上根本没生效**。 修法:`decide()` 保持纯函数,新增 `autoJobs` 参数由调用方(prepare)算好传入; detach 分支在没有显式 job 数时回落到这台机器的推荐值。实测 `sched_cap` 从 0 变成 24。两者都没有时,**reason 里直接说「bounded by nothing」**。 ## 2. `.mcpp-sched` 的令牌**没有任何人回收** 令牌由持有它的 supervisor 删除。supervisor 没跑到清理就死掉(对构建按 Ctrl-C、 OOM killer、重启)就会留下目录,而没有任何代码删它 —— 每发生一次就**永久**少掉 一个槽位,攒够 cap 个之后下一次构建等一个永远不会被释放的令牌,**没有输出、 没有诊断**。对构建按 Ctrl-C 是再平常不过的操作。 ⚠️ 我第一次把回收放在了 prepare 里(schedule 决策旁边),**e2e 证明它根本没跑**: 增量构建走工程级 fast path,直接重放 build.ninja,不重新推导 plan。回收必须放在 **每次构建都会经过**的地方,也就是 execute 里 spawn ninja 之前。 ## 3. phase 1 等 BMI 是 `for(;;)`,没有上限 phase 2 有明确的上限,注释还写着「无上限的等待比失败更糟,因为没有任何东西告诉你 该看哪」—— 而**等同一个 supervisor 的 phase 1 没有**。supervisor 被 OOM 杀掉就 永远等下去。补上 10s「supervisor 没起来」宽限 + 2h 硬上限,两者都会恢复旧 BMI。 `acquire_token` 同样加了上限:超时后**不带 cap 继续**(信号量限的是内存压力, 不是正确性,失败的构建比慢的构建更糟),并说清楚该删哪个目录。 ## 4. supervisor 有一条退出路径不写 `.rc` 命令文件读不出来时 `cmd_bmi_supervise` 直接 return 2,而 phase 1/2 都在等那个文件 —— 和「supervisor 从没启动」无法区分,两边只能等到超时。现在这种情况也写 rc。 ## 测试 `tests/e2e/234_bmi_schedule_on.sh`(**这个特性此前没有任何 e2e**,只有 `decide()` 的单测,测的是**表**不是机制)。它种下满额的陈旧令牌,要求下一次构建照样跑完。 这个测试**在修好之前红了两次**:第一次真的卡死 600s,第二次暴露了我把回收放错了 地方 —— 不是空转的。 单测补了两条:零 cap 必须**在 reason 里说自己没有上限**;detach 在没有 job 数时 必须回落到宿主推荐值,而显式 `--jobs` 仍然优先。 本地:83 个单测全过,234 过。
1 parent ffbe0a6 commit a2407ce

23 files changed

Lines changed: 6138 additions & 20 deletions
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
payload: payload:gcc → /home/speak/.mcpp/registry/data/xpkgs/xim-x-gcc/16.1.0/bin/g++
2+
run id : 4e58a816 (fresh)
3+
host : linux x86_64 · 13th Gen Intel(R) Core(TM) i9-13900K · 32 logical / 24 physical (heterogeneous)
4+
fixture: 20 units, fanin 3, weight 4
5+
6+
[ 0.0s] mcpp@2026.8.13.1/gcc/release/cold/synth-20x3/headers configure
7+
[ 0.0s] mcpp@2026.8.13.1/gcc/release/cold/synth-20x3/headers seed build
8+
[ 1.3s] mcpp@2026.8.13.1/gcc/release/cold/synth-20x3/headers run 1/3
9+
[ 2.6s] mcpp@2026.8.13.1/gcc/release/cold/synth-20x3/headers run 2/3
10+
[ 3.9s] mcpp@2026.8.13.1/gcc/release/cold/synth-20x3/headers run 3/3
11+
mcpp@2026.8.13.1/gcc/release/cold/synth-20x3/headers 1.31s (min 1.28 / max 1.33, n=3)
12+
[ 5.3s] mcpp@2026.8.13.1/gcc/release/noop/synth-20x3/headers configure
13+
[ 5.3s] mcpp@2026.8.13.1/gcc/release/noop/synth-20x3/headers seed build
14+
[ 5.5s] mcpp@2026.8.13.1/gcc/release/noop/synth-20x3/headers run 1/3
15+
[ 5.6s] mcpp@2026.8.13.1/gcc/release/noop/synth-20x3/headers run 2/3
16+
[ 5.8s] mcpp@2026.8.13.1/gcc/release/noop/synth-20x3/headers run 3/3
17+
mcpp@2026.8.13.1/gcc/release/noop/synth-20x3/headers 0.16s (min 0.16 / max 0.18, n=3)
18+
[ 6.0s] mcpp@2026.8.13.1/gcc/release/touch-hub/synth-20x3/headers configure
19+
[ 6.0s] mcpp@2026.8.13.1/gcc/release/touch-hub/synth-20x3/headers seed build
20+
[ 6.1s] mcpp@2026.8.13.1/gcc/release/touch-hub/synth-20x3/headers run 1/3
21+
[ 7.5s] mcpp@2026.8.13.1/gcc/release/touch-hub/synth-20x3/headers run 2/3
22+
[ 8.8s] mcpp@2026.8.13.1/gcc/release/touch-hub/synth-20x3/headers run 3/3
23+
mcpp@2026.8.13.1/gcc/release/touch-hub/synth-20x3/headers 1.30s (min 1.30 / max 1.35, n=3)
24+
[ 10.1s] mcpp@2026.8.13.1/gcc/release/touch-leaf/synth-20x3/headers configure
25+
[ 10.1s] mcpp@2026.8.13.1/gcc/release/touch-leaf/synth-20x3/headers seed build
26+
[ 10.3s] mcpp@2026.8.13.1/gcc/release/touch-leaf/synth-20x3/headers run 1/3
27+
[ 11.0s] mcpp@2026.8.13.1/gcc/release/touch-leaf/synth-20x3/headers run 2/3
28+
[ 11.8s] mcpp@2026.8.13.1/gcc/release/touch-leaf/synth-20x3/headers run 3/3
29+
mcpp@2026.8.13.1/gcc/release/touch-leaf/synth-20x3/headers 0.78s (min 0.78 / max 0.78, n=3)
30+
[ 12.6s] mcpp@2026.8.13.1/gcc/release/edit-body/synth-20x3/headers configure
31+
[ 12.6s] mcpp@2026.8.13.1/gcc/release/edit-body/synth-20x3/headers seed build
32+
[ 12.8s] mcpp@2026.8.13.1/gcc/release/edit-body/synth-20x3/headers run 1/3
33+
[ 13.5s] mcpp@2026.8.13.1/gcc/release/edit-body/synth-20x3/headers run 2/3
34+
[ 14.3s] mcpp@2026.8.13.1/gcc/release/edit-body/synth-20x3/headers run 3/3
35+
mcpp@2026.8.13.1/gcc/release/edit-body/synth-20x3/headers 0.78s (min 0.78 / max 0.80, n=3)
36+
[ 15.1s] mcpp@2026.8.13.1/gcc/release/edit-comment/synth-20x3/headers configure
37+
[ 15.1s] mcpp@2026.8.13.1/gcc/release/edit-comment/synth-20x3/headers seed build
38+
[ 15.9s] mcpp@2026.8.13.1/gcc/release/edit-comment/synth-20x3/headers run 1/3
39+
[ 17.2s] mcpp@2026.8.13.1/gcc/release/edit-comment/synth-20x3/headers run 2/3
40+
[ 18.4s] mcpp@2026.8.13.1/gcc/release/edit-comment/synth-20x3/headers run 3/3
41+
mcpp@2026.8.13.1/gcc/release/edit-comment/synth-20x3/headers 1.26s (min 1.24 / max 1.29, n=3)
42+
[ 19.7s] mcpp@2026.8.13.1/gcc/release/cold/synth-20x3/modules configure
43+
[ 19.7s] mcpp@2026.8.13.1/gcc/release/cold/synth-20x3/modules seed build
44+
[ 37.9s] mcpp@2026.8.13.1/gcc/release/cold/synth-20x3/modules run 1/3
45+
[ 56.6s] mcpp@2026.8.13.1/gcc/release/cold/synth-20x3/modules run 2/3
46+
[ 75.1s] mcpp@2026.8.13.1/gcc/release/cold/synth-20x3/modules run 3/3
47+
mcpp@2026.8.13.1/gcc/release/cold/synth-20x3/modules 18.51s (min 17.92 / max 18.70, n=3)
48+
[ 93.0s] mcpp@2026.8.13.1/gcc/release/noop/synth-20x3/modules configure
49+
[ 93.0s] mcpp@2026.8.13.1/gcc/release/noop/synth-20x3/modules seed build
50+
[ 93.2s] mcpp@2026.8.13.1/gcc/release/noop/synth-20x3/modules run 1/3
51+
[ 93.4s] mcpp@2026.8.13.1/gcc/release/noop/synth-20x3/modules run 2/3
52+
[ 93.6s] mcpp@2026.8.13.1/gcc/release/noop/synth-20x3/modules run 3/3
53+
mcpp@2026.8.13.1/gcc/release/noop/synth-20x3/modules 0.18s (min 0.16 / max 0.18, n=3)
54+
[ 93.7s] mcpp@2026.8.13.1/gcc/release/touch-hub/synth-20x3/modules configure
55+
[ 93.7s] mcpp@2026.8.13.1/gcc/release/touch-hub/synth-20x3/modules seed build
56+
[ 93.9s] mcpp@2026.8.13.1/gcc/release/touch-hub/synth-20x3/modules run 1/3
57+
[ 94.8s] mcpp@2026.8.13.1/gcc/release/touch-hub/synth-20x3/modules run 2/3
58+
[ 95.8s] mcpp@2026.8.13.1/gcc/release/touch-hub/synth-20x3/modules run 3/3
59+
mcpp@2026.8.13.1/gcc/release/touch-hub/synth-20x3/modules 0.93s (min 0.91 / max 0.94, n=3)
60+
[ 96.7s] mcpp@2026.8.13.1/gcc/release/touch-leaf/synth-20x3/modules configure
61+
[ 96.7s] mcpp@2026.8.13.1/gcc/release/touch-leaf/synth-20x3/modules seed build
62+
[ 96.9s] mcpp@2026.8.13.1/gcc/release/touch-leaf/synth-20x3/modules run 1/3
63+
[ 98.2s] mcpp@2026.8.13.1/gcc/release/touch-leaf/synth-20x3/modules run 2/3
64+
[ 99.7s] mcpp@2026.8.13.1/gcc/release/touch-leaf/synth-20x3/modules run 3/3
65+
mcpp@2026.8.13.1/gcc/release/touch-leaf/synth-20x3/modules 1.40s (min 1.39 / max 1.41, n=3)
66+
[ 101.1s] mcpp@2026.8.13.1/gcc/release/edit-body/synth-20x3/modules configure
67+
[ 101.1s] mcpp@2026.8.13.1/gcc/release/edit-body/synth-20x3/modules seed build
68+
[ 101.2s] mcpp@2026.8.13.1/gcc/release/edit-body/synth-20x3/modules run 1/3
69+
[ 102.2s] mcpp@2026.8.13.1/gcc/release/edit-body/synth-20x3/modules run 2/3
70+
[ 103.1s] mcpp@2026.8.13.1/gcc/release/edit-body/synth-20x3/modules run 3/3
71+
mcpp@2026.8.13.1/gcc/release/edit-body/synth-20x3/modules 0.94s (min 0.92 / max 0.96, n=3)
72+
[ 104.1s] mcpp@2026.8.13.1/gcc/release/edit-comment/synth-20x3/modules configure
73+
[ 104.1s] mcpp@2026.8.13.1/gcc/release/edit-comment/synth-20x3/modules seed build
74+
[ 105.0s] mcpp@2026.8.13.1/gcc/release/edit-comment/synth-20x3/modules run 1/3
75+
[ 105.9s] mcpp@2026.8.13.1/gcc/release/edit-comment/synth-20x3/modules run 2/3
76+
[ 106.9s] mcpp@2026.8.13.1/gcc/release/edit-comment/synth-20x3/modules run 3/3
77+
mcpp@2026.8.13.1/gcc/release/edit-comment/synth-20x3/modules 0.92s (min 0.92 / max 0.92, n=3)
78+
[ 107.8s] mcpp@2026.8.13.1/gcc/release/cold/synth-20x3/modules-impl configure
79+
[ 107.8s] mcpp@2026.8.13.1/gcc/release/cold/synth-20x3/modules-impl seed build
80+
[ 113.2s] mcpp@2026.8.13.1/gcc/release/cold/synth-20x3/modules-impl run 1/3
81+
[ 118.6s] mcpp@2026.8.13.1/gcc/release/cold/synth-20x3/modules-impl run 2/3
82+
[ 123.9s] mcpp@2026.8.13.1/gcc/release/cold/synth-20x3/modules-impl run 3/3
83+
mcpp@2026.8.13.1/gcc/release/cold/synth-20x3/modules-impl 5.35s (min 5.30 / max 5.36, n=3)
84+
[ 129.2s] mcpp@2026.8.13.1/gcc/release/noop/synth-20x3/modules-impl configure
85+
[ 129.2s] mcpp@2026.8.13.1/gcc/release/noop/synth-20x3/modules-impl seed build
86+
[ 129.4s] mcpp@2026.8.13.1/gcc/release/noop/synth-20x3/modules-impl run 1/3
87+
[ 129.6s] mcpp@2026.8.13.1/gcc/release/noop/synth-20x3/modules-impl run 2/3
88+
[ 129.7s] mcpp@2026.8.13.1/gcc/release/noop/synth-20x3/modules-impl run 3/3
89+
mcpp@2026.8.13.1/gcc/release/noop/synth-20x3/modules-impl 0.18s (min 0.16 / max 0.18, n=3)
90+
[ 129.9s] mcpp@2026.8.13.1/gcc/release/touch-hub/synth-20x3/modules-impl configure
91+
[ 129.9s] mcpp@2026.8.13.1/gcc/release/touch-hub/synth-20x3/modules-impl seed build
92+
[ 130.1s] mcpp@2026.8.13.1/gcc/release/touch-hub/synth-20x3/modules-impl run 1/3
93+
[ 130.6s] mcpp@2026.8.13.1/gcc/release/touch-hub/synth-20x3/modules-impl run 2/3
94+
[ 131.1s] mcpp@2026.8.13.1/gcc/release/touch-hub/synth-20x3/modules-impl run 3/3
95+
mcpp@2026.8.13.1/gcc/release/touch-hub/synth-20x3/modules-impl 0.48s (min 0.48 / max 0.50, n=3)
96+
[ 131.6s] mcpp@2026.8.13.1/gcc/release/touch-leaf/synth-20x3/modules-impl configure
97+
[ 131.6s] mcpp@2026.8.13.1/gcc/release/touch-leaf/synth-20x3/modules-impl seed build
98+
[ 131.7s] mcpp@2026.8.13.1/gcc/release/touch-leaf/synth-20x3/modules-impl run 1/3
99+
[ 132.2s] mcpp@2026.8.13.1/gcc/release/touch-leaf/synth-20x3/modules-impl run 2/3
100+
[ 132.7s] mcpp@2026.8.13.1/gcc/release/touch-leaf/synth-20x3/modules-impl run 3/3
101+
mcpp@2026.8.13.1/gcc/release/touch-leaf/synth-20x3/modules-impl 0.48s (min 0.46 / max 0.48, n=3)
102+
[ 133.2s] mcpp@2026.8.13.1/gcc/release/edit-body/synth-20x3/modules-impl configure
103+
[ 133.2s] mcpp@2026.8.13.1/gcc/release/edit-body/synth-20x3/modules-impl seed build
104+
[ 133.4s] mcpp@2026.8.13.1/gcc/release/edit-body/synth-20x3/modules-impl run 1/3
105+
[ 134.2s] mcpp@2026.8.13.1/gcc/release/edit-body/synth-20x3/modules-impl run 2/3
106+
[ 134.9s] mcpp@2026.8.13.1/gcc/release/edit-body/synth-20x3/modules-impl run 3/3
107+
mcpp@2026.8.13.1/gcc/release/edit-body/synth-20x3/modules-impl 0.78s (min 0.76 / max 0.80, n=3)
108+
[ 135.7s] mcpp@2026.8.13.1/gcc/release/edit-comment/synth-20x3/modules-impl configure
109+
[ 135.7s] mcpp@2026.8.13.1/gcc/release/edit-comment/synth-20x3/modules-impl seed build
110+
[ 136.5s] mcpp@2026.8.13.1/gcc/release/edit-comment/synth-20x3/modules-impl run 1/3
111+
[ 137.0s] mcpp@2026.8.13.1/gcc/release/edit-comment/synth-20x3/modules-impl run 2/3
112+
[ 137.5s] mcpp@2026.8.13.1/gcc/release/edit-comment/synth-20x3/modules-impl run 3/3
113+
mcpp@2026.8.13.1/gcc/release/edit-comment/synth-20x3/modules-impl 0.48s (min 0.48 / max 0.52, n=3)
114+
[ 138.0s] mcpp@2026.8.11.3/gcc/release/cold/synth-20x3/headers configure
115+
[ 138.0s] mcpp@2026.8.11.3/gcc/release/cold/synth-20x3/headers seed build
116+
[ 139.6s] mcpp@2026.8.11.3/gcc/release/cold/synth-20x3/headers run 1/3
117+
[ 141.0s] mcpp@2026.8.11.3/gcc/release/cold/synth-20x3/headers run 2/3
118+
[ 142.3s] mcpp@2026.8.11.3/gcc/release/cold/synth-20x3/headers run 3/3
119+
mcpp@2026.8.11.3/gcc/release/cold/synth-20x3/headers 1.39s (min 1.34 / max 1.49, n=3)
120+
[ 143.8s] mcpp@2026.8.11.3/gcc/release/noop/synth-20x3/headers configure
121+
[ 143.8s] mcpp@2026.8.11.3/gcc/release/noop/synth-20x3/headers seed build
122+
[ 144.0s] mcpp@2026.8.11.3/gcc/release/noop/synth-20x3/headers run 1/3
123+
[ 144.2s] mcpp@2026.8.11.3/gcc/release/noop/synth-20x3/headers run 2/3
124+
[ 144.3s] mcpp@2026.8.11.3/gcc/release/noop/synth-20x3/headers run 3/3
125+
mcpp@2026.8.11.3/gcc/release/noop/synth-20x3/headers 0.16s (min 0.16 / max 0.16, n=3)
126+
[ 144.5s] mcpp@2026.8.11.3/gcc/release/touch-hub/synth-20x3/headers configure
127+
[ 144.5s] mcpp@2026.8.11.3/gcc/release/touch-hub/synth-20x3/headers seed build
128+
[ 144.7s] mcpp@2026.8.11.3/gcc/release/touch-hub/synth-20x3/headers run 1/3
129+
[ 146.0s] mcpp@2026.8.11.3/gcc/release/touch-hub/synth-20x3/headers run 2/3
130+
[ 147.5s] mcpp@2026.8.11.3/gcc/release/touch-hub/synth-20x3/headers run 3/3
131+
mcpp@2026.8.11.3/gcc/release/touch-hub/synth-20x3/headers 1.43s (min 1.37 / max 1.51, n=3)
132+
[ 149.0s] mcpp@2026.8.11.3/gcc/release/touch-leaf/synth-20x3/headers configure
133+
[ 149.0s] mcpp@2026.8.11.3/gcc/release/touch-leaf/synth-20x3/headers seed build
134+
[ 149.2s] mcpp@2026.8.11.3/gcc/release/touch-leaf/synth-20x3/headers run 1/3
135+
[ 150.1s] mcpp@2026.8.11.3/gcc/release/touch-leaf/synth-20x3/headers run 2/3
136+
[ 150.9s] mcpp@2026.8.11.3/gcc/release/touch-leaf/synth-20x3/headers run 3/3
137+
mcpp@2026.8.11.3/gcc/release/touch-leaf/synth-20x3/headers 0.86s (min 0.84 / max 0.90, n=3)
138+
[ 151.8s] mcpp@2026.8.11.3/gcc/release/edit-body/synth-20x3/headers configure
139+
[ 151.8s] mcpp@2026.8.11.3/gcc/release/edit-body/synth-20x3/headers seed build
140+
[ 151.9s] mcpp@2026.8.11.3/gcc/release/edit-body/synth-20x3/headers run 1/3
141+
[ 152.8s] mcpp@2026.8.11.3/gcc/release/edit-body/synth-20x3/headers run 2/3
142+
[ 153.7s] mcpp@2026.8.11.3/gcc/release/edit-body/synth-20x3/headers run 3/3
143+
mcpp@2026.8.11.3/gcc/release/edit-body/synth-20x3/headers 0.86s (min 0.86 / max 0.86, n=3)
144+
[ 154.5s] mcpp@2026.8.11.3/gcc/release/edit-comment/synth-20x3/headers configure
145+
[ 154.5s] mcpp@2026.8.11.3/gcc/release/edit-comment/synth-20x3/headers seed build
146+
[ 155.4s] mcpp@2026.8.11.3/gcc/release/edit-comment/synth-20x3/headers run 1/3
147+
[ 156.7s] mcpp@2026.8.11.3/gcc/release/edit-comment/synth-20x3/headers run 2/3
148+
[ 158.0s] mcpp@2026.8.11.3/gcc/release/edit-comment/synth-20x3/headers run 3/3
149+
mcpp@2026.8.11.3/gcc/release/edit-comment/synth-20x3/headers 1.35s (min 1.31 / max 1.39, n=3)
150+
[ 159.4s] mcpp@2026.8.11.3/gcc/release/cold/synth-20x3/modules configure
151+
[ 159.4s] mcpp@2026.8.11.3/gcc/release/cold/synth-20x3/modules seed build
152+
[ 177.5s] mcpp@2026.8.11.3/gcc/release/cold/synth-20x3/modules run 1/3
153+
[ 195.4s] mcpp@2026.8.11.3/gcc/release/cold/synth-20x3/modules run 2/3

0 commit comments

Comments
 (0)