Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor methods which violate the deeply nested loops #5450

Merged
merged 1 commit into from Feb 6, 2024

Conversation

b10n1k
Copy link
Contributor

@b10n1k b10n1k commented Feb 2, 2024

Simply extract parts of the subroutines which causes perlcritic to complain about deeply nested loops.
https://progress.opensuse.org/issues/138416

lib/OpenQA/Scheduler/Model/Jobs.pm Outdated Show resolved Hide resolved
lib/OpenQA/Schema/Result/JobGroups.pm Outdated Show resolved Hide resolved
lib/OpenQA/Schema/Result/JobGroups.pm Outdated Show resolved Hide resolved
@b10n1k b10n1k force-pushed the perlcritic_deeply_nested branch 2 times, most recently from 19d26cd to 8ccc0bc Compare February 5, 2024 12:05
lib/OpenQA/Schema/Result/JobGroups.pm Outdated Show resolved Hide resolved
lib/OpenQA/Schema/Result/JobGroups.pm Outdated Show resolved Hide resolved
lib/OpenQA/Schema/Result/JobGroups.pm Outdated Show resolved Hide resolved
lib/OpenQA/Schema/Result/JobGroups.pm Outdated Show resolved Hide resolved
lib/OpenQA/Schema/Result/JobGroups.pm Outdated Show resolved Hide resolved
lib/OpenQA/Schema/ResultSet/Jobs.pm Outdated Show resolved Hide resolved
lib/OpenQA/Schema/ResultSet/Jobs.pm Outdated Show resolved Hide resolved
lib/OpenQA/Schema/ResultSet/Jobs.pm Outdated Show resolved Hide resolved
lib/OpenQA/Schema/ResultSet/Jobs.pm Outdated Show resolved Hide resolved
@b10n1k b10n1k force-pushed the perlcritic_deeply_nested branch 2 times, most recently from 545957e to b767891 Compare February 5, 2024 13:49
Comment on lines 102 to 105
for my $worker (keys %taken) {
my $ji = $taken{$worker};
if ($prio > 0) {
# this means we will by default increase the offset per half-assigned job,
# so if we miss 1/25 jobs, we'll bump by +24
log_debug "Discarding job $ji->{id} (with priority $prio) due to incomplete parallel cluster"
. ', reducing priority by '
. STARVATION_PROTECTION_PRIORITY_OFFSET;
$j->{priority_offset} += STARVATION_PROTECTION_PRIORITY_OFFSET;
}
else {
# don't "take" the worker, but make sure it's not
# used for another job and stays around
log_debug "Holding worker $worker for job $ji->{id} to avoid starvation";
$allocated_workers->{$worker} = $ji->{id};
}

_allocate_worker_with_priority($prio, $ji, $j, $allocated_workers, $worker);
}
Copy link
Member

Choose a reason for hiding this comment

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

Now maybe we can go one step further

_allocate_worker_with_priority($prio, $taken{$_}, $j, $allocated_workers, $_) for keys %taken;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no sure. I see $ji in use below in the code

lib/OpenQA/Schema/ResultSet/Jobs.pm Show resolved Hide resolved
@perlpunk
Copy link
Contributor

perlpunk commented Feb 6, 2024

It would be useful to introduce changes step by step and rerun the failing test, to see which change is the culprit.

@b10n1k b10n1k force-pushed the perlcritic_deeply_nested branch 2 times, most recently from e9210ed to 800d73b Compare February 6, 2024 10:16
@okurz
Copy link
Member

okurz commented Feb 6, 2024

still failed tidy. Please tidy and consider to mark your PR as ready for review

Simply extract parts of the subroutines which causes perlcritic to complain
about deeply nested loops.

https://progress.opensuse.org/issues/138416

Signed-off-by: ybonatakis <ybonatakis@suse.com>
@b10n1k b10n1k marked this pull request as ready for review February 6, 2024 11:10
Copy link

codecov bot commented Feb 6, 2024

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (0d50a81) 98.37% compared to head (de41fba) 98.37%.

Files Patch % Lines
lib/OpenQA/Schema/Result/JobGroups.pm 98.18% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5450   +/-   ##
=======================================
  Coverage   98.37%   98.37%           
=======================================
  Files         389      389           
  Lines       37751    37769   +18     
=======================================
+ Hits        37139    37157   +18     
  Misses        612      612           

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

@okurz okurz merged commit dfb33b1 into os-autoinst:master Feb 6, 2024
40 of 41 checks passed
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.

None yet

4 participants