Skip to content

Conversation

@Vogtinator
Copy link
Member

@Vogtinator Vogtinator commented Oct 31, 2025

I found that openqa-schedule was pretty much always at 100% CPU use on my workstation, which could only be worked around by a restart of the scheduler. I finally had a look and this fixes it.

If a wakeup happens while there are no jobs to be scheduled, it did not emit concluded and the timer for scheduling is left at 0ms, which causes high CPU and DB use by the scheduler. Move the call to emit concluded to the right place to ensure it's called in that case as well.

"Scheduling: Free workers: $free_worker_count/$worker_count; Scheduled jobs: " . scalar(keys %$scheduled_jobs));

my ($allocated_workers, $allocated_jobs) = $self->_allocate_jobs($free_workers);
return [] unless keys %$allocated_workers;
Copy link
Member Author

Choose a reason for hiding this comment

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

OTOH, might also be possible to just delete this line altogether? That turns the loop below into a noop

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, you can also just remove this line entirely (and also not add an additional emit('conclude') relying on the one at the end of the function). That would probably be the best solution.

Copy link
Member Author

Choose a reason for hiding this comment

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

I just removed all early exits.

@codecov
Copy link

codecov bot commented Oct 31, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.26%. Comparing base (d63698b) to head (bef46f5).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6826      +/-   ##
==========================================
- Coverage   99.26%   99.26%   -0.01%     
==========================================
  Files         402      402              
  Lines       41400    41395       -5     
==========================================
- Hits        41094    41089       -5     
  Misses        306      306              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

my $limit = OpenQA::App->singleton->config->{scheduler}->{max_running_jobs};
if ($limit >= 0 && $running >= $limit) {
log_debug("max_running_jobs ($limit) exceeded, scheduling no additional jobs");
$self->emit('conclude');
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't we still need it here? This condition has an early return and I suppose the same counts here as for other early returns.

Copy link
Member Author

@Vogtinator Vogtinator Oct 31, 2025

Choose a reason for hiding this comment

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

No, the call at the end of schedule is reached in that case.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, right. This is a whole different function.

"Scheduling: Free workers: $free_worker_count/$worker_count; Scheduled jobs: " . scalar(keys %$scheduled_jobs));

my ($allocated_workers, $allocated_jobs) = $self->_allocate_jobs($free_workers);
return [] unless keys %$allocated_workers;
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, you can also just remove this line entirely (and also not add an additional emit('conclude') relying on the one at the end of the function). That would probably be the best solution.

If a wakeup happens while there are no jobs to be scheduled, it did not
emit concluded and the timer for scheduling is left at 0ms, which causes
high CPU and DB use by the scheduler.

Just remove all early exits, which just increased the complexity of the
method without much benefit.
my $limit = OpenQA::App->singleton->config->{scheduler}->{max_running_jobs};
if ($limit >= 0 && $running >= $limit) {
log_debug("max_running_jobs ($limit) exceeded, scheduling no additional jobs");
$self->emit('conclude');
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, right. This is a whole different function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants