mirror of
https://github.com/morluto/rea.git
synced 2026-12-01 02:49:12 +00:00
fix(ci): keep equal-duration shard allocation from leaving jobs empty (#14257)
Co-authored-by: ShuaixinHuang <ShuaixinHuang@users.noreply.github.com>
This commit is contained in:
1 parent
8a77faf842
commit
5aef49a421
2 files changed
+14
-1
No files matched your search
@@ -235,3 +235,13 @@ describe("duration shard allocation", () => {
|
||||
).toBe(300);
|
||||
});
|
||||
});
|
||||
|
||||
it("uses both shards when equal files fit into spare workers in one shard", () => {
|
||||
const items = ["a", "b"].map((key) => ({
|
||||
item: key,
|
||||
key,
|
||||
duration: 20,
|
||||
laneWidth: 2,
|
||||
}));
|
||||
expect(allocateByDuration(items, 2)).toEqual([["a"], ["b"]]);
|
||||
});
|
||||
@@ -181,7 +181,10 @@ export function allocateByDuration<T>(
|
||||
for (const candidate of shards.slice(1)) {
|
||||
const phases = place(candidate.phases, entry, duration);
|
||||
const wall = wallOf(phases);
|
||||
if (wall < chosenWall) {
|
||||
if (
|
||||
wall < chosenWall ||
|
||||
(wall === chosenWall && candidate.items.length < chosen.items.length)
|
||||
) {
|
||||
chosen = candidate;
|
||||
chosenPhases = phases;
|
||||
chosenWall = wall;
|
||||
|
||||
Reference in new issue
Block a user