Skip to content

Commit 7b04083

Browse files
committed
ci: 每片按耗时升序跑,让「核心已覆盖」成为一个可判断的中间状态
LPT 装箱按降序考虑成员,所以每片交给 run_members.sh 的顺序也是降序 —— 贵的先跑。 反过来。 理由不是「更快发现失败」,而是让维护者能在跑完之前就**做决定**。少数时候,一个 改动在核心已被证明覆盖之后就值得合入,不必等尾巴跑完。 一次全量 linux run 是 13427s 成员墙钟,前四名占 52%(grpc-codegen 3363s、 grpc-module 1724s、opencv-module-dnn 1017s、protobuf-protoc 945s)。按这个顺序, 约 55 个成员在第一个重量级启动前就已报完 —— 于是「除了那四个已知的贵成员之外 全绿」是一个**存在的、早早出现的、可以判断的状态**。贵的先跑则没有这种中间状态: 一小时内什么都说明不了,然后一次性全部结束。 超时的后果按同一逻辑读:分片现在丢的是贵成员而不是便宜成员 —— 那正是维护者本来 就会选择跳过的那一半,数量少,且在 tests/member-timings.tsv 里逐个有名有姓。 装箱与顺序是两个问题,这里只动后者:LPT 仍按降序装箱(否则箱子会不均)。三平台 七个分片逐一比对过成员集合 —— 完全一致。单片路径(`--shard 0/1`)同样升序,所以 本地与 CI 的顺序是同一个。
1 parent fc27c08 commit 7b04083

1 file changed

Lines changed: 39 additions & 6 deletions

File tree

tests/plan_shards.lua

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,6 @@ if #members == 0 then
6969
table.sort(members)
7070
end
7171

72-
if shardCount <= 1 then
73-
print(table.concat(members, " "))
74-
return
75-
end
76-
7772
-- ── measured times ────────────────────────────────────────────────────────
7873
-- Format: <platform>\t<member>\t<seconds>
7974
local times, samples = {}, {}
@@ -96,6 +91,43 @@ if #samples > 0 then
9691
median = samples[math.ceil(#samples / 2)]
9792
end
9893

94+
-- ── run order: cheapest first ─────────────────────────────────────────────
95+
--
96+
-- Packing and ORDER are different questions. LPT has to consider members
97+
-- descending or the bins come out lopsided, and that stays exactly as it was;
98+
-- this only decides the sequence a shard hands to run_members.sh.
99+
--
100+
-- Cheapest first so that BREADTH is covered early, and a maintainer can act on
101+
-- the run before it finishes.
102+
--
103+
-- That is the reason, and it is a deliberate one: occasionally a change is
104+
-- worth merging once the core is demonstrably covered, without waiting out the
105+
-- tail. A full linux run is 13427s of member wall-clock and four members are
106+
-- 52% of it (grpc-codegen 3363s, grpc-module 1724s, opencv-module-dnn 1017s,
107+
-- protobuf-protoc 945s). Ordered this way, ~55 members have reported before
108+
-- the first heavyweight even starts — so "everything but the four known
109+
-- expensive ones is green" is a state that exists, early, and can be judged.
110+
-- With the expensive members leading, the run has no such intermediate state:
111+
-- it is uninformative for an hour and then complete.
112+
--
113+
-- Read the consequence the same way. A shard that hits its timeout now loses
114+
-- the expensive members rather than the cheap ones — which is the half a
115+
-- maintainer would choose to skip anyway, few in number and named in
116+
-- tests/member-timings.tsv.
117+
local function cheapest_first(list)
118+
table.sort(list, function(a, b)
119+
local ta, tb = times[a] or median, times[b] or median
120+
if ta ~= tb then return ta < tb end
121+
return a < b -- deterministic across machines
122+
end)
123+
return list
124+
end
125+
126+
if shardCount <= 1 then
127+
print(table.concat(cheapest_first(members), " "))
128+
return
129+
end
130+
99131
-- ── dependency signature, for affinity ────────────────────────────────────
100132
local function deps_of(member)
101133
local toml = read_file("tests/examples/" .. member .. "/mcpp.toml")
@@ -165,4 +197,5 @@ if os.getenv("PLAN_SHARDS_DEBUG") then
165197
end
166198
end
167199

168-
print(table.concat(shards[shardIndex] and shards[shardIndex].members or {}, " "))
200+
print(table.concat(
201+
cheapest_first(shards[shardIndex] and shards[shardIndex].members or {}), " "))

0 commit comments

Comments
 (0)