07Distributed task execution
Give heavy tasks a bigger machine
List two machine sizes. vx learns which tasks need the big one, and starts it only for them.
cpu4: { max: 8, cpu: 4, memory: '16GB' },cpu16: { max: 2, cpu: 16, memory: '64GB' },Declare two sizes
Section titled “Declare two sizes”dte({ workers: { linux: { machines: { cpu4: { max: 8, cpu: 4, memory: '16GB', }, cpu16: { max: 2, cpu: 16, memory: '64GB', runsOn: 'ubuntu-latest-16-cores', }, }, }, }, adapter: github(),}),Read the new size as: up to 2 machines of 16 cores and 64GB, on the ubuntu-latest-16-cores runner.
You can now offer a big machine without paying for it on every task.
Send each size to its runner
Section titled “Send each size to its runner”Run vx dte init again. vx-worker.yml now maps each size to its runner:
runs-on: ${{ fromJSON('{"linux.cpu4":"ubuntu-latest","linux.cpu16":"ubuntu-latest-16-cores"}')[inputs.size] }}Look at the two keys: linux.cpu4 and linux.cpu16, one per size.
You can now run each size on the CI runner you pay for.
How vx picks the size
Section titled “How vx picks the size”- A task with no history runs on any free core. To decide how many machines to start, vx counts it as 2 cores and 4GB.
- vx records the cores and memory it used.
- A task that used about all of its machine runs on a bigger size next time.
Check yourself A vite build used every core of a cpu4 machine in its last run. Where does it run next?
On cpu16. A task that filled its machine only goes to a bigger one. A lint task that used one
core keeps sharing a cpu4.
1. Run 1: the build fills linux.cpu4#1
Tasks status cache ±usual time cpu mem outputs blocks worker task success miss — 16ms 21% 2.1MB 23B 1 linux.cpu4#1 @demo/ui#build success miss — 3.01s 396% 24MB 19B 0 linux.cpu4#1 @demo/web#build workers linux.cpu4#1 stopped 2 done · warm-up 0.2s · @demo/ui#build, @demo/web#buildRead the cpu column: @demo/web#build used 396%, every core of a 4-core machine.
2. Run 2: vx starts linux.cpu16#1 for it
Tasks status cache ±usual time cpu mem outputs blocks worker task success miss +3ms 19ms 18% 2.1MB 23B 1 linux.cpu4#1 @demo/ui#build success miss +12ms 3.02s 394% 23MB 19B 0 linux.cpu16… @demo/web#build workers linux.cpu4#1 left 1 done · warm-up 0.1s · @demo/ui#build linux.cpu16#1 stopped 1 done · warm-up 0.1s · @demo/web#buildThe small build stays on linux.cpu4#1. The heavy one gets linux.cpu16#1: the worker column cuts long names, the workers line names it in full.
You can now predict which tasks get the big machine, and see it happen.
PatternsCommon setups
Some tasks on macOS
Section titled “Some tasks on macOS”Add a type whose machine names its platform. vx dte init runs it on macos-latest:
mac: { machines: { m1: { max: 2, cpu: 3, memory: '7GB', platform: 'darwin-arm64', }, },},A task with exec.platforms: ['darwin-arm64'] runs only there.
No cap on a size
Section titled “No cap on a size”Leave out max and a run starts as many as its work needs:
cpu4: { cpu: 4, memory: '16GB' },Count new tasks bigger
Section titled “Count new tasks bigger”unmeasured changes the 2 cores and 4GB of step 1. Raise it if most of your tasks are heavy:
dte({ unmeasured: { cpu: 4, memory: '8GB' }, /* … */ }),You can now add macOS, lift a cap and tune how new tasks are counted.
DetailsEvery option
A machine size
Section titled “A machine size”| Field | What it does | Default | Example |
|---|---|---|---|
cpu |
Its cores. vx counts on them until the worker reports its real machine. Required. | none | 4 |
memory |
Its memory, in bytes or as text. Required. | none | '16GB', '512MiB' |
max |
How many one run may start. | no cap | 8 |
platform |
linux-x64, linux-arm64, darwin-x64 or darwin-arm64. A worker that joins on another is refused. |
this machine’s, not checked | 'darwin-arm64' |
runsOn |
The CI runner label vx dte init writes for it. |
the platform’s GitHub-hosted runner | 'ubuntu-latest-16-cores' |
Names of types and sizes use letters, digits, _ and -. A field vx does not know, such as maxx, is refused.
How a run sizes itself
Section titled “How a run sizes itself”- Only work counts: a task that missed the cache, or waits on one that did, and every uncached task.
- A task with history books its average cores (a whole core at least) and its peak memory.
- A task that used 90% or more of its machine’s cores or memory takes a whole bigger machine next time.
- Change a size’s cores, memory, platform or runner, and vx forgets what it measured for that size.
- A worker that is idle, with nothing left it could take, leaves.
All of dte()’s options: Spread a CI run over several machines.