CI / Speed and debugging
Find out where your CI time goes
A CI run is slow, and the log does not say why. The time can go to the queue, the start of the VM, the checkout, the install or the tests. The forge keeps the time of each part of each job, so you can find the slow part and fix it. It also compares each job with its last successful runs, so you see when a change made a job slower.
6 min read
You can read the timing on the run page, with src, with MCP and with REST.
You need:
- Read access to the CI runs of the repository. Only admins see the timing of a hidden workflow.
1. Open the run
Open the run on the CI tab of the repository. Then select a job.
2. Read the Timing card
The Timing card is above the log. Each row is one part of the job, with a bar at its place in the job and its duration.
The header of the card gives the total time of each kind of part:
- Waits for the forge: the job waits for a slot in the queue, or for the forge to start it.
- Forge work: the forge makes the job, starts the VM and the container of the job, checks out the commit, and collects the results.
- Steps of the workflow: the steps of your workflow file. A step that failed has a red bar.
What each part means explains each row.
3. See if a job got slower or faster
The forge compares each job that passed with the same job in the earlier runs of the workflow: the median time of its last 10 successful runs.
- In the Jobs graph, a job that took markedly longer shows an up arrow and its share, like +52%. A job that took markedly less shows a down arrow, like −30%. Hover the mark to read the median it compares with.
- At the top of the job's panel, a line says how long the job took and how that compares, for example This job took 9m 50s: 52% slower than the median of its last 10 successful runs, 6m 28s.
A job counts as slower or faster when it took at least 20% and at least 15 seconds more or less than the median. Between those, the panel says it was about as fast as usual. A job has no comparison until it has 3 earlier successful runs of the same workflow. A job that failed, was cancelled, or took the result of an earlier run (see Skip unchanged jobs) has none. A share link of a private pull request does not show it.
When a job got slower, read its Timing card (step 2) and compare it with the card of an earlier run of the same job.
4. Make the slow part faster
- If Install dependencies or another step downloads the same files in each job, keep them with
cache(). See the CI reference. - If a slow step, like a build, gets the same input files in many runs, skip it with a step cache.
- If Start the image is long, the VM of the job waited for a free host, or pulled the CI image. A site admin can give the repository hosts of its own.
- If Wait for a container slot is long, your runs start more jobs than can run at the same time. An admin can see and change the container limit of the repository with
src ci settings --containers <n>.
Done
You know which part of the job takes the time, and which change makes it faster. To measure the start of jobs in more detail, see Measure how fast CI jobs start.
Read the timing from a terminal or an agent
Find the id of the run:
src ci runs --limit 5Show the timing of every job of the run, or of one job:
src ci timing <run> src ci timing <run> --job "test (shard: 1)"For a script, add
--json. The answer is the same as the answer ofGET /api/v1/repos/<owner>/<repo>/ci/runs/<run>/timingand of the MCP toolget_ci_run_timing.
The output of src ci timing looks like this:
Timing of run 7c1e2d3f-4a5b-4c6d-8e7f-9a0b1c2d3e4f (ci)
build: success
KIND PART RESULT START TOOK
wait Wait for a container slot +0.0 s 4.1 s
forge Make the job +4.1 s 0.6 s
wait Start the job +4.7 s 0.4 s
forge Provision the container +5.1 s 0.4 s
forge Start the image +5.5 s 18.2 s
forge Make the repository +23.7 s 0.3 s
forge Fetch the commit +24.0 s 2.4 s
forge Check out the commit +26.4 s 1.2 s
forge Start the runner +27.6 s 0.8 s
step Set up Node success +28.4 s 1.1 s
step Install dependencies success +29.5 s 21.4 s
step Test success +50.9 s 98.2 s
forge Send the last logs and results +149.1 s 0.3 s
forge Collect the results +149.4 s 0.2 s
forge Remove the container +149.6 s 1.7 s
Total: wait 4.5 s, forge 26.1 s, step 120.7 s.
Speed: 151.3 s, 34% slower than the median of its last 10 successful runs (113.0 s).
The Speed line compares the job with its last successful runs, as in step 3. In --json, each job has it as trend: ms, medianMs, runs, change (the share above or below the median, like 0.34) and verdict (slower, faster or usual), or null.
If a job ended with an error, a line Error: <why> comes under its name. For example, a job whose container did not start fails before its first step, and this line tells you why. A job that never got a runner says queued, no runner. The forge waited for one until the job's timeoutMinutes.
src run view <run> --json jobs also gives the start and the end of each step, as gh run view does.
What each part means
| Part | What happens |
|---|---|
| Wait for a container slot | The job waits for a free slot in the queue of the account and of the repository. A long wait means that other jobs use the slots. |
| Make the job | The forge reads the plans of the run and makes the job's record. |
| Start the job | The forge starts the job. |
| Provision the container | The forge makes a token for the job. |
| Start the image | The runner starts a VM for the job, and the agent of the forge on the VM starts the container of the job from the CI image. A wait for a free host makes this longer, and so does a disk that does not have the CI image yet. |
| Make the repository, Fetch the commit, Check out the commit | The checkout of your commit in the container. The job fetches the commit with git from the git servers of the forge, at the depth of checkout.depth, then checks it out. With lfs: true, Check out the commit also downloads the LFS files of the commit. |
| Check out the extra checkouts | The other repositories that the job checks out. |
| Start the runner | The forge copies the runner into the container. The runner starts and loads your workflow file. |
| Your steps | The steps of your workflow, with their result. |
| Send the last logs and results | The runner sends the end of the log, the outputs and the summary. |
| Collect the results, Remove the container | The forge reads the results of the job and removes its container. |
| Debug window | The job ran again with debug, and its container stayed after its last step for people to run commands in it. See Debug a job in its container. |
Note
A job that ran before the forge kept the start of steps has an older timing. It shows the steps without a place in the job, and the checkout as one part. An older job can also show parts that new jobs do not have, like Restore the snapshot (repository), Download the checkout or Index the checkout.