Repository navigation
Back off job polling from 250ms up to the polling interval - #3890
Open
sethboyles wants to merge 1 commit into
Open
sethboyles wants to merge 1 commit into
sethboyles wants to merge 1 commit into
Conversation
Job polling checked the job once immediately and then slept a fixed polling interval (3s) between checks. Short asynchronous jobs, such as app and route deletes, are rarely complete at the first check, so every such command took at least 3s even when the job finished in well under a second. Poll at 250ms, 750ms and 1.75s after the start, then on the existing polling-interval grid (3s, 6s, ...), so every check today's CLI makes still happens and no job is detected later than before. The event stream now closes right after the terminal event instead of sleeping one more interval first. Timeout checks are unchanged. Add Sleep to the ccv3 Clock so the delay sequence can be tested deterministically. ai-assisted=yes AI-Tool-Used: Claude, Codex AI-Tool-Use-Level: High AI-Code-Category: Production Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sethboyles
force-pushed
the
feature/cli-job-poll-backoff
branch
from
November 2, 2026 22:45
6c90d43 to
14e0808
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of the Change
ccv3 job polling (
PollJob,PollJobForState,PollJobToEventStreaminapi/cloudcontroller/ccv3/job.go) checks the job once immediately and then sleeps a fixed polling interval (3s,util/configv3/defaults.go) between checks. Short Cloud Controller jobs, such as app and route deletes, are rarely complete at that first check. So every command that waits on one takes at least 3s, even when the job finishes in well under a second.This PR replaces the fixed sleep with a short ramp of early checks that then joins the existing polling grid:
PollJobToEventStreamnow closes the stream right after the terminal event, instead of sleeping one more interval before closing.Clockinterface gainsSleep(time.Duration)(real implementationtime.Sleep; fake regenerated), so the schedule is tested deterministically instead of against wall-clock bounds.Only ccv3 job polling changes. Build/staging, package, app-start and task polling still use the existing fixed interval.
Request-count impact
GET /v3/jobs/:guidis a small read: it looks up the job, its warnings and the linked resource. Each poll GET keeps the existing retry behavior for 5xx responses (api/cloudcontroller/wrapper/retry_request.go). If Cloud Controller rate limiting is enabled, these GETs count against the per-user limit as they do today. Operators can watch Cloud Controller request rates and 429 responses after rolling out a CLI version that includes this.Why Is This PR Valuable?
Every async CLI command that waits on a job returns sooner when its job is short, including
cf delete,cf delete -r, route deletes and service operations. For example,cf delete -rpolls the app-delete job and then the route-delete jobs, so it currently pays at least two 3s waits.Measured against a small Cloud Foundry foundation, building
mainand this branch and alternating them for 10 runs each. Each run deleted a freshly created app; for-rthe app had one mapped route:mainmean / mediancf delete -fcf delete -f -rOn that foundation, app-delete jobs usually took a few seconds to be picked up by a worker. So
cf delete -fmostly finished at the 6s grid point either way, but it no longer slipped to the 9s point.cf delete -f -rruns a second round of job polling for the route deletes, which are short, so it roughly halves. In an earlier acceptance-test run,cf delete -f -raveraged 9.1s over 165 calls. CI pipelines and test suites that run many such commands benefit the most.Applicable Issues
None filed.
How Urgent Is The Change?
Not urgent.
Other Relevant Parties
Anyone running many async CLI commands, such as CI pipelines and acceptance-test suites. I will open a separate PR for
v8once this is accepted.🤖 Generated with Claude Code