From: Fabian Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH manager 1/3] pvescheduler: simplify code for sleep time calculation
Date: Thu, 11 Nov 2021 16:17:43 +0100 [thread overview]
Message-ID: <20211111151745.130818-2-f.ebner@proxmox.com> (raw)
In-Reply-To: <20211111151745.130818-1-f.ebner@proxmox.com>
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
PVE/Service/pvescheduler.pm | 22 ++++------------------
1 file changed, 4 insertions(+), 18 deletions(-)
diff --git a/PVE/Service/pvescheduler.pm b/PVE/Service/pvescheduler.pm
index a8d548fb..86891827 100755
--- a/PVE/Service/pvescheduler.pm
+++ b/PVE/Service/pvescheduler.pm
@@ -25,20 +25,6 @@ my $finish_jobs = sub {
}
};
-my $get_sleep_time = sub {
- my ($calculate_offset) = @_;
- my $time = 60;
-
- if ($calculate_offset) {
- # try to run near minute boundaries, makes more sense to the user as he
- # configures jobs with minute precision
- my ($current_seconds) = localtime;
- $time = (60 - $current_seconds) if (60 - $current_seconds >= 5);
- }
-
- return $time;
-};
-
sub run {
my ($self) = @_;
@@ -84,12 +70,12 @@ sub run {
$run_jobs->();
- my $sleep_time;
+ my $sleep_time = 60;
if ($count >= 1000) {
- $sleep_time = $get_sleep_time->(1);
+ # Job schedule has minute precision, so try running near the minute boundary.
+ my ($current_seconds) = localtime;
+ $sleep_time = (60 - $current_seconds) if (60 - $current_seconds >= 5);
$count = 0;
- } else {
- $sleep_time = $get_sleep_time->(0);
}
my $slept = 0; # SIGCHLD interrupts sleep, so we need to keep track
--
2.30.2
next prev parent reply other threads:[~2021-11-11 15:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-11 15:17 [pve-devel] [PATCH-SERIES manager] small cleanups for scheduler/jobs Fabian Ebner
2021-11-11 15:17 ` Fabian Ebner [this message]
2021-11-11 15:17 ` [pve-devel] [PATCH manager 2/3] jobs: started_job: rename variable to $msg Fabian Ebner
2021-11-11 15:17 ` [pve-devel] [PATCH manager 3/3] jobs: rename function to better distinguish job state and task status Fabian Ebner
2021-11-11 20:06 ` [pve-devel] applied-series: [PATCH-SERIES manager] small cleanups for scheduler/jobs Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211111151745.130818-2-f.ebner@proxmox.com \
--to=f.ebner@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox