Skip to content

client: don't fetch too much work for projects with zero resource share#7024

Merged
AenBleidd merged 2 commits into
masterfrom
dpa_wf5
Apr 21, 2026
Merged

client: don't fetch too much work for projects with zero resource share#7024
AenBleidd merged 2 commits into
masterfrom
dpa_wf5

Conversation

@davidpanderson

@davidpanderson davidpanderson commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

If there's an idle instance, and the project is not at a max concurrent limit, request 1 instance and 1 second

Fixes #7010


Summary by cubic

Reduce work fetch for backup projects (resource_share = 0): set req_instances and req_secs to 0, then request only 1 instance for 1 second when there’s an idle instance, skipping fetch if at the project’s max concurrent limit. Prevents over-fetching and avoids stale request values.

Written for commit ee2405a. Summary will update on new commits.

If there's an idle instance, and the project is not at a max concurrent limit,
request 1 instance and 1 second
Copilot AI review requested due to automatic review settings April 21, 2026 02:59

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 1 file

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adjusts client work-fetch behavior for projects with resource_share == 0 to avoid over-requesting work, and to respect per-project max-concurrent limits.

Changes:

  • Request only 1 instance / 1 second of work (instead of per-idle-instance) when a zero-resource-share project has idle capacity.
  • Skip requesting work entirely when the project is already at its max concurrent limit.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread client/work_fetch.cpp
Comment on lines +257 to 268
if (nidle_now) {
// unless we're at the max concurrent limit
if (p->app_configs.project_has_mc
&& p->app_configs.project_max_concurrent
&& p->proj_n_concurrent >= p->app_configs.project_max_concurrent
) {
return;
}
req_instances = 1;
req_secs = 1;
}
return;

Copilot AI Apr 21, 2026

Copy link

Choose a reason for hiding this comment

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

In the resource_share == 0 branch, set_request() now returns without setting req_instances/req_secs when nidle_now == 0, and also returns early (line 263) when at max concurrent. If these request fields are not re-initialized earlier in set_request(), this can leave stale values from a previous call and cause an unintended request. Consider explicitly setting req_instances (and any related request duration fields) to 0 before returning in these paths.

Copilot uses AI. Check for mistakes.
Comment thread client/work_fetch.cpp
@@ -254,8 +254,17 @@ void RSC_WORK_FETCH::set_request(PROJECT* p) {
// if backup project, fetch 1 job per idle instance

Copilot AI Apr 21, 2026

Copy link

Choose a reason for hiding this comment

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

The comment says 'fetch 1 job per idle instance', but the new behavior requests at most 1 instance total (when any idle instance exists), and otherwise requests nothing. Update the comment to match the new logic to avoid misleading future changes.

Suggested change
// if backup project, fetch 1 job per idle instance
// if backup project and any instance is idle, fetch at most 1 job

Copilot uses AI. Check for mistakes.
@AenBleidd AenBleidd added this to the Client/Manager 8.2.12 milestone Apr 21, 2026
@AenBleidd AenBleidd merged commit 4b56d97 into master Apr 21, 2026
467 checks passed
@AenBleidd AenBleidd deleted the dpa_wf5 branch April 21, 2026 16:09
@github-project-automation github-project-automation Bot moved this from In progress to Merged in Client/Manager Apr 21, 2026
@davidpanderson davidpanderson restored the dpa_wf5 branch April 24, 2026 00:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Merged

Development

Successfully merging this pull request may close these issues.

Interaction between Resource Share 0 and max_concurrent

3 participants