A pipeline can be slow in more than one way. Jobs might wait for runners, spend most of their time installing tools, or finish quickly but leave developers searching through logs to understand a failure. Adding runners helps only one of those problems.
Start with the delay your team encounters most often. The aim is to help someone decide what to do next while the change is still fresh in their mind, without making a passing pipeline less trustworthy. You don't need to redesign every pipeline to make progress.
Find where a change spends its time
Choose a frequently changed project and look at several recent pipelines, including a failed run, a busy period, and a run without a warm cache. Follow the path from the push to the result the developer needed. Separate time spent waiting for a runner from time spent preparing the job, running checks, transferring files, and waiting for other jobs.
Ask the people using that pipeline where they lose time. A twenty-minute pipeline that reports a syntax error in its first minute may be less disruptive than a ten-minute pipeline that reveals the same error at the end. A quick failed job can still cost half an hour if its output doesn't identify the test or explain how to repeat it.
Agree on one improvement to try and how you'll judge it. For example, you might want common test failures to reach the author sooner, fewer jobs to be rerun without a code change, or shorter queues during the afternoon peak. Keep total job time and infrastructure cost alongside the time a developer waits; parallel work can improve one while increasing the others.
If most of the delay is before execution starts, inspect runner demand and capacity before rewriting tests. The runner separation recommendation explains how to adjust pools without letting untrusted jobs reach protected resources. A queue isn't a reason to remove that separation.
Bring the checks that help most toward the start
Put inexpensive checks for common mistakes early enough to save someone a longer wait. Configuration validation, compilation, linting, and focused tests often fit here. Follow them with the broader checks needed before merging or releasing. Which check runs first should reflect the failures your team actually encounters, not a universal order for every language or application.
Look for jobs that wait on work they don't use. Suppose an API test needs the application build but waits for an unrelated documentation build because both are in the previous stage. A needs relationship can let that test start when its actual prerequisite finishes. Keep dependencies that matter: a packaging job still needs the outputs and successful checks required for the package it publishes.
When changing those relationships, check artifact delivery too. Jobs using needs download artifacts from the jobs listed there, rather than every earlier stage. An apparently unrelated scheduling edit can otherwise leave a job without its build output.
Parallelize independent tests when execution time, rather than runner availability, is the problem. Start with a small number of groups and balance them by observed duration. Ten test files that each take a second aren't comparable to one integration test that takes several minutes. Include repeated setup and data preparation in the comparison, and make sure parallel tests don't compete over the same database, ports, or external account.
Keep the simpler arrangement if extra parallelism adds contention, queue time, or maintenance work without shortening the wait. Splitting a suite isn't an improvement merely because more jobs appear in the graph.
Avoid running the same work unnecessarily
Review which events create pipelines and which jobs each event needs. workflow:rules controls pipeline creation; job rules controls the jobs included. Use them together so a push to an open merge request doesn't produce both a branch pipeline and a merge request pipeline doing the same work unintentionally. Keep distinct pipelines when they answer different questions, such as checking a proposed change and publishing a release.
Change-based selection can help in a repository with independent applications. Before adding rules:changes, identify files that affect more than one application: shared libraries, dependency lockfiles, build images, and pipeline configuration are common examples. A path filter that ignores those inputs can produce a fast green pipeline for an untested change. Try both an application-only edit and a shared edit, and inspect which jobs are created.
Check new branches, schedules, and manually started pipelines separately. They don't all have the same comparison base as a merge request. Where you use compare_to, choose the ref because it represents the comparison you need, rather than copying a rule from another project. Keep a broader check at an appropriate point, such as before release, when selective testing can't confidently cover the dependencies.
For build and test work that can stop safely, configure redundant-pipeline cancellation and interruptible so superseded commits don't occupy runners unnecessarily. Check the configured auto-cancel mode: the default conservative behavior won't cancel a pipeline once a non-interruptible job has started. Deployment, data migration, and other state-changing jobs need a separate decision about interruption; stopping them midway can leave work to repair.
Reuse preparation, not assumptions about correctness
If preparation dominates a job, compare the cost of downloading an image, installing tools, restoring a cache, and running the work itself. A maintained image with the required tools can avoid repeating installation, but it also needs an owner to update and rebuild it. Smaller images aren't automatically faster if every job then installs the same toolchain from scratch.
Use caches for reusable downloads or other data the job can reconstruct. Choose cache keys that distinguish incompatible dependencies and environments, such as different lockfiles or toolchain versions. Keep the normal installation or verification step so a missing or stale cache doesn't change whether the job produces a correct result. Measure cold and warm runs; a cache that costs more to transfer than it saves isn't helping.
Use job artifacts when a later job needs the particular output produced by an earlier job. A compiled package or test report shouldn't depend on finding the right entry in a best-effort cache. Keep release outputs for the period in which your team may need to inspect or redeploy them. Deployment and recovery planning explains how that retention decision affects recovery.
Avoid sharing caches across work with different trust levels just to improve hit rates. An untrusted job that can replace data later consumed by a protected build may change what that build executes.
Make failures understandable and worth acting on
A failure should tell the author what went wrong, where to look, and how to reproduce the check. Give jobs names that describe their purpose, retain the relevant output, and include the command or test selection needed to repeat a failure. Keep credentials and unrelated environment data out of diagnostics.
Publish JUnit test reports so readers can inspect failed tests in GitLab instead of searching through a long log. The report doesn't determine job success: the test command still needs to return a non-zero exit status when tests fail. Try a deliberately failing test and confirm both the failed job and the readable report. A reporting improvement that accidentally turns the job green defeats its purpose.
When a test fails intermittently, investigate what changes between runs: ordering, shared state, time, resource pressure, or an external dependency. Retries can help with a known temporary infrastructure failure, but repeatedly rerunning until green conceals the reliability problem. If a team temporarily removes a flaky test from required checks, give the repair an owner and retain a way to see that the coverage is missing. allow_failure should express a deliberate decision that a check isn't required, not become the default response to unexplained failures.
Once one project has a better approach, consider whether other teams have the same need. Adopting and maintaining reusable pipelines helps turn a successful change into maintained pipeline code without imposing every project's choices on everyone else.
Compare the result with the problem you started with
Try one change at a time where possible, then compare similar runs before and after it. Include busy periods and failed runs, not just the fastest successful example. Look at the time to a meaningful result, queue time, execution time, reruns, and resource use. Ask developers whether the result is easier to act on.
Check that the jobs you expect still run for merge requests, shared-file changes, default-branch updates, schedules, and releases where those paths apply. Keep a known failing change in your checks of the pipeline itself. Faster completion with fewer required tests, missing reports, or hidden failures isn't the result you're trying to achieve.
Record what improved and what didn't in the work item for the change. That gives the next maintainer a reason for the arrangement and helps the team choose the next improvement from experience rather than starting the same investigation again.
Further Reading
- Analyze pipeline efficiency to investigate job duration, runner delays, and repeated setup work.
- Define job dependencies with
needsand choose which artifacts a job downloads when removing unnecessary stage waits. - Control pipeline creation and choose when jobs run when reducing duplicate or irrelevant work.
- Configure caching for reproducible jobs that can benefit from reused downloads.
- Publish unit test reports to make failures easier to inspect and repeat.
- Configure
interruptiblewhen deciding which superseded jobs can stop safely.