Skip to content

Smarter resource checking - Only check triggering resources - #9492

Merged
taylorsilva merged 13 commits into
masterfrom
1445-only-check-triggering-resources
Mar 25, 2026
Merged

taylorsilva merged 13 commits into
masterfrom
1445-only-check-triggering-resources

Conversation

@taylorsilva

@taylorsilva taylorsilva commented Mar 18, 2026 •

Copy link
Copy Markdown
Member

Changes proposed by this PR

closes #1445

The goal of this PR is to reduce the number of resource checks that currently happen in Concourse. I'm going to describe the current behaviour of Concourse and then explain what this PR changes.

Current Behaviour

There are three main ways a build is started: manually triggered, automatic trigger, and rerun of previous build.

In parallel, there is also Lidar running every 10s, looking for any resources that have surpassed their check_every interval. Lidar performs this check for every resource in unpaused pipelines, except resources that are only used in put steps.

Manually triggered builds: These happen when a user starts a new build via the web UI or fly trigger-job. In both of these cases, Concourse will create resource checks for all inputs of the job, overriding the check interval of all resources. The job will only start once all input resources have been checked.

Automatically triggered builds: These happen when a check started by Lidar finds a new version of an input to a job. In this case, no extra resource checks are made and the job is started with the latest set of input versions available from all resources of the job.

Rerun builds: These never create checks because they use the previous builds input versions. These are manually created.

With this setup, we end up with a system that is constantly running checks, more than it really needs to. The benefit of this is that when a job is automatically triggered, we don't need to wait for any other resource checks to run, we can just start the build. The con with this approach is that we waste a lot of compute checking resources and end up hammering external systems constantly.

Behaviour Proposed by this PR

Lidar only creates checks for resources that are triggers for jobs, excluding triggers that also have passed constraints. This alone should drop the number of checks regularly occurring in a Concourse cluster.

The API endpoint used to manually trigger new builds no longer creates checks. That is now done by the BuildStarter.

We now move the creation of most resource checks into the atc/scheduler/ package, specifically the BuildStarter.

Behaviour is the same for rerun builds, and mostly the same for manually triggered builds. Automatically triggered builds are slightly different.

Manually triggered builds: The check interval of all input resources is overridden, same as previous behaviour when checks were made in the atc/api/ layer. The build is started once all input resources have been checked. The big change here is which resources the job waits to check; only resources that are inputs with no passed constraints.

Automatically triggered builds: These builds start after all non-triggering input resources have been checked, if they have passed their check interval. We don't check triggering resources because Lidar will check them, which is the same behaviour as before.

In all cases, when the BuildStarter creates checks, it won't create checks for resources that are pinned to a specific version, and any that have passed constraints.

With checks not constantly running for as many resources, the baseline amount of compute required for a Concourse cluster should be lower on average. External systems will also be hammered much less, though they will see spikes whenever a job starts and all it's non-triggering resources are checked. The con with this approach is that jobs will take longer to start if they need to wait for any resources to be checked.

Migration

There is a migration in this PR that adds a column to help us track when the next check of a resource should occur. The default value this column has for all resources after the migration is applied is Unix epoch. I don't think this should have any adverse affects. Lidar will only check trigger: true jobs, and whenever a job is scheduled, then all of its inputs will be checked. I don't expect there to be a "stampeding herd" of checks being run after the migration is applied.

@taylorsilva
taylorsilva force-pushed the 1445-only-check-triggering-resources branch 3 times, most recently from 83ad44f to fdb2b15 Compare March 20, 2026 15:15
and have the BuildStarter in the atc/scheduler/ package create check
builds for input resources, if necessary.

Overall this should result in a lot less checks happening, which means
less hammaring of external systems (i.e. Git servers).

When a job is triggered, then all of its inputs will be checked. We skip
inputs that are pinned or have passed constraints on them. In both of
those cases, checking the resource will not change the list of possible
input versions for the job.

I debated if the BuildStarter should create in-memory or DB checks. DB
checks are de-duplicated at the db level, but will grow the size of that
table faster.
In-memory checks are de-duplicated at the individual web node. So in
multi-web node setups there is a chance that duplicate check builds are
made. The only negative consequence of this is that the check runs twice
instead of once.

I decided to use in-memory builds since it maintains current behaviour
best. Most checks run as in-memory checks currently via lidar, so I
decided to stick with this approach. This PR is mostly shifting who
creates the check workloads from Lidar to the Schedular, so I think it
makes sense to keep using in-memory checks.

Signed-off-by: Taylor Silva <[email protected]>
this is now done in the scheduler, if necessary.

Signed-off-by: Taylor Silva <[email protected]>
We'd do the join and not use it for filtering. I'm guessing we added
this thinking we needed it for getting put-only resources. That ended up
not being the case though since we use rs.last_check_succeeded and
rs.last_check_build_id to get put-only resources.

Signed-off-by: Taylor Silva <[email protected]>
We now track when the next check of a resource _should_ occur. This
allows us, in the scheduler, to issue checks for resources that have
exceeded their check interval. It also allows us to be smarter about
which resources we check by inspecting the nextCheckTime of the
resource.

Signed-off-by: Taylor Silva <[email protected]>
Signed-off-by: Taylor Silva <[email protected]>
Signed-off-by: Taylor Silva <[email protected]>
it was part of the system used before Lidar was made

Signed-off-by: Taylor Silva <[email protected]>
because logically it made no difference to what the query would return.
The main thing we want to check is if the next_check_time is before the
build's created_time. If next_check_time is before the created_time,
then last_check_end_time would also be before, we don't need to check
it.

Signed-off-by: Taylor Silva <[email protected]>
@taylorsilva
taylorsilva force-pushed the 1445-only-check-triggering-resources branch from f3cf9e6 to ce99939 Compare March 23, 2026 16:29
@taylorsilva

taylorsilva commented Mar 23, 2026 •

Copy link
Copy Markdown
Member Author

I wanted to track three things to evaluate how this change in scheduling of jobs and checks works. I started a local instance of Concourse running these three pipelines (same one's I used in the issue):

The three metrics I want to track over a ~1hr period are:

  1. Rate of checks being scheduled
  2. Total checks run
  3. Total builds for jobs run

My hope is that 1 and 2 go down (less checks being scheduled) and 3 stays the same. Initialization of jobs should slow down a bit since we have to wait for checks to run now (not in all cases), but overall I'd expect Concourse to be able to get through roughly the same number of builds before and after this PR.

So I set the pipelines and let them run for 1hr. They all use time resources with different source.intervals, and different triggering and passed constraints setup. I used the default check interval of one minute for all of them.

Current Behaviour

image
  • Rate: ~0.7 checks per second
  • Total Checks run: 2617
  • Total Job Builds Ran: 441

PR Behaviour

image
  • Rate: ~0.24 checks per second (lower is better, means less periodic checks occurring)
  • Total Checks run: 824 (less is better)
  • Total Job Builds Ran: 442 (similar is good, no change in scheduling rate)

Summary

It appears this PR achieves the desired goal. The rate and total number of checks run dropped by 68%, but the number of builds run over the 1hr period was the same at ~442 builds successfully run.

I'm still cautiously making this change, so I'm planning to run it on our CI env first as a dev release after merging.

@taylorsilva
taylorsilva marked this pull request as ready for review March 23, 2026 21:16
@taylorsilva
taylorsilva requested review from a team and Copilot March 23, 2026 21:16

This comment was marked as resolved.

Signed-off-by: Taylor Silva <[email protected]>
For some reason this test is flaky in CI. I haven't gotten it to fail locally (`ginkgo --until-it-fails`) and even `fly intercept`'ing and re-running the test has always resulted in it passing.

My gut says this is related to CPU/Memory pressure causing the test to flake, but I'm not 100% sure about that. We also set `--flake-attempts` to 3 and this test fails all three times, which is VERY surprising to me. This makes me think the setup of the test is bad, but I can't see where it could be messing up.

The error I keep seeing is that `resources` has a length of three instead of two. I'd expect this to happen if the `BeforeEach()` didn't run. Maybe ginkgo is messing up the parallelization some how??

I'm going to mark the test as `Serial`; maybe we're somehow conflicting with other tests?? I don't see how that would happen, but having it flake like this is very annoying. If setting it to `Serial` makes it pass consistently then I'll do it.

Signed-off-by: Taylor Silva <[email protected]>
Comment thread atc/db/check_factory_test.go Outdated
Comment on lines +512 to +515
It("returns the triggering, and errored put-only resource", func() {
Expect(resources).To(HaveLen(2))
Expect(resources[0].Name()).To(Equal("some-resource-trigger"))
Expect(resources[1].Name()).To(Equal("some-put-only-resource"))

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason this test is flaky in CI. I haven't gotten it to fail locally (ginkgo --until-it-fails) and even fly intercept'ing and re-running the test has always resulted in it passing.

My gut says this is related to CPU/Memory pressure causing the test to flake, but I'm not 100% sure about that. We also set --flake-attempts to 3 and this test fails all three times, which is VERY surprising to me. This makes me think the setup of the test is bad, but I can't see where it could be messing up.

The error I keep seeing is that resources has a length of three instead of two. I'd expect this to happen if the BeforeEach() didn't run. Maybe ginkgo is messing up the parallelization some how??

I'm going to mark the test as Serial; maybe we're somehow conflicting with other tests?? I don't see how that would happen, but having it flake like this is very annoying. If setting it to Serial makes it pass consistently then I'll do it.

@taylorsilva
taylorsilva merged commit 16ef245 into master Mar 25, 2026
12 checks passed
@taylorsilva
taylorsilva deleted the 1445-only-check-triggering-resources branch March 25, 2026 14:52
@taylorsilva taylorsilva added this to the v8.2.0 milestone Mar 25, 2026
@taylorsilva

taylorsilva commented Apr 8, 2026 •

Copy link
Copy Markdown
Member Author

I updated ci.concourse-ci.org to see if anything breaks from this PR.

So far everything seems normal. Upgrade was done at 11:08am UTC-4.

@taylorsilva taylorsilva changed the title Only check triggering resources Smarter resource checking - Only check triggering resources May 6, 2026
kcbimonte pushed a commit to Aviator-Labs/docs-ci that referenced this pull request Jun 7, 2026
documents concourse/concourse#9492

Signed-off-by: Taylor Silva <[email protected]>
kcbimonte pushed a commit to Aviator-Labs/docs-ci that referenced this pull request Sep 26, 2026
documents concourse/concourse#9492

Signed-off-by: Taylor Silva <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Resources that are inputs to jobs that have no triggers should not check.

2 participants