Skip to content
Source
Sign inSign up

Measure how fast jobs start

CI / Speed and debugging

Measure how fast CI jobs start

Your CI jobs take long to start, and you want to find the slow stage before you change job sizes or limits. The startup diagnostic workflow measures each stage of a start on Source, with no install and no test suite.

3 min read

A start on Ravion has four stages, in this order:

  • The queue: the job waits until the account and the repository can run one more job.
  • The VM placement: Ravion finds a host and starts a fresh VM on it. The agent on the VM then starts the job container from the CI image.
  • The checkout: the job container gets your commit.
  • The first command: the runner loads your workflow file and starts the first step.

A local run has no queue and no VM. So this measurement runs on Source.

You need:

  • Write access to a repository on Source whose jobs run on Ravion, to push the workflow and start it.
  • The src CLI, logged in.

1. Add the diagnostic workflow

Create .source/workflows/startup-diagnostic.ts. This is the diagnostic workflow of the TanStack Source repository:

import { defineWorkflow, manual } from '@tanstack-source/ci'

// No install or test suite: the forge's job record measures provisioning and checkout.
// Run twice on the same ref to compare a fresh plan/cache with their cached paths.
const probe = {
  name: 'First command',
  run: `node -e 'console.log(JSON.stringify({firstCommandAt:Date.now(),node:process.version,arch:process.arch}))'`,
}
const common = { timeoutMinutes: 5, checkout: { depth: 1, lfs: false } } as const

export default defineWorkflow('startup-diagnostic', { on: [manual()], cancelOlderRuns: false })
  .job('node-small', { ...common, image: 'node', size: 'small', steps: [probe] })
  .job('node-large', { ...common, image: 'node', size: 'large', steps: [probe] })
  .job('browser-large', { ...common, image: 'browser', size: 'large', steps: [probe] })
  • It has only a manual trigger, no secrets, no external network access, and a five-minute limit for each job.
  • It compares a small and a large job on the node image, and a large job on the browser image.

Push it to a branch in your repository.

2. Start it on that branch

Replace OWNER/REPO and BRANCH:

src api repos/OWNER/REPO/ci/workflows/startup-diagnostic/runs -X POST -f ref=BRANCH

The answer is the new run. Write down its id.

3. Read the timing of each job

When the run ends, read the timing of its jobs. Replace RUN_ID:

src ci timing RUN_ID

The output has one table for each job. Each row is one part of the job, in order. These parts make the four stages:

StageParts
The queueWait for a container slot
The VM placementProvision the container, Start the image
The checkoutMake the repository, Fetch the commit, Check out the commit
The first commandStart the runner, First command

The parts Make the job and Start the job come between the queue and the VM placement. In them, the forge makes the job and starts it.

For what each part does, see What each part means.

4. Make the slow stage faster

  • The queue: other jobs of the account or the repository run at the same time. An admin of the repository can change how many of its jobs run at once with src ci settings --containers <n>.
  • The VM placement: the job waited for a free host, or its VM pulled the CI image, which a new disk does not have yet. A site admin can give the repository Ravion hosts of its own.
  • The checkout: in Fetch the commit, the job fetches your commit with git from the git servers of the forge, at the depth of checkout.depth. This workflow fetches one commit (depth: 1). A job with depth: 0 fetches all the history, which takes longer. With lfs: true, Check out the commit also downloads the LFS files of the commit.

Done

You know how long each stage of a start takes on Ravion: the queue, the VM placement, the checkout and the first command. Change the slowest stage first.

Tip

A repository that runs one job at a time runs these three jobs one after the other. Other CI jobs of the account wait in the same queue. So the queue wait shows how busy the account and the repository are.