All of lore.kernel.org
 help / color / mirror / Atom feed
* [OSSTEST PATCH v2 00/29] Planner: Performance improvement
@ 2015-09-07 16:07 Ian Jackson
  2015-09-07 16:07 ` [OSSTEST PATCH 01/29] Tcl: Use lshift instead of open-coding with lrange Ian Jackson
                   ` (28 more replies)
  0 siblings, 29 replies; 32+ messages in thread
From: Ian Jackson @ 2015-09-07 16:07 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Campbell

This series addresses a performance problem which we seem to be
experiencing with the existing osstest resource planner in Xen Project
test colo.  The current setup can leave hosts idle for too long before
getting around to allocating them to test jobs.

There are also some reporting/debugging improvements.

The full explanation of the new algorithm is in the commit message for
  14/29 Planner: ms-queuedaemon: Restart planning when resources become free

Most of this series touches code in the central queue daemon, or in
command line tools, and is not subject to the osstest self-push-gate.

I have extensively tested this series in the Cambridge instance, where
this version of ms-queuedaemon is currently running and seems to be
happy.  The queuedaemon changes and the client (per-flight) changes
are fully compatible in both directions (except for Ian C's
out-of-mainline reporting tool which calls `get-plan' and is already
rather broken).

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [OSSTEST PATCH 01/29] Tcl: Use lshift instead of open-coding with lrange
  2015-09-07 16:07 [OSSTEST PATCH v2 00/29] Planner: Performance improvement Ian Jackson
@ 2015-09-07 16:07 ` Ian Jackson
  2015-09-07 16:08 ` [OSSTEST PATCH 02/29] Planner: docs: Minor fixes Ian Jackson
                   ` (27 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Ian Jackson @ 2015-09-07 16:07 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Campbell

In ms-queuedaemon, and JobDB-Executive, once each.  No functional
change.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
 ms-queuedaemon          |    3 +--
 tcl/JobDB-Executive.tcl |    3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/ms-queuedaemon b/ms-queuedaemon
index e15bc79..d6d59ee 100755
--- a/ms-queuedaemon
+++ b/ms-queuedaemon
@@ -210,8 +210,7 @@ proc queuerun-perhaps-step {} {
         return
     }
 
-    set thinking [lindex $queue_running 0]
-    set queue_running [lrange $queue_running 1 end]
+    set thinking [lshift queue_running]
     log-event "queuerun-perhaps-step selected"
 
     set thinking_after [after [expr {$c(QueueThoughtsTimeout) * 1000}] \
diff --git a/tcl/JobDB-Executive.tcl b/tcl/JobDB-Executive.tcl
index 7228712..d61d2a2 100644
--- a/tcl/JobDB-Executive.tcl
+++ b/tcl/JobDB-Executive.tcl
@@ -74,8 +74,7 @@ proc set-flight {} {
         set argv [lrange $argv 2 end]
     }
 
-    set flight [lindex $argv 0]
-    set argv [lrange $argv 1 end]
+    set flight [lshift argv]
     set env(OSSTEST_FLIGHT) $flight
 }
 
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [OSSTEST PATCH 02/29] Planner: docs: Minor fixes
  2015-09-07 16:07 [OSSTEST PATCH v2 00/29] Planner: Performance improvement Ian Jackson
  2015-09-07 16:07 ` [OSSTEST PATCH 01/29] Tcl: Use lshift instead of open-coding with lrange Ian Jackson
@ 2015-09-07 16:08 ` Ian Jackson
  2015-09-07 16:08 ` [OSSTEST PATCH 03/29] Planner: docs: Document set-info command Ian Jackson
                   ` (26 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Ian Jackson @ 2015-09-07 16:08 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Campbell

 * Document the ms-queuedaemon banner
 * Document the argument to the allocation $resourcecall callback fn.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
 Osstest/Executive.pm |    2 +-
 README.planner       |    3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/Osstest/Executive.pm b/Osstest/Executive.pm
index bf968c8..ab015d2 100644
--- a/Osstest/Executive.pm
+++ b/Osstest/Executive.pm
@@ -604,7 +604,7 @@ sub plan_search ($$$$) {
 }
 
 sub alloc_resources {
-    my ($resourcecall) = pop @_;
+    my ($resourcecall) = pop @_; # $resourcecall->($plan);
     my (%xparams) = @_;
     # $resourcecall should die (abort) or return ($ok, $bookinglist)
     #
diff --git a/README.planner b/README.planner
index 73e97ea..4cf682d 100644
--- a/README.planner
+++ b/README.planner
@@ -181,6 +181,9 @@ DETAILED PROTOCOL NOTES
 
 ms-queuedaemon commands
 
+        < OK ms-queuedaemon [INFO...]
+                Banner on connection.  INFO should be ignored.
+
 	> wait
 		I want to join the plan
 
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [OSSTEST PATCH 03/29] Planner: docs: Document set-info command
  2015-09-07 16:07 [OSSTEST PATCH v2 00/29] Planner: Performance improvement Ian Jackson
  2015-09-07 16:07 ` [OSSTEST PATCH 01/29] Tcl: Use lshift instead of open-coding with lrange Ian Jackson
  2015-09-07 16:08 ` [OSSTEST PATCH 02/29] Planner: docs: Minor fixes Ian Jackson
@ 2015-09-07 16:08 ` Ian Jackson
  2015-09-07 16:08 ` [OSSTEST PATCH 04/29] Planner: Fix indefinite holdoff Ian Jackson
                   ` (25 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Ian Jackson @ 2015-09-07 16:08 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Campbell

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
 README.planner |   10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/README.planner b/README.planner
index 4cf682d..ef2acba 100644
--- a/README.planner
+++ b/README.planner
@@ -184,6 +184,16 @@ ms-queuedaemon commands
         < OK ms-queuedaemon [INFO...]
                 Banner on connection.  INFO should be ignored.
 
+        > set-info KEY VALUE
+                There are various informational keys which are used by
+                the planner, provided by clients.  Keys include:
+
+        > set-info preinfo ...                   } used for reporting
+        > set-info job ...                       }
+        > set-info priority ...                      } used for
+        > set-info sub-priority ...                  } queue adjustment
+        > set-info wait-start-adjust ...             }
+
 	> wait
 		I want to join the plan
 
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [OSSTEST PATCH 04/29] Planner: Fix indefinite holdoff
  2015-09-07 16:07 [OSSTEST PATCH v2 00/29] Planner: Performance improvement Ian Jackson
                   ` (2 preceding siblings ...)
  2015-09-07 16:08 ` [OSSTEST PATCH 03/29] Planner: docs: Document set-info command Ian Jackson
@ 2015-09-07 16:08 ` Ian Jackson
  2015-09-07 16:08 ` [OSSTEST PATCH 05/29] Planner: client side: $mayalloc parameter to $resourcecall->() Ian Jackson
                   ` (24 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Ian Jackson @ 2015-09-07 16:08 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Campbell

runneeded-ensure-will would always reset the runneeded_holdoff_after
timer.  So no new queue run would start until no runneeded-ensure-will
has occurred for (currently) 30s.

Instead, only start the timer if it's not already running.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
 ms-queuedaemon |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/ms-queuedaemon b/ms-queuedaemon
index d6d59ee..1aa526c 100755
--- a/ms-queuedaemon
+++ b/ms-queuedaemon
@@ -86,10 +86,12 @@ proc runneeded-ensure-will {need} {
     log-event "runneeded-ensure-will $need (was $need_queue_run)"
 
     if {$need > $need_queue_run} { set need_queue_run $need }
-    catch { after cancel $runneeded_holdoff_after }
-    set runneeded_holdoff_after \
-        [after [expr {$c(QueueDaemonHoldoff) * 1000}] \
-             runneeded-perhaps-start]
+
+    if {![info exists runneeded_holdoff_after]} {
+	set runneeded_holdoff_after \
+	    [after [expr {$c(QueueDaemonHoldoff) * 1000}] \
+		 runneeded-perhaps-start]
+    }
 }
 
 proc runneeded-perhaps-start {} {
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [OSSTEST PATCH 05/29] Planner: client side: $mayalloc parameter to $resourcecall->()
  2015-09-07 16:07 [OSSTEST PATCH v2 00/29] Planner: Performance improvement Ian Jackson
                   ` (3 preceding siblings ...)
  2015-09-07 16:08 ` [OSSTEST PATCH 04/29] Planner: Fix indefinite holdoff Ian Jackson
@ 2015-09-07 16:08 ` Ian Jackson
  2015-09-07 16:08 ` [OSSTEST PATCH 06/29] Planner: client side: New `!OK think noalloc' protocol Ian Jackson
                   ` (23 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Ian Jackson @ 2015-09-07 16:08 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Campbell

Add a new parameter to $resourcecall which allows the alloc_resources
loop in Osstest::Executive to specify to its clients that on this
occasion they should not make any actual allocations.

The callers of alloc_resources are all adjusted to honour this new
parameter:
 * ts-hosts-allocate-Executive avoids allocating unless $mayalloc
 * mg-allocate avoids allocating unless $mayalloc
 * mg-blockage never allocates anyway.

Currently we always pass 1, so no functional change.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
 Osstest/Executive.pm        |    4 ++--
 mg-allocate                 |    4 ++--
 mg-blockage                 |    2 +-
 ts-hosts-allocate-Executive |    4 ++--
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/Osstest/Executive.pm b/Osstest/Executive.pm
index ab015d2..f9be0a0 100644
--- a/Osstest/Executive.pm
+++ b/Osstest/Executive.pm
@@ -604,7 +604,7 @@ sub plan_search ($$$$) {
 }
 
 sub alloc_resources {
-    my ($resourcecall) = pop @_; # $resourcecall->($plan);
+    my ($resourcecall) = pop @_; # $resourcecall->($plan, $mayalloc);
     my (%xparams) = @_;
     # $resourcecall should die (abort) or return ($ok, $bookinglist)
     #
@@ -720,7 +720,7 @@ sub alloc_resources {
 		$plan= from_json($jplan);
 	    }, sub {
 		if (!eval {
-		    ($ok, $bookinglist) = $resourcecall->($plan);
+		    ($ok, $bookinglist) = $resourcecall->($plan, 1);
 		    1;
 		}) {
 		    warn "resourcecall $@";
diff --git a/mg-allocate b/mg-allocate
index fc1b394..6dc7ddd 100755
--- a/mg-allocate
+++ b/mg-allocate
@@ -270,7 +270,7 @@ sub showposs ($) {
 sub plan () {
     my @got;
     alloc_resources(sub {
-        my ($plan) = @_;
+        my ($plan, $mayalloc) = @_;
 
 	@got = ();
         my @possmatrix = ([]);
@@ -310,7 +310,7 @@ sub plan () {
 	die unless $planned;
 
         my $allok=0;
-        if (!$planned->{Start}) {
+        if ($mayalloc && !$planned->{Start}) {
             $allok=1;
 
             alloc_prep();
diff --git a/mg-blockage b/mg-blockage
index a21f15b..1f66d8e 100755
--- a/mg-blockage
+++ b/mg-blockage
@@ -40,7 +40,7 @@ sub max { (reverse sort @_)[0]; }
 
 sub plan () {
     alloc_resources(sub {
-	my ($plan) = @_;
+	my ($plan, $mayalloc) = @_;
 
 	my $now = time;
 	if ($now > $end) { return (1, { Bookings => [ ] }); }
diff --git a/ts-hosts-allocate-Executive b/ts-hosts-allocate-Executive
index 6583191..4c7c614 100755
--- a/ts-hosts-allocate-Executive
+++ b/ts-hosts-allocate-Executive
@@ -606,7 +606,7 @@ sub alloc_hosts () {
 }
 
 sub attempt_allocation {
-    ($plan) = @_;
+    ($plan, $mayalloc) = @_;
     undef $best;
 
     logm("allocating hosts: ".join(' ', map { $_->{Ident} } @hids));
@@ -632,7 +632,7 @@ sub attempt_allocation {
 
     my $retval=0;
 
-    if (!$best->{Start}) {
+    if ($mayalloc && !$best->{Start}) {
 	$retval= 1;
 	foreach my $hid (@hids) {
 	    my $got= actual_allocation($hid);
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [OSSTEST PATCH 06/29] Planner: client side: New `!OK think noalloc' protocol
  2015-09-07 16:07 [OSSTEST PATCH v2 00/29] Planner: Performance improvement Ian Jackson
                   ` (4 preceding siblings ...)
  2015-09-07 16:08 ` [OSSTEST PATCH 05/29] Planner: client side: $mayalloc parameter to $resourcecall->() Ian Jackson
@ 2015-09-07 16:08 ` Ian Jackson
  2015-09-07 16:08 ` [OSSTEST PATCH 07/29] Planner: client side: Do not force OSSTEST_RESOURCE_PRIORITY Ian Jackson
                   ` (22 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Ian Jackson @ 2015-09-07 16:08 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Campbell

Introduce a way for the queue daemon to tell its client that it must
not allocate anything in this planning iteration.

In the client:
 * Advertise the new feature via set-info.
 * Accept the `noalloc' part of `!OK think noalloc';
 * Print that in our log message;
 * Honour it by passing it to $resourcecall.

And document the new protocol.  However, there is no server-side yet,
so this does not yet introduce any overall change to the system.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
 Osstest/Executive.pm |    9 ++++++---
 README.planner       |    6 +++++-
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/Osstest/Executive.pm b/Osstest/Executive.pm
index f9be0a0..4f51d70 100644
--- a/Osstest/Executive.pm
+++ b/Osstest/Executive.pm
@@ -674,6 +674,7 @@ sub alloc_resources {
                 $set_info->('priority', $priority);
                 $set_info->('sub-priority',$ENV{OSSTEST_RESOURCE_SUBPRIORITY});
                 $set_info->('preinfo',     $ENV{OSSTEST_RESOURCE_PREINFO});
+		$set_info->('feature-noalloc', 1);
 
                 if (defined $waitstart) {
                     $set_info->('wait-start',$waitstart);
@@ -699,7 +700,9 @@ sub alloc_resources {
 
             logm("resource allocation: awaiting our slot...");
 
-            $_= <$qserv>;  defined && m/^\!OK think\s$/ or die "$_ ?";
+            $_= <$qserv>;
+	    defined && m/^\!OK think( noalloc)?\s$/ or die "$_ ?";
+	    my $noalloc = $1 // '';
 
             opendb_tests();
 
@@ -715,12 +718,12 @@ sub alloc_resources {
 		read($qserv, $jplan, $jplanlen) == $jplanlen or die $!;
 		my $jplanprint= $jplan;
 		chomp $jplanprint;
-		logm("resource allocation: obtained base plan.");
+		logm("resource allocation: obtained base plan$noalloc.");
 		$debugm->("base plan = ", $jplanprint);
 		$plan= from_json($jplan);
 	    }, sub {
 		if (!eval {
-		    ($ok, $bookinglist) = $resourcecall->($plan, 1);
+		    ($ok, $bookinglist) = $resourcecall->($plan, !$noalloc);
 		    1;
 		}) {
 		    warn "resourcecall $@";
diff --git a/README.planner b/README.planner
index ef2acba..52f757b 100644
--- a/README.planner
+++ b/README.planner
@@ -194,11 +194,15 @@ ms-queuedaemon commands
         > set-info sub-priority ...                  } queue adjustment
         > set-info wait-start-adjust ...             }
 
+        > set-info feature-noalloc 1
+	        The client understands `!OK think noalloc'.
+
 	> wait
 		I want to join the plan
 
-	< !OK think
+	< !OK think [noalloc]
 		Now is the time to add yourself to the plan
+                `noalloc' means client must not not actually allocate.
 
 		> get-plan
 		< OK get-plan BYTES
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [OSSTEST PATCH 07/29] Planner: client side: Do not force OSSTEST_RESOURCE_PRIORITY
  2015-09-07 16:07 [OSSTEST PATCH v2 00/29] Planner: Performance improvement Ian Jackson
                   ` (5 preceding siblings ...)
  2015-09-07 16:08 ` [OSSTEST PATCH 06/29] Planner: client side: New `!OK think noalloc' protocol Ian Jackson
@ 2015-09-07 16:08 ` Ian Jackson
  2015-09-08  9:45   ` Ian Campbell
  2015-09-07 16:08 ` [OSSTEST PATCH 08/29] Planner: ms-planner support -w option Ian Jackson
                   ` (21 subsequent siblings)
  28 siblings, 1 reply; 32+ messages in thread
From: Ian Jackson @ 2015-09-07 16:08 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Campbell

This makes it possible to run mg-allocate with a different priority
simply by setting OSSTEST_RESOURCE_PRIORITY in its environment.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
v2: New patch
---
 mg-allocate |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mg-allocate b/mg-allocate
index 6dc7ddd..14c9088 100755
--- a/mg-allocate
+++ b/mg-allocate
@@ -365,7 +365,7 @@ while (@ARGV && $ARGV[0] =~ m/^[-0-9]/) {
                              $2 eq 'm' ?    60 :
                                              1);
         } elsif (s/^\-U/-/) {
-            $ENV{OSSTEST_RESOURCE_PRIORITY}= -1000000;
+            $ENV{OSSTEST_RESOURCE_PRIORITY} //= -1000000;
         } else {
             die "bad option \`$_'";
         }
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [OSSTEST PATCH 08/29] Planner: ms-planner support -w option
  2015-09-07 16:07 [OSSTEST PATCH v2 00/29] Planner: Performance improvement Ian Jackson
                   ` (6 preceding siblings ...)
  2015-09-07 16:08 ` [OSSTEST PATCH 07/29] Planner: client side: Do not force OSSTEST_RESOURCE_PRIORITY Ian Jackson
@ 2015-09-07 16:08 ` Ian Jackson
  2015-09-07 16:08 ` [OSSTEST PATCH 09/29] Planner: ms-queuedaemon: Prep for multiple walkers Ian Jackson
                   ` (20 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Ian Jackson @ 2015-09-07 16:08 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Campbell

We are going to introduce multiple concurrent streams of planning
processing, called `walkers' in ms-queuedaemon.  The work-in-progress
plan is stored, server-side, during planning, in data-plan.pl.  But we
need to have more than one of these.

Update ms-planner and ms-planner-debug to honour a -w option, to
specify a replacement for the word `plan' in `data-plan.pl'.

No overall functional change, since nothing uses these options yet.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
 ms-planner       |    6 +++++-
 ms-planner-debug |   13 ++++++++++---
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/ms-planner b/ms-planner
index f38f05b..053f330 100755
--- a/ms-planner
+++ b/ms-planner
@@ -33,12 +33,16 @@ use Osstest::Executive;
 
 open DEBUG, ">/dev/null" or die $!;
 
+our $walker = 'plan';
+
 while (@ARGV and $ARGV[0] =~ m/^-/) {
     $_= shift @ARGV;
     last if m/^--$/;
     while (m/^-./) {
         if (s/^-D/-/) {
             open DEBUG, ">&STDERR" or die $!;
+        } elsif (s/^-w(.+)/-/) {
+	    $walker = $1;
         } else {
             die "$_ ?";
         }
@@ -49,7 +53,7 @@ csreadconfig();
 
 our ($plan);
 
-my $fn= "data-plan.pl";
+my $fn= "data-$walker.pl";
 
 sub allocations ($$) {
     my ($init, $each) = @_;
diff --git a/ms-planner-debug b/ms-planner-debug
index e277ca6..eac5675 100755
--- a/ms-planner-debug
+++ b/ms-planner-debug
@@ -25,7 +25,14 @@ use Osstest;
 
 csreadconfig();
 
-my $f= sprintf "data-plan-debug-%s.txt", time;
+my $walker = 'plan';
+
+if (@ARGV && $ARGV[0] =~ m/^-w(.+)$/) {
+    $walker = $1;
+    shift @ARGV;
+}
+
+my $f= sprintf "data-$walker-debug-%s.txt", time;
 
 printf "%s\n", $f;
 
@@ -42,9 +49,9 @@ foreach my $arg (@ARGV) {
     }
 }
 
-print "==========data-plan.pl==========\n";
+print "==========data-$walker.pl==========\n";
 
-system 'cat data-plan.pl 2>&1';
+system 'cat data-$walker.pl 2>&1';
 
 print "==========resources==========\n";
 
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [OSSTEST PATCH 09/29] Planner: ms-queuedaemon: Prep for multiple walkers
  2015-09-07 16:07 [OSSTEST PATCH v2 00/29] Planner: Performance improvement Ian Jackson
                   ` (7 preceding siblings ...)
  2015-09-07 16:08 ` [OSSTEST PATCH 08/29] Planner: ms-planner support -w option Ian Jackson
@ 2015-09-07 16:08 ` Ian Jackson
  2015-09-07 16:08 ` [OSSTEST PATCH 10/29] Planner: ms-queuedaemon: Synchronise thinking " Ian Jackson
                   ` (19 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Ian Jackson @ 2015-09-07 16:08 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Campbell

We are going to introduce multiple concurrent streams of planning
processing, called `walkers'.

Prepare the ground for this with some formulaic changes which will
otherwise greatly clutter substantive patches.

(A client will still only think for one walker at once, because that's
what the client protocol expects - and anything else would be far too
confusing.)

General:
 * Introduce the concept of a `walker' to ms-queuedaemon.
 * Provide a list of the walkers which might exist, `walkers'
 * Provide some helper procedures for iterating over these,
   and easily accessing their state.

Queue handling:
 * Add a new `w' argument to many procs: specifically, most of the
   procs in the section `machinery for running the queue'.
 * Log the walker ($w) at the start of all relevant log messages.
 * Pass the -w option to ms-planner and ms-planner-debug.
 * Add safety catches which will crash the ms-queuedaemon if it finds
   it is asking the same client to think for more than one walker.
 * we-are-thinking and check-we-are-thinking tell the caller what
   walker the client is thinking for.
 * In the resource-plan.html filename, replace `plan' with the walker
   filename.

Elsewhere:
 * Teach dequeue-chan to deal with all the walkers, including
   maybe the (one) walker for which the client is thinking.
 * Teach log-state to report on all the walkers.
 * In the runneeded logic, hardcode `plan' as the walker to use.

There is still actually only one walker.

No overall functional change, except to some log messages.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>

---
v2: Fix walker-globals to import the $w/$v from #0, ie the global scope
    Correct invocation of upvar in walker-globals
    Use walker-globals everywhere, not obsolete name walker-vars
    Do not pass w to do-book-resources (which does not want it
        because it uses uses chan-we-are-thinking)
---
 ms-queuedaemon |  189 +++++++++++++++++++++++++++++++++++---------------------
 1 file changed, 120 insertions(+), 69 deletions(-)

diff --git a/ms-queuedaemon b/ms-queuedaemon
index 1aa526c..6e1ba0e 100755
--- a/ms-queuedaemon
+++ b/ms-queuedaemon
@@ -21,6 +21,23 @@
 
 source ./tcl/daemonlib.tcl
 
+set walkers {plan}
+
+proc walker-globals {w} {
+    # introduces queue_running, thinking[_after] for the specific walker
+    foreach v {queue_running thinking thinking_after} {
+	uplevel 1 [list upvar #0 $w/$v $v]
+    }
+}
+
+proc foreach-walker {walkervar body} {
+    global walkers
+    upvar 1 $walkervar w
+    foreach w $walkers {
+	uplevel 1 walker-globals $w
+	uplevel 1 $body
+    }
+}
 
 proc chan-destroy-stuff {chan} {
     dequeue-chan $chan destroy
@@ -31,13 +48,20 @@ proc chan-destroy-stuff {chan} {
 proc dequeue-chan {chan why} {
     log-event "dequeue-chan $chan $why"
 
-    global queue queue_running thinking
+    global queue
     lremove queue $chan
 
-    if {[info exists queue_running]} { lremove queue_running $chan }
-    if {[info exists thinking] &&
-        ![string compare $thinking $chan]} {
-        queuerun-step-done $why
+    foreach-walker w {
+	if {[info exists queue_running]} { lremove queue_running $chan }
+    }
+
+    # Reentrancy: this next loop can only trigger once, because
+    # the queuerun-step-done won't ever start chan thinking again
+    foreach-walker w {
+	if {[info exists thinking] &&
+	    ![string compare $thinking $chan]} {
+	    queuerun-step-done $w $why
+	}
     }
 }
 
@@ -55,31 +79,35 @@ proc log-event {m} {
 }
 
 proc log-state {m} {
-    global need_queue_run queue queue_running thinking
+    global need_queue_run queue
 
     set lhs [format "N=%d Q=%d (%-11.11s) " \
                  $need_queue_run [llength $queue] $queue]
 
-    if {[info exists queue_running]} {
-        append lhs [format "R=%d " [llength $queue_running]]
-        if {[info exists thinking]} {
-            append lhs [format "T=%s " $thinking]
-        } else {
-            append lhs [format "        "]
-        }
-        append lhs [format "(%-11.11s) " $queue_running]
-    } else {
-        append lhs "                          "
+    foreach-walker w {
+	if {[info exists queue_running]} {
+	    append lhs [format "R=%d " [llength $queue_running]]
+	    if {[info exists thinking]} {
+		append lhs [format "T=%s " $thinking]
+	    } else {
+		append lhs [format "        "]
+	    }
+	    append lhs [format "(%-11.11s) " $queue_running]
+	} else {
+	    append lhs "                          "
+	}
     }
+
     log "$lhs | $m"
 }
 
 #---------- machinery for making sure we run the queue ----------
 #
 # variables:
-#   queue            chans that are waiting for resources
-#   queue_running    unset if not running, list of chans if running
-#   need_queue_run   0: not needed; 1: needed if more resources; 2: force
+#  $w/queue            chans that are waiting for resources
+#  $w/queue_running    unset if not running, list of chans if running
+#  need_queue_run      0: not needed; 1: needed if more resources; 2: force
+# the $w/ variables are generally upvar'd with walker-globals
 
 proc runneeded-ensure-will {need} {
     global runneeded_holdoff_after c need_queue_run
@@ -96,7 +124,8 @@ proc runneeded-ensure-will {need} {
 
 proc runneeded-perhaps-start {} {
     log-event runneeded-perhaps-start
-    global queue queue_running thinking need_queue_run inhibit
+    walker-globals plan
+    global queue need_queue_run inhibit
     global runneeded_holdoff_after
     unset runneeded_holdoff_after
 
@@ -108,8 +137,8 @@ proc runneeded-perhaps-start {} {
     set need_queue_run 0
 
     if {![llength $queue]} {
-        plan-reset
-        report-plan
+        plan-reset plan
+        report-plan plan
         return
     }
 
@@ -140,7 +169,7 @@ proc runneeded-perhaps-start {} {
     log "runneeded-perhaps-start starting cleaned=$cleaned"
 
     runneeded-2-requeue
-    queuerun-start
+    queuerun-start plan
 }
 
 proc runneeded-ensure-polling {} {
@@ -181,26 +210,29 @@ proc runneeded-2-requeue {} {
 #---------- machinery for running the queue ----------
 #
 # variables:
-#    queue             chans waiting, read when we start
-#    queue_running     chans not yet asked
-#    thinking          chan currently asking
-#    thinking_after    timeout
+#  queue                chans waiting, read when we start
+#  $w/queue_running     chans not yet asked
+#  $w/thinking          chan currently asking
+#  $w/thinking_after    timeout
+# all the $w/ are generally upvar'd by walker-globals
 
-proc plan-reset {} {
-    exec ./ms-planner reset < /dev/null
+proc plan-reset {w} {
+    exec ./ms-planner -w$w reset < /dev/null
 }
 
-proc queuerun-start {} {
-    log-event queuerun-start
-    global queue_running queue
-    plan-reset
+proc queuerun-start {w} {
+    global queue
+    walker-globals $w
+    log-event "$w queuerun-start"
+    plan-reset $w
     set queue_running $queue
-    after idle queuerun-perhaps-step
+    after idle queuerun-perhaps-step plan
 }
 
-proc queuerun-perhaps-step {} {
-    log-event queuerun-perhaps-step
-    global thinking queue_running thinking_after c
+proc queuerun-perhaps-step {w} {
+    log-event "$w queuerun-perhaps-step"
+    walker-globals $w
+    global c
 
     if {[info exists thinking]} return
     if {![info exists queue_running]} return
@@ -208,107 +240,126 @@ proc queuerun-perhaps-step {} {
     if {![llength $queue_running]} {
         unset queue_running
         runneeded-ensure-will 0
-        report-plan
+        report-plan $w
         return
     }
 
-    set thinking [lshift queue_running]
-    log-event "queuerun-perhaps-step selected"
+    set next [lindex $queue_running 0]
+    set already [we-are-thinking $next]
+    if {[llength $already]} {
+	error "next $next thinking $already but also want $w"
+    }
+
+    set thinking $next
+    lshift queue_running
+    log-event "$w queuerun-perhaps-step selected"
 
     set thinking_after [after [expr {$c(QueueThoughtsTimeout) * 1000}] \
-                            queue-thoughts-timedout]
+                            queue-thoughts-timedout $w]
     for-chan $thinking {
         puts-chan $thinking "!OK think"
     }
 }
 
-proc report-plan {} {
+proc report-plan {w} {
     global c
     if {[catch {
-        exec ./ms-planner show-html > "$c(WebspaceFile)/resource-plan.html"
+	set outputfile "$c(WebspaceFile)/resource-$w.html"
+	exec ./ms-planner -w$w show-html > $outputfile
     } emsg]} {
-        log "INTERNAL ERROR showing plan html: $emsg"
+        log "INTERNAL ERROR showing $w html: $emsg"
     } else {
-        log "report-plan OK"
+        log "$w report-plan OK"
     }
 }
 
 proc we-are-thinking {chan} {
-    global thinking
-    return [expr {[info exists thinking] && ![string compare $thinking $chan]}]
+    set ws {}
+    foreach-walker w {
+	if {[info exists thinking] && ![string compare $thinking $chan]} {
+	    lappend ws $w
+	}
+    }
+    if {[llength $ws] > 1} {
+	error "arrgh chan $chan thinking $ws !"
+    }
+    return [lindex $ws 0]
 }
 
 proc check-we-are-thinking {chan} {
-    if {![we-are-thinking $chan]} {
+    set w [we-are-thinking $chan]
+    if {![string length $w]} {
         puts-chan $chan "ERROR you are not thinking"
         return -code return
     }
+    return $w
 }
 
-proc queuerun-step-done {why} {
-    log-event "queuerun-step-done $why"
-    global queue_running thinking thinking_after
-    puts-chan-desc $thinking "queuerun-step-done $thinking $why"
+proc queuerun-step-done {w why} {
+    log-event "$w queuerun-step-done $why"
+    walker-globals $w
+    puts-chan-desc $thinking "$w queuerun-step-done $thinking $why"
     if {[info exists thinking_after]} {
         after cancel $thinking_after
         unset thinking_after
     }
     unset thinking
-    after idle queuerun-perhaps-step
+    after idle queuerun-perhaps-step $w
 }
 
-proc queue-thoughts-timedout {} {
-    log-event queue-thoughts-timedout
-    global thinking thinking_after
+proc queue-thoughts-timedout {w} {
+    log-event "$w queue-thoughts-timedout"
+    walker-globals $w
     set chan $thinking
     unset thinking_after
-    queuerun-step-done timeout
+    queuerun-step-done $w timeout
     for-chan $chan {
         puts-chan $chan "!ERROR timed out (too pensive)"
     }
 }
 
 proc cmd/thought-wait {chan desc} {
-    check-we-are-thinking $chan
-    queuerun-step-done thought-wait
+    set w [check-we-are-thinking $chan]
+    queuerun-step-done $w thought-wait
     puts-chan $chan "OK thought"
 }
 
 proc cmd/thought-done {chan desc} {
-    check-we-are-thinking $chan
-    queuerun-step-done thought-done
+    set w [check-we-are-thinking $chan]
+    queuerun-step-done $w thought-done
     dequeue-chan $chan thought-wait
     puts-chan $chan "OK thought"
 }
 
 proc cmd/get-plan {chan desc} {
     global plan
-    set plan [exec -keepnewline ./ms-planner get-plan < /dev/null]
+    set w [check-we-are-thinking $chan]
+    set plan [exec -keepnewline ./ms-planner -w$w get-plan < /dev/null]
     puts-chan-data $chan "OK get-plan" $plan
 }
 
 proc cmd/book-resources {chan desc bytes} {
-    check-we-are-thinking $chan
     read-chan-data $chan $bytes do-book-resources
 }
 proc do-book-resources {chan desc data} {
     global plan errorInfo
-    check-we-are-thinking $chan
+    set w [check-we-are-thinking $chan]
     set info [chan-get-info $chan {"$info(preinfo) "} ""]
     append info [chan-get-info $chan {"job $info(job)"} $desc]
     if {[catch {
-	exec ./ms-planner book-resources $info << $data
+	exec ./ms-planner -w$w book-resources $info << $data
     } emsg]} {
-	set f [exec ./ms-planner-debug $info $data $plan]
+	set f [exec ./ms-planner-debug -w$w $info $data $plan]
 	error "$f $emsg" $errorInfo
     }
     puts-chan $chan "OK book-resources"
 }
 
 proc cmd/unwait {chan desc} {
-    if {[we-are-thinking $chan]} {
-        queuerun-step-done unwait
-        set res cancel
+    set w [we-are-thinking $chan]
+    if {[string length $w]} {
+        queuerun-step-done $w unwait
+        set res "$w cancel"
     } else {
         set res noop
     }
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [OSSTEST PATCH 10/29] Planner: ms-queuedaemon: Synchronise thinking multiple walkers
  2015-09-07 16:07 [OSSTEST PATCH v2 00/29] Planner: Performance improvement Ian Jackson
                   ` (8 preceding siblings ...)
  2015-09-07 16:08 ` [OSSTEST PATCH 09/29] Planner: ms-queuedaemon: Prep for multiple walkers Ian Jackson
@ 2015-09-07 16:08 ` Ian Jackson
  2015-09-07 16:08 ` [OSSTEST PATCH 11/29] Planner: ms-queuedaemon: Break out queuerun-finished/<walker> Ian Jackson
                   ` (18 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Ian Jackson @ 2015-09-07 16:08 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Campbell

If multiple walkers want to ask the same chan, we want to serialise
them.  This is actually straightforward:  Firstly, we arrrange that
each walker finishing a thought will prompt _all_ walkers to
reconsider whether they need to continue.  Then we can simply do
nothing if we want to a chan to think that another walker is already
waiting for; since that other walker will prompt us later.

Still no actual functional change because there is still only one
walker.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
 ms-queuedaemon |   14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/ms-queuedaemon b/ms-queuedaemon
index 6e1ba0e..d51fd52 100755
--- a/ms-queuedaemon
+++ b/ms-queuedaemon
@@ -216,6 +216,12 @@ proc runneeded-2-requeue {} {
 #  $w/thinking_after    timeout
 # all the $w/ are generally upvar'd by walker-globals
 
+proc walkers-perhaps-queue-steps {} {
+    foreach-walker w {
+	after idle queuerun-perhaps-step $w
+    }
+}
+
 proc plan-reset {w} {
     exec ./ms-planner -w$w reset < /dev/null
 }
@@ -226,7 +232,7 @@ proc queuerun-start {w} {
     log-event "$w queuerun-start"
     plan-reset $w
     set queue_running $queue
-    after idle queuerun-perhaps-step plan
+    walkers-perhaps-queue-steps
 }
 
 proc queuerun-perhaps-step {w} {
@@ -247,7 +253,9 @@ proc queuerun-perhaps-step {w} {
     set next [lindex $queue_running 0]
     set already [we-are-thinking $next]
     if {[llength $already]} {
-	error "next $next thinking $already but also want $w"
+	# $already will wake us via walkers-perhaps-queue-steps
+	log-event "$w queuerun-perhaps-step already $already"
+	return
     }
 
     set thinking $next
@@ -304,7 +312,7 @@ proc queuerun-step-done {w why} {
         unset thinking_after
     }
     unset thinking
-    after idle queuerun-perhaps-step $w
+    walkers-perhaps-queue-steps
 }
 
 proc queue-thoughts-timedout {w} {
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [OSSTEST PATCH 11/29] Planner: ms-queuedaemon: Break out queuerun-finished/<walker>
  2015-09-07 16:07 [OSSTEST PATCH v2 00/29] Planner: Performance improvement Ian Jackson
                   ` (9 preceding siblings ...)
  2015-09-07 16:08 ` [OSSTEST PATCH 10/29] Planner: ms-queuedaemon: Synchronise thinking " Ian Jackson
@ 2015-09-07 16:08 ` Ian Jackson
  2015-09-07 16:08 ` [OSSTEST PATCH 12/29] Planner: ms-queuedaemon: Break out notify-to-think Ian Jackson
                   ` (17 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Ian Jackson @ 2015-09-07 16:08 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Campbell

This formalises the queue-completed interface, allowing parts outside
the queuerun machinery to cleanly be notified when a queue is
completed, and relieving the queuerun-perhaps-step of the need to know
what to do for the end of any particular walker's queue.

Currently there is still only one walker, `plan'.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
 ms-queuedaemon |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/ms-queuedaemon b/ms-queuedaemon
index d51fd52..3026a64 100755
--- a/ms-queuedaemon
+++ b/ms-queuedaemon
@@ -172,6 +172,11 @@ proc runneeded-perhaps-start {} {
     queuerun-start plan
 }
 
+proc queuerun-finished/plan {} {
+    runneeded-ensure-will 0
+    report-plan plan
+}
+
 proc runneeded-ensure-polling {} {
     log-event runneeded-ensure-polling
     global polling_after queue c
@@ -245,8 +250,7 @@ proc queuerun-perhaps-step {w} {
 
     if {![llength $queue_running]} {
         unset queue_running
-        runneeded-ensure-will 0
-        report-plan $w
+	queuerun-finished/$w
         return
     }
 
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [OSSTEST PATCH 12/29] Planner: ms-queuedaemon: Break out notify-to-think
  2015-09-07 16:07 [OSSTEST PATCH v2 00/29] Planner: Performance improvement Ian Jackson
                   ` (10 preceding siblings ...)
  2015-09-07 16:08 ` [OSSTEST PATCH 11/29] Planner: ms-queuedaemon: Break out queuerun-finished/<walker> Ian Jackson
@ 2015-09-07 16:08 ` Ian Jackson
  2015-09-07 16:08 ` [OSSTEST PATCH 13/29] Planner: ms-queuedaemon: Make report-plan take output walker name Ian Jackson
                   ` (16 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Ian Jackson @ 2015-09-07 16:08 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Campbell

This is going to want to do something more complicated shortly.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
v2: Fix a whitespace error
---
 ms-queuedaemon |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/ms-queuedaemon b/ms-queuedaemon
index 3026a64..1fe555d 100755
--- a/ms-queuedaemon
+++ b/ms-queuedaemon
@@ -268,9 +268,8 @@ proc queuerun-perhaps-step {w} {
 
     set thinking_after [after [expr {$c(QueueThoughtsTimeout) * 1000}] \
                             queue-thoughts-timedout $w]
-    for-chan $thinking {
-        puts-chan $thinking "!OK think"
-    }
+
+    notify-to-think $w $thinking
 }
 
 proc report-plan {w} {
@@ -379,6 +378,12 @@ proc cmd/unwait {chan desc} {
     puts-chan $chan "OK unwait $res"
 }
 
+proc notify-to-think {w thinking} {
+    for-chan $thinking {
+	puts-chan $thinking "!OK think"
+    }
+}
+
 #---------- general stuff ----------
 
 proc banner {chan} {
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [OSSTEST PATCH 13/29] Planner: ms-queuedaemon: Make report-plan take output walker name
  2015-09-07 16:07 [OSSTEST PATCH v2 00/29] Planner: Performance improvement Ian Jackson
                   ` (11 preceding siblings ...)
  2015-09-07 16:08 ` [OSSTEST PATCH 12/29] Planner: ms-queuedaemon: Break out notify-to-think Ian Jackson
@ 2015-09-07 16:08 ` Ian Jackson
  2015-09-07 16:08 ` [OSSTEST PATCH 14/29] Planner: ms-queuedaemon: Restart planning when resources become free Ian Jackson
                   ` (15 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Ian Jackson @ 2015-09-07 16:08 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Campbell

We are going to want to process each walker's data into reports which
are not necessarily named after the same walker.

No functional change as yet.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
 ms-queuedaemon |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/ms-queuedaemon b/ms-queuedaemon
index 1fe555d..811f0ee 100755
--- a/ms-queuedaemon
+++ b/ms-queuedaemon
@@ -138,7 +138,7 @@ proc runneeded-perhaps-start {} {
 
     if {![llength $queue]} {
         plan-reset plan
-        report-plan plan
+        report-plan plan plan
         return
     }
 
@@ -174,7 +174,7 @@ proc runneeded-perhaps-start {} {
 
 proc queuerun-finished/plan {} {
     runneeded-ensure-will 0
-    report-plan plan
+    report-plan plan plan
 }
 
 proc runneeded-ensure-polling {} {
@@ -272,10 +272,10 @@ proc queuerun-perhaps-step {w} {
     notify-to-think $w $thinking
 }
 
-proc report-plan {w} {
+proc report-plan {w wo} {
     global c
     if {[catch {
-	set outputfile "$c(WebspaceFile)/resource-$w.html"
+	set outputfile "$c(WebspaceFile)/resource-$wo.html"
 	exec ./ms-planner -w$w show-html > $outputfile
     } emsg]} {
         log "INTERNAL ERROR showing $w html: $emsg"
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [OSSTEST PATCH 14/29] Planner: ms-queuedaemon: Restart planning when resources become free
  2015-09-07 16:07 [OSSTEST PATCH v2 00/29] Planner: Performance improvement Ian Jackson
                   ` (12 preceding siblings ...)
  2015-09-07 16:08 ` [OSSTEST PATCH 13/29] Planner: ms-queuedaemon: Make report-plan take output walker name Ian Jackson
@ 2015-09-07 16:08 ` Ian Jackson
  2015-09-07 16:08 ` [OSSTEST PATCH 15/29] Plan reporting: Break out return-plan-to-client Ian Jackson
                   ` (14 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Ian Jackson @ 2015-09-07 16:08 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Campbell

This solves a performance problem with the existing planner.

The problem is that with a large installation, and a big queue, a full
plan can take a long time to prepare.  (In our current installation,
perhaps as long as half an hour.)  Any resource which becomes free
during one plan run cannot be allocated to a new job until the next
plan run starts.  This means resources (test machines) are often
sitting around idle.

Fix this by restarting the planning process as soon as any new
resource becomes free.  This means that jobs at the front of the queue
get a chance to allocate it right away, so it will probably be
allocated soon.

If it is only interesting to jobs later in the queue, then there may
be a delay in reallocating it, but presumably the resource is not much
in demand and those later jobs will allocate it when they get a bit
closer to the head.

But, there is a problem with this: it means that the plan is generally
never completed.  So we have no overview any more of when which
flights will finish and what the overall queue is like.  We solve this
problem by running a second instance of the planner algorithm, all the
way to completion, in a `dummy' mode where no actual resource
allocation takes place.  This second `projection' instance comes into
being whenever the main `plan' instance is restarted, and it inherits
the planning state from the main `plan' instance.

Global livelock (where we keep restarting the plan but never manage to
allocate anything) is not possible because each restart involves a new
resource becoming free.  If nothing gets allocated because we can't
get that far before being restarted, then eventually there will be
nothing left allocated to become newly free.

Starvation, of a form, is possible: a late-in-queue job which wants a
resource available right now might have difficulty allocating it
because the planner is spending its effort rescheduling early-in-queue
jobs which want resources which are in greater demand - so that the
late-in-queue job never gets called.  Arguably this is an appropriate
allocation of planning time.

With this arrangement we can generate two reports: a `plan' report
containing the short term plan which was used for actual resource
allocation, and which is frequently restarted and therefore not
necessarily complete; and a `projection' report which contains a
complete plan for all work the system is currently aware of, but which
is less-frequently updated.

Because planner clients do not contain the planning algorithm state,
the only client change needed is the ability to run in a `dummy' mode
without actual allocation; this is the `noalloc' feature earlier in
this series.

The main work is in ms-queuedaemon.  We have prepared the ground for
multiple instances of the planning algorithm; from the point of view
of ms-queuedaemon, an instance of the planning algorithm is mainly a
walk over the job queue.  So we call them `walkers'.

Therefore, what we do here is introduce a new `projection' walker,
as follows:

Add `projection' to the global list of possible walkers.

Invent a new section of code, the `restarter', which is responsible
for managing the relationship between the two walkers.  (It uses
direct knowledge of the queue state data structures, etc., to avoid
having to invent a complete formal interface to a walker.)

If we ever finish the plan walker's queue, we update both the
projection report output and the plan report output, from the same
plan.  Finishing the projection walker's queue means we have a
complete projection, but we don't touch the plan.

In principle it might happen that the plan walker might overtake the
projection walker, and then complete, write out a complete and up to
date plan as the projection, and that the projection walker would then
complete and overwrite the projection with less-up-to-date
information.  We don't explicitly exclude this.  Of course such a
result will be rectified soon enough by another planning run.

The restarter can ask the database for the list of currently-available
resources, and can therefore detect when new become newly-free.

The rest of the code remains largely ignorant of the operation of the
restarter.  There are a few hooks:

runneeded-perhaps-start notifies the restarter when we start the
plan; this is used by the restarter to record the set of free
resources at the start of a planning run, so that it can see later
whether any /new/ resources have become free.

restarter-maybe-provoke-restart is called when we get notification
from the the owner daemon that resources may have become idle.  We
look for newly-idle resources, and if there are any, and we are
running the plan walker, we directly edit the plan walker's queue to
put RESTART at the front.

queuerun-perhaps-step spots the special entry RESTART in its queue and
calls into back the restarter when it finds it.  This deferred
approach is necessary because we can't do the restart operation while
a client is thinking (because we would have to change that client's
cogitation from the `live, can allocate' mode to the `dummy, cannot
allocate' mode; and because that would make the code more complex).

The main work is done in the restarter-restart-now hook.  It reports
the current (incomplete) plan, and then checks to see if a projection
walker is running; if it is, it leaves it alone, and simply abandons
the current plan run and arranges for a new run to started.  If a
projection walker is not running it copies all the plan walker's state
(including the data-plan.pl disk file containing the plan-in-progress)
to the projection walker, and sets the projection walker going.

We update .gitignore to ignore data-plan.* and data-projection.*.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
v2: Update .gitignore too.
    Use `walker-globals' not `walker-runvars' (which does not exist).
    Remove wrap damage `#' from comment.
    Fix typo in commit message.
    Fix several silly bugs in for-free-resources
    Fix three silly bugs relating to handling of $newly_free
    Fix a wrong bracket syntax error in restarter-maybe-provoke-restart
    Properly return from queuerun-perhaps-step on RESTART;
        restarter-restart-now has taken the flow of control.
    Reorder operations in restarter-restart-now so as to make it work
    Correct some wrong log messages in restarter-restart-now
    Add a log message when we restart planning
    Minor code layout changes
    In notify-to-think, process feature-noalloc properly
---
 .gitignore     |    4 +--
 README.planner |    8 +++++
 ms-queuedaemon |  104 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 3 files changed, 112 insertions(+), 4 deletions(-)

diff --git a/.gitignore b/.gitignore
index 07b039d..bccf488 100644
--- a/.gitignore
+++ b/.gitignore
@@ -18,8 +18,8 @@ publish-lock
 bisecting-sticky-branch
 [tu].*
 [tu]
-data-plan.pl
-data-plan.pl.new
+data-plan.*
+data-projection.*
 data-plan-debug-*.txt
 data-tree-lock
 tree-bisect
diff --git a/README.planner b/README.planner
index 52f757b..b1bacd4 100644
--- a/README.planner
+++ b/README.planner
@@ -76,6 +76,14 @@ that newly-freed resources are properly offered first to the tasks at
 the front of the queue.  ms-ownerdaemon sets all idle resources to
 allocatable at the start of each planning cycle.
 
+The planner actually sometimes runs two planning cycles: if resources
+become free while the planner is running, it will restart the planning
+cycle in an effort to get those resources into service.  But, it will
+leave the existing planning run going in a projection-only mode (where
+no resources actually get allocated), so that there is a report for
+the administrator showing an idea of what the system thinks may happen
+in the more distant future.
+
 
 ms-ownerdaemon and `ownd' tasks
 -------------------------------
diff --git a/ms-queuedaemon b/ms-queuedaemon
index 811f0ee..d48715e 100755
--- a/ms-queuedaemon
+++ b/ms-queuedaemon
@@ -21,7 +21,7 @@
 
 source ./tcl/daemonlib.tcl
 
-set walkers {plan}
+set walkers {plan projection}
 
 proc walker-globals {w} {
     # introduces queue_running, thinking[_after] for the specific walker
@@ -169,12 +169,19 @@ proc runneeded-perhaps-start {} {
     log "runneeded-perhaps-start starting cleaned=$cleaned"
 
     runneeded-2-requeue
+    restarter-starting-plan-hook
     queuerun-start plan
 }
 
 proc queuerun-finished/plan {} {
     runneeded-ensure-will 0
     report-plan plan plan
+    report-plan plan projection
+}
+
+proc queuerun-finished/projection {} {
+    runneeded-ensure-will 0
+    report-plan projection projection
 }
 
 proc runneeded-ensure-polling {} {
@@ -255,6 +262,12 @@ proc queuerun-perhaps-step {w} {
     }
 
     set next [lindex $queue_running 0]
+    if {![string compare RESTART $next]} {
+	lshift queue_running
+	restarter-restart-now
+	return
+    }
+
     set already [we-are-thinking $next]
     if {[llength $already]} {
 	# $already will wake us via walkers-perhaps-queue-steps
@@ -378,9 +391,95 @@ proc cmd/unwait {chan desc} {
     puts-chan $chan "OK unwait $res"
 }
 
+#---------- special magic for restarting the plan ----------
+
+proc for-free-resources {varname body} {
+    jobdb::transaction resources {
+	pg_execute -array free_resources_row dbh {
+		SELECT (restype || '/' || resname || '/' || shareix) AS r
+		  FROM resources
+	     WHERE NOT (SELECT live FROM tasks WHERE taskid=owntaskid)
+	      ORDER BY restype, resname
+	} {
+	    uplevel 1 [list set $varname $free_resources_row(r)]
+	    uplevel 1 $body
+	}
+    }
+}
+
+proc restarter-starting-plan-hook {} {
+    global wasfree
+    catch { unset wasfree }
+    for-free-resources freeres {
+	set wasfree($freeres) 1
+    }
+}
+
+proc restarter-maybe-provoke-restart {} {
+    set newly_free {}
+    global wasfree
+    for-free-resources freeres {
+	if {[info exists wasfree($freeres)]} continue
+	lappend newly_free $freeres
+	set wasfree($freeres) 1
+    }
+    if {![llength $newly_free]} {
+	log-event "restarter-maybe-provoke-restart nothing"
+	return
+    }
+ 
+    walker-globals plan
+
+    if {!([info exists queue_running] && [llength $queue_running])} {
+	log-event "restarter-maybe-provoke-restart not-running ($newly_free)"
+	return
+    }
+    
+    log-event "restarter-maybe-provoke-restart provoked ($newly_free)"
+
+    if {[string compare RESTART [lindex $queue_running 0]]} {
+	set queue_running [concat RESTART $queue_running]
+    }
+    after idle queuerun-perhaps-step plan
+}
+
+proc restarter-restart-now {} {
+    # We restart the `plan' walker.  Well, actually, if the
+    # `projection' walker is not running, we transfer the `plan'
+    # walker to it.  At this stage the plan walker is not thinking so
+    # there are no outstanding callbacks to worry about.
+
+    log-event restarter-restart-now
+
+    global projection/queue_running
+    global plan/queue_running
+
+    if {![info exists projection/queue_running]} {
+	log-event "restarter-restart-now projection-idle continue-as"
+	set projection/queue_running [set plan/queue_running]
+	file copy -force data-plan.pl data-projection.pl
+	after idle queuerun-perhaps-step projection
+    } else {
+	log-event "restarter-restart-now projection-running"
+    }
+
+    report-plan plan plan
+
+    unset plan/queue_running
+    runneeded-ensure-will 2
+}
+
 proc notify-to-think {w thinking} {
     for-chan $thinking {
-	puts-chan $thinking "!OK think"
+	set noalloc [chan-get-info $thinking {$info(feature-noalloc)} {}]
+	switch -glob $w.$noalloc {
+	    plan.* { puts-chan $thinking "!OK think" }
+	    projection.1 { puts-chan $thinking "!OK think noalloc" }
+	    projection.* {
+		# oh well, can't include it in the projection; too bad
+		queuerun-step-done $w "!feature-noalloc"
+	    }
+	}
     }
 }
 
@@ -519,6 +618,7 @@ proc await-endings-notified {} {
             error "$owndchan eof"
         }
         runneeded-ensure-will 2
+        restarter-maybe-provoke-restart
     }
 }
 
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [OSSTEST PATCH 15/29] Plan reporting: Break out return-plan-to-client
  2015-09-07 16:07 [OSSTEST PATCH v2 00/29] Planner: Performance improvement Ian Jackson
                   ` (13 preceding siblings ...)
  2015-09-07 16:08 ` [OSSTEST PATCH 14/29] Planner: ms-queuedaemon: Restart planning when resources become free Ian Jackson
@ 2015-09-07 16:08 ` Ian Jackson
  2015-09-07 16:08 ` [OSSTEST PATCH 16/29] Plan reporting: Provide get-last-plan queuedaemon command Ian Jackson
                   ` (13 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Ian Jackson @ 2015-09-07 16:08 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Campbell

We are going to want to reuse this.  No functional change.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
 ms-queuedaemon |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/ms-queuedaemon b/ms-queuedaemon
index d48715e..8c9af81 100755
--- a/ms-queuedaemon
+++ b/ms-queuedaemon
@@ -355,11 +355,16 @@ proc cmd/thought-done {chan desc} {
     puts-chan $chan "OK thought"
 }
 
+proc return-plan-to-client {chan wf} {
+    set tplan [exec -keepnewline ./ms-planner -w$wf get-plan < /dev/null]
+    puts-chan-data $chan "OK get-plan" $tplan
+    return $tplan
+}
+
 proc cmd/get-plan {chan desc} {
     global plan
     set w [check-we-are-thinking $chan]
-    set plan [exec -keepnewline ./ms-planner -w$w get-plan < /dev/null]
-    puts-chan-data $chan "OK get-plan" $plan
+    set plan [return-plan-to-client $chan $w]
 }
 
 proc cmd/book-resources {chan desc bytes} {
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [OSSTEST PATCH 16/29] Plan reporting: Provide get-last-plan queuedaemon command
  2015-09-07 16:07 [OSSTEST PATCH v2 00/29] Planner: Performance improvement Ian Jackson
                   ` (14 preceding siblings ...)
  2015-09-07 16:08 ` [OSSTEST PATCH 15/29] Plan reporting: Break out return-plan-to-client Ian Jackson
@ 2015-09-07 16:08 ` Ian Jackson
  2015-09-07 16:08 ` [OSSTEST PATCH 17/29] Planner: ms-queuedaemon: Break out chan-plan-info Ian Jackson
                   ` (12 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Ian Jackson @ 2015-09-07 16:08 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Campbell

This allows retrieval, by monitoring clients which are not
participating in the planning queue, of the finished projection, or
the unfinished plan as it was at the time of last restart.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
v2: Fix invocation of return-plan-to-client.
    Use data-W.final.pl, not data-W-final.pl, to fit
        with existing .gitignore, and be slightly neater.
---
 README.planner |   11 +++++++++++
 ms-queuedaemon |    8 ++++++++
 2 files changed, 19 insertions(+)

diff --git a/README.planner b/README.planner
index b1bacd4..21b3415 100644
--- a/README.planner
+++ b/README.planner
@@ -224,6 +224,17 @@ ms-queuedaemon commands
 
 	> thought-done | thought-wait
 
+        > get-last-plan projection|plan
+                Retrieve the last fully completed plan (`projection'),
+		or the most recent short-term information used for
+		actual resource allocation (`plan').
+
+		For monitoring tools, not participants in the resource
+		allocation process.  Response is as for get-plan:
+
+		< OK get-plan BYTES
+		PLAN-DATA
+
 
 Plan is:
 	Start	time_t used for "now" *
diff --git a/ms-queuedaemon b/ms-queuedaemon
index 8c9af81..18d703e 100755
--- a/ms-queuedaemon
+++ b/ms-queuedaemon
@@ -293,6 +293,7 @@ proc report-plan {w wo} {
     } emsg]} {
         log "INTERNAL ERROR showing $w html: $emsg"
     } else {
+	file copy -force data-$w.pl data-$wo.final.pl
         log "$w report-plan OK"
     }
 }
@@ -367,6 +368,13 @@ proc cmd/get-plan {chan desc} {
     set plan [return-plan-to-client $chan $w]
 }
 
+proc cmd/get-last-plan {chan desc w} {
+    global walkers
+    if {[lsearch -exact $walkers $w] < 0} { error "unknown last-plan ($w)" }
+    if {![file exists data-$w.final.pl]} { error "no last-plan $w" }
+    return-plan-to-client $chan $w.final
+}
+
 proc cmd/book-resources {chan desc bytes} {
     read-chan-data $chan $bytes do-book-resources
 }
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [OSSTEST PATCH 17/29] Planner: ms-queuedaemon: Break out chan-plan-info
  2015-09-07 16:07 [OSSTEST PATCH v2 00/29] Planner: Performance improvement Ian Jackson
                   ` (15 preceding siblings ...)
  2015-09-07 16:08 ` [OSSTEST PATCH 16/29] Plan reporting: Provide get-last-plan queuedaemon command Ian Jackson
@ 2015-09-07 16:08 ` Ian Jackson
  2015-09-07 16:08 ` [OSSTEST PATCH 18/29] Planner: Report unprocessed planning clients Ian Jackson
                   ` (11 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Ian Jackson @ 2015-09-07 16:08 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Campbell

Also, refactor the space separator handling to use a list and `join'
(since we are going to maybe have desc be "").

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
v2: New patch
---
 ms-queuedaemon |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/ms-queuedaemon b/ms-queuedaemon
index 18d703e..72e22d0 100755
--- a/ms-queuedaemon
+++ b/ms-queuedaemon
@@ -375,14 +375,20 @@ proc cmd/get-last-plan {chan desc w} {
     return-plan-to-client $chan $w.final
 }
 
+proc chan-plan-info {chan desc} {
+    set l {}
+    lappend l [chan-get-info $chan {"$info(preinfo)"} ""]
+    lappend l [chan-get-info $chan {"job $info(job)"} $desc]
+    return [join $l " "]
+}
+
 proc cmd/book-resources {chan desc bytes} {
     read-chan-data $chan $bytes do-book-resources
 }
 proc do-book-resources {chan desc data} {
     global plan errorInfo
     set w [check-we-are-thinking $chan]
-    set info [chan-get-info $chan {"$info(preinfo) "} ""]
-    append info [chan-get-info $chan {"job $info(job)"} $desc]
+    set info [chan-plan-info $plan $desc]
     if {[catch {
 	exec ./ms-planner -w$w book-resources $info << $data
     } emsg]} {
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [OSSTEST PATCH 18/29] Planner: Report unprocessed planning clients
  2015-09-07 16:07 [OSSTEST PATCH v2 00/29] Planner: Performance improvement Ian Jackson
                   ` (16 preceding siblings ...)
  2015-09-07 16:08 ` [OSSTEST PATCH 17/29] Planner: ms-queuedaemon: Break out chan-plan-info Ian Jackson
@ 2015-09-07 16:08 ` Ian Jackson
  2015-09-07 16:08 ` [OSSTEST PATCH 19/29] Tcl: Provide get-chan-desc in daemonlib Ian Jackson
                   ` (10 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Ian Jackson @ 2015-09-07 16:08 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Campbell

With recent changes, it can happen that a queue daemon client is not
given an opportunity to report itself in the plan.  This makes the
plan incomplete.

(For resource-plan.html, because the planning run was restarted to try
to quickly allocate new resources; for resource-projection.html,
because it's an old client that doesn't support feature-noalloc.)

When this happens, provide an explicit indication of this in the plan:

* Invent a new entry Unprocessed in data-*.pl for this information.
* Display the first 50 in ms-planner show-html.
* Provide a new ms-planner invocation `unprocessed' to record one.
* Note unprocessed when we skip a client due to !feature-noalloc.
* Note unprocessed for remaining queue when we restart planning.

For now this algorithm can be rather unfortunately O(n^2) when
draining the planning queue, because each `ms-planner unprocessed'
invocation adds only one job but needs to read and write the whole
plan.   This will be fixed shortly.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
v2: New patch
---
 ms-planner     |   27 +++++++++++++++++++++++++++
 ms-queuedaemon |   10 ++++++++++
 2 files changed, 37 insertions(+)

diff --git a/ms-planner b/ms-planner
index 053f330..495c8ff 100755
--- a/ms-planner
+++ b/ms-planner
@@ -238,6 +238,7 @@ sub cmd_reset () {
 
     $plan->{Start}= time;
     $plan->{Events}= { };
+    $plan->{Unprocessed}= [ ];
 
     my %magictask;
     foreach my $taskrefkey (qw(preparing shared)) {
@@ -731,12 +732,38 @@ sub cmd_show_html () {
 	printf "</tr>\n";
     }
     printf "</table>\n";
+    printf "<p>\n";
+    my $unprocessed = $plan->{Unprocessed};
+    if (@$unprocessed) {
+	    printf "%d tasks not processed and therefore not shown:\n",
+	        scalar @$unprocessed;
+	    my $shown = 0;
+	    printf "<ul>\n";
+	    foreach my $unprocessed (@$unprocessed) {
+		if (++$shown > 50) {
+		    printf "<li>...</li>\n";
+		    last;
+		}
+		printf "<li>%s</li>\n", encode_entities($unprocessed->{Info});
+	    }
+	    printf "</ul>\n";
+	    printf "<p>\n";
+    }
     printf "Report generated %s.\n",
         strftime("%Y-%b-%d %a %H:%M:%S", localtime $now);
     die $! if STDOUT->error;
     die $! unless STDOUT->flush;
 }
 
+sub cmd_unprocessed () {
+    die unless @ARGV==1;
+    my ($baseinfo) = @ARGV;
+
+    get_current_plan();
+    push @{ $plan->{Unprocessed} }, { Info => $baseinfo };
+    check_write_new_plan();
+}
+
 die unless @ARGV;
 die if $ARGV[0] =~ m/^-/;
 my $subcmd= shift @ARGV;
diff --git a/ms-queuedaemon b/ms-queuedaemon
index 72e22d0..fba28a1 100755
--- a/ms-queuedaemon
+++ b/ms-queuedaemon
@@ -482,12 +482,21 @@ proc restarter-restart-now {} {
 	log-event "restarter-restart-now projection-running"
     }
 
+    foreach skip [set plan/queue_running] {
+	for-chan $skip {
+	    chan-note-unprocessed plan $skip
+	}
+    }
     report-plan plan plan
 
     unset plan/queue_running
     runneeded-ensure-will 2
 }
 
+proc chan-note-unprocessed {w chan} {
+    exec ./ms-planner -w$w unprocessed [chan-plan-info $chan {}]
+}
+
 proc notify-to-think {w thinking} {
     for-chan $thinking {
 	set noalloc [chan-get-info $thinking {$info(feature-noalloc)} {}]
@@ -496,6 +505,7 @@ proc notify-to-think {w thinking} {
 	    projection.1 { puts-chan $thinking "!OK think noalloc" }
 	    projection.* {
 		# oh well, can't include it in the projection; too bad
+		chan-note-unprocessed $w $thinking
 		queuerun-step-done $w "!feature-noalloc"
 	    }
 	}
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [OSSTEST PATCH 19/29] Tcl: Provide get-chan-desc in daemonlib
  2015-09-07 16:07 [OSSTEST PATCH v2 00/29] Planner: Performance improvement Ian Jackson
                   ` (17 preceding siblings ...)
  2015-09-07 16:08 ` [OSSTEST PATCH 18/29] Planner: Report unprocessed planning clients Ian Jackson
@ 2015-09-07 16:08 ` Ian Jackson
  2015-09-07 16:08 ` [OSSTEST PATCH 20/29] Planner: ms-queuedaemon: Use chan-get-desc in chan-plan-info Ian Jackson
                   ` (9 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Ian Jackson @ 2015-09-07 16:08 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Campbell

Provide a facility for the daemon main program to get the channel
connection information.

No caller yet.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
v2: New patch
---
 tcl/daemonlib.tcl |    5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tcl/daemonlib.tcl b/tcl/daemonlib.tcl
index d097624..55bc385 100644
--- a/tcl/daemonlib.tcl
+++ b/tcl/daemonlib.tcl
@@ -106,6 +106,11 @@ proc puts-chan-desc {chan m} {
     log "$desc $m"
 }
 
+proc get-chan-desc {chan} {
+    upvar \#0 chandesc($chan) desc
+    return $desc
+}
+
 proc must-gets-chan {chan re} {
     if {[gets $chan l] <= 0} { error "NOT $chan $re ?" }
     puts-chan-desc $chan "<< $l"
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [OSSTEST PATCH 20/29] Planner: ms-queuedaemon: Use chan-get-desc in chan-plan-info
  2015-09-07 16:07 [OSSTEST PATCH v2 00/29] Planner: Performance improvement Ian Jackson
                   ` (18 preceding siblings ...)
  2015-09-07 16:08 ` [OSSTEST PATCH 19/29] Tcl: Provide get-chan-desc in daemonlib Ian Jackson
@ 2015-09-07 16:08 ` Ian Jackson
  2015-09-07 16:08 ` [OSSTEST PATCH 21/29] Planner: Remove O(n^2) problem from plan restart Ian Jackson
                   ` (8 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Ian Jackson @ 2015-09-07 16:08 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Campbell

This relieves the callers of the need to provide a desc.  This is
helpful because chan-note-unprocessed doesn't have one.

Overall functional change is to show the chan desc (ie, the client TCP
connection info) in the list of unprocessed clients.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
v2: New patch
---
 ms-queuedaemon |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/ms-queuedaemon b/ms-queuedaemon
index fba28a1..29b906f 100755
--- a/ms-queuedaemon
+++ b/ms-queuedaemon
@@ -375,7 +375,8 @@ proc cmd/get-last-plan {chan desc w} {
     return-plan-to-client $chan $w.final
 }
 
-proc chan-plan-info {chan desc} {
+proc chan-plan-info {chan} {
+    set desc [get-chan-desc $chan]
     set l {}
     lappend l [chan-get-info $chan {"$info(preinfo)"} ""]
     lappend l [chan-get-info $chan {"job $info(job)"} $desc]
@@ -388,7 +389,7 @@ proc cmd/book-resources {chan desc bytes} {
 proc do-book-resources {chan desc data} {
     global plan errorInfo
     set w [check-we-are-thinking $chan]
-    set info [chan-plan-info $plan $desc]
+    set info [chan-plan-info $chan]
     if {[catch {
 	exec ./ms-planner -w$w book-resources $info << $data
     } emsg]} {
@@ -494,7 +495,7 @@ proc restarter-restart-now {} {
 }
 
 proc chan-note-unprocessed {w chan} {
-    exec ./ms-planner -w$w unprocessed [chan-plan-info $chan {}]
+    exec ./ms-planner -w$w unprocessed [chan-plan-info $chan]
 }
 
 proc notify-to-think {w thinking} {
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [OSSTEST PATCH 21/29] Planner: Remove O(n^2) problem from plan restart
  2015-09-07 16:07 [OSSTEST PATCH v2 00/29] Planner: Performance improvement Ian Jackson
                   ` (19 preceding siblings ...)
  2015-09-07 16:08 ` [OSSTEST PATCH 20/29] Planner: ms-queuedaemon: Use chan-get-desc in chan-plan-info Ian Jackson
@ 2015-09-07 16:08 ` Ian Jackson
  2015-09-07 16:08 ` [OSSTEST PATCH 22/29] Planner: ms-queuedaemon: Better log message for Tcl `after idle' Ian Jackson
                   ` (7 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Ian Jackson @ 2015-09-07 16:08 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Campbell

Change `./ms-planner unprocessed' to take a file of infos on stdin,
and when we restart the planning, invoke it once.

(This would be an incompatible change to the planner, needing a
queuedaemon restart, if this patch were applied separately from the
previous "Report unprocessed planning clients".)

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
v2: New patch
---
 ms-planner     |   10 +++++++---
 ms-queuedaemon |   18 +++++++++++-------
 2 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/ms-planner b/ms-planner
index 495c8ff..47e0ea7 100755
--- a/ms-planner
+++ b/ms-planner
@@ -756,11 +756,15 @@ sub cmd_show_html () {
 }
 
 sub cmd_unprocessed () {
-    die unless @ARGV==1;
-    my ($baseinfo) = @ARGV;
+    die unless @ARGV==0;
 
     get_current_plan();
-    push @{ $plan->{Unprocessed} }, { Info => $baseinfo };
+
+    while (<STDIN>) {
+	chomp;
+	push @{ $plan->{Unprocessed} }, { Info => $_ };
+    }
+
     check_write_new_plan();
 }
 
diff --git a/ms-queuedaemon b/ms-queuedaemon
index 29b906f..a249b50 100755
--- a/ms-queuedaemon
+++ b/ms-queuedaemon
@@ -483,10 +483,10 @@ proc restarter-restart-now {} {
 	log-event "restarter-restart-now projection-running"
     }
 
-    foreach skip [set plan/queue_running] {
-	for-chan $skip {
-	    chan-note-unprocessed plan $skip
-	}
+    if {[catch {
+	chans-note-unprocessed plan [set plan/queue_running]
+    } emsg]} {
+	log "INTERNAL ERROR setting unprocessed: $emsg"
     }
     report-plan plan plan
 
@@ -494,8 +494,12 @@ proc restarter-restart-now {} {
     runneeded-ensure-will 2
 }
 
-proc chan-note-unprocessed {w chan} {
-    exec ./ms-planner -w$w unprocessed [chan-plan-info $chan]
+proc chans-note-unprocessed {w chans} {
+    set data {}
+    foreach chan $chans {
+	append data [chan-plan-info $chan] "\n"
+    }
+    exec ./ms-planner -w$w unprocessed << $data
 }
 
 proc notify-to-think {w thinking} {
@@ -506,7 +510,7 @@ proc notify-to-think {w thinking} {
 	    projection.1 { puts-chan $thinking "!OK think noalloc" }
 	    projection.* {
 		# oh well, can't include it in the projection; too bad
-		chan-note-unprocessed $w $thinking
+		chans-note-unprocessed $w [list $thinking]
 		queuerun-step-done $w "!feature-noalloc"
 	    }
 	}
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [OSSTEST PATCH 22/29] Planner: ms-queuedaemon: Better log message for Tcl `after idle'
  2015-09-07 16:07 [OSSTEST PATCH v2 00/29] Planner: Performance improvement Ian Jackson
                   ` (20 preceding siblings ...)
  2015-09-07 16:08 ` [OSSTEST PATCH 21/29] Planner: Remove O(n^2) problem from plan restart Ian Jackson
@ 2015-09-07 16:08 ` Ian Jackson
  2015-09-07 16:08 ` [OSSTEST PATCH 23/29] Planner: ms-queuedaemon: Reformat debugging output for more tasks Ian Jackson
                   ` (6 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Ian Jackson @ 2015-09-07 16:08 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Campbell

This does not mean the planner is `idle' in any general sense of the
word.  It just means that the Tcl event loop has finished processing
outstanding events.  Change the debug message to be less confusing.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
v2: New patch
---
 ms-queuedaemon |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ms-queuedaemon b/ms-queuedaemon
index a249b50..9280f51 100755
--- a/ms-queuedaemon
+++ b/ms-queuedaemon
@@ -73,7 +73,7 @@ proc log-event {m} {
     if {![info exists log_state_after]} {
         set log_state_after [after idle {
             unset log_state_after
-            log-state idle
+            log-state tcl-idle
         }]
     }
 }
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [OSSTEST PATCH 23/29] Planner: ms-queuedaemon: Reformat debugging output for more tasks
  2015-09-07 16:07 [OSSTEST PATCH v2 00/29] Planner: Performance improvement Ian Jackson
                   ` (21 preceding siblings ...)
  2015-09-07 16:08 ` [OSSTEST PATCH 22/29] Planner: ms-queuedaemon: Better log message for Tcl `after idle' Ian Jackson
@ 2015-09-07 16:08 ` Ian Jackson
  2015-09-07 16:08 ` [OSSTEST PATCH 24/29] Manual allocation: Report better info in plan for rogue tasks Ian Jackson
                   ` (5 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Ian Jackson @ 2015-09-07 16:08 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Campbell

These wider fields will work well for up to 999 tasks.

Cosmetic change only.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
v2: New patch
---
 ms-queuedaemon |   13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/ms-queuedaemon b/ms-queuedaemon
index 9280f51..98cf5c1 100755
--- a/ms-queuedaemon
+++ b/ms-queuedaemon
@@ -81,20 +81,21 @@ proc log-event {m} {
 proc log-state {m} {
     global need_queue_run queue
 
-    set lhs [format "N=%d Q=%d (%-11.11s) " \
+    set lhs [format "N=%d Q=%d (%-15.15s) " \
                  $need_queue_run [llength $queue] $queue]
 
     foreach-walker w {
+	append lhs "| "
 	if {[info exists queue_running]} {
-	    append lhs [format "R=%d " [llength $queue_running]]
+	    append lhs [format "R=%-3d " [llength $queue_running]]
 	    if {[info exists thinking]} {
-		append lhs [format "T=%s " $thinking]
+		append lhs [format "T=%-7s " $thinking]
 	    } else {
-		append lhs [format "        "]
+		append lhs [format "          "]
 	    }
-	    append lhs [format "(%-11.11s) " $queue_running]
+	    append lhs [format "(%-15.15s) " $queue_running]
 	} else {
-	    append lhs "                          "
+	    append lhs "                                  "
 	}
     }
 
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [OSSTEST PATCH 24/29] Manual allocation: Report better info in plan for rogue tasks
  2015-09-07 16:07 [OSSTEST PATCH v2 00/29] Planner: Performance improvement Ian Jackson
                   ` (22 preceding siblings ...)
  2015-09-07 16:08 ` [OSSTEST PATCH 23/29] Planner: ms-queuedaemon: Reformat debugging output for more tasks Ian Jackson
@ 2015-09-07 16:08 ` Ian Jackson
  2015-09-07 16:08 ` [OSSTEST PATCH 25/29] Manual allocation: Break out manual_allocation_base_jobinfo from mg-blockage Ian Jackson
                   ` (4 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Ian Jackson @ 2015-09-07 16:08 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Campbell, Ian Jackson

(This will only take effect as such tasks appear in the plan for the
first time.  Ie, once a rogue task is found, the plan is populated by
whatever version of the planner is running at that time.  So the
effect will not be immediately visible.)

Signed-off-by: Ian Jackson <iwj@osstest.xs.citrite.net>
---
v2: New patch
---
 ms-planner |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/ms-planner b/ms-planner
index 47e0ea7..1f996a6 100755
--- a/ms-planner
+++ b/ms-planner
@@ -291,7 +291,10 @@ END
 	    $info= "(preparing)";
 	} else {
 	    print DEBUG "rogue $reso $shareix: $arow->{owntaskid}\n";
-	    $info= "rogue task $arow->{subtask}";
+	    $info= "rogue task";
+	    $info .= " $arow->{type} $arow->{refkey}";
+	    $info .= " ($arow->{comment})" if defined $arow->{comment};
+	    $info .= " $arow->{subtask}";
 	}
 	$plan->{Allocations}{$reskey}= {
             Task => $arow->{owntaskid},
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [OSSTEST PATCH 25/29] Manual allocation: Break out manual_allocation_base_jobinfo from mg-blockage
  2015-09-07 16:07 [OSSTEST PATCH v2 00/29] Planner: Performance improvement Ian Jackson
                   ` (23 preceding siblings ...)
  2015-09-07 16:08 ` [OSSTEST PATCH 24/29] Manual allocation: Report better info in plan for rogue tasks Ian Jackson
@ 2015-09-07 16:08 ` Ian Jackson
  2015-09-08  9:59   ` Ian Campbell
  2015-09-07 16:08 ` [OSSTEST PATCH 26/29] Manual allocation: Provide JobInfo in mg-blockage Ian Jackson
                   ` (3 subsequent siblings)
  28 siblings, 1 reply; 32+ messages in thread
From: Ian Jackson @ 2015-09-07 16:08 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Campbell

This is called `jobinfo' because it ought to be used in
alloc_resources's JobInfo xparam, rather than an Xinfo in the booking:
JobInfo is per planning client; Xinfo is per individual resource.

mg-blockage currently gets this wrong; we will fix that shortly.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
v2: New patch
---
 Osstest/Executive.pm |    7 +++++++
 mg-blockage          |    5 ++---
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/Osstest/Executive.pm b/Osstest/Executive.pm
index 4f51d70..1efcfd4 100644
--- a/Osstest/Executive.pm
+++ b/Osstest/Executive.pm
@@ -51,6 +51,7 @@ BEGIN {
                       report_altchangecolour
                       report_blessingscond report_find_push_age_info
                       tcpconnect_queuedaemon plan_search
+                      manual_allocation_base_jobinfo
                       alloc_resources alloc_resources_rollback_begin_work
                       resource_check_allocated resource_shared_mark_ready
                       duration_estimator
@@ -494,6 +495,12 @@ END
     return $taskid;
 }        
 
+sub manual_allocation_base_jobinfo () {
+    my $whoami = `whoami`; chomp $whoami;
+    my $hostname = `uname -n`; chomp $hostname;
+    return "$whoami\@$hostname";
+}
+
 sub alloc_resources_rollback_begin_work () {
     $dbh_tests->rollback();
     db_begin_work($dbh_tests, \@all_lock_tables);
diff --git a/mg-blockage b/mg-blockage
index 1f66d8e..0286c27 100755
--- a/mg-blockage
+++ b/mg-blockage
@@ -24,9 +24,8 @@ sub parsedate ($) {
     return $r;
 }
 
-my $whoami = `whoami`; chomp $whoami;
-my $hostname = `uname -n`; chomp $hostname;
-my $xinfo = "blockage $whoami\@$hostname [$start .. $end]";
+my $basexinfo = manual_allocation_base_joinfo();
+my $xinfo = "blockage $basexinfo [$start .. $end]";
 $xinfo .= " $mxinfo" if defined $mxinfo;
 
 $start = parsedate $start;
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [OSSTEST PATCH 26/29] Manual allocation: Provide JobInfo in mg-blockage
  2015-09-07 16:07 [OSSTEST PATCH v2 00/29] Planner: Performance improvement Ian Jackson
                   ` (24 preceding siblings ...)
  2015-09-07 16:08 ` [OSSTEST PATCH 25/29] Manual allocation: Break out manual_allocation_base_jobinfo from mg-blockage Ian Jackson
@ 2015-09-07 16:08 ` Ian Jackson
  2015-09-07 16:08 ` [OSSTEST PATCH 27/29] Manual allocation: Provide JobInfo in mg-allocate Ian Jackson
                   ` (2 subsequent siblings)
  28 siblings, 0 replies; 32+ messages in thread
From: Ian Jackson @ 2015-09-07 16:08 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Campbell

Supply most of the information about our allocations in JobInfo,
rather than Xinfo.  And, correspondingly, rename all the variables
`xinfo' to `info'.

Supply only the supplied hostname as the Xinfo.  This is slightly
redundant but it does at least tell us what came out of the db.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
v2: New patch
---
 mg-blockage |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/mg-blockage b/mg-blockage
index 0286c27..90547a5 100755
--- a/mg-blockage
+++ b/mg-blockage
@@ -14,7 +14,7 @@ csreadconfig();
 die unless @ARGV==3 || @ARGV==4;
 die if $ARGV[0] =~ m/^=/;
 
-our ($start,$end,$hostflag,$mxinfo) = @ARGV;
+our ($start,$end,$hostflag,$minfo) = @ARGV;
 
 sub parsedate ($) {
     open D, "-|", qw(date +%s -d), @_ or die $!;
@@ -24,13 +24,13 @@ sub parsedate ($) {
     return $r;
 }
 
-my $basexinfo = manual_allocation_base_joinfo();
-my $xinfo = "blockage $basexinfo [$start .. $end]";
-$xinfo .= " $mxinfo" if defined $mxinfo;
+my $baseinfo = manual_allocation_base_jobinfo();
+my $info = "blockage $baseinfo [$start .. $end]";
+$info .= " $minfo" if defined $minfo;
 
 $start = parsedate $start;
 $end   = parsedate $end;
-print $xinfo, "\n" or die $!;
+print $info, "\n" or die $!;
 
 die unless $end > $start;
 
@@ -38,7 +38,7 @@ sub min { (sort @_)[0]; }
 sub max { (reverse sort @_)[0]; }
 
 sub plan () {
-    alloc_resources(sub {
+    alloc_resources(JobInfo => $info, sub {
 	my ($plan, $mayalloc) = @_;
 
 	my $now = time;
@@ -72,7 +72,7 @@ END
 		foreach (my $ix=0; $ix<$avail; $ix++) {
 		    my $booking =  {
 			Reso => $res->{restype}.' '.$res->{resname},
-			Xinfo => $xinfo,
+			Xinfo => $host,
 			Start => $bookstart - $now,
 			End => $bookend - $now,
 		    };
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [OSSTEST PATCH 27/29] Manual allocation: Provide JobInfo in mg-allocate
  2015-09-07 16:07 [OSSTEST PATCH v2 00/29] Planner: Performance improvement Ian Jackson
                   ` (25 preceding siblings ...)
  2015-09-07 16:08 ` [OSSTEST PATCH 26/29] Manual allocation: Provide JobInfo in mg-blockage Ian Jackson
@ 2015-09-07 16:08 ` Ian Jackson
  2015-09-07 16:08 ` [OSSTEST PATCH 28/29] Manual allocation: Show tty in jobinfo Ian Jackson
  2015-09-07 16:08 ` [OSSTEST PATCH 29/29] Manual allocation: Set $| in mg-blockage Ian Jackson
  28 siblings, 0 replies; 32+ messages in thread
From: Ian Jackson @ 2015-09-07 16:08 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Campbell

Use manual_allocation_base_jobinfo to obtain some information which
will go into `job' in the planner, and show up everywhere.

Put just the request (from the command line) in the Xinfo.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
v2: New patch
---
 mg-allocate |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/mg-allocate b/mg-allocate
index 14c9088..672d9ec 100755
--- a/mg-allocate
+++ b/mg-allocate
@@ -269,7 +269,10 @@ sub showposs ($) {
 
 sub plan () {
     my @got;
-    alloc_resources(sub {
+
+    my $info = "manual ".manual_allocation_base_jobinfo();
+
+    alloc_resources(JobInfo => $info, sub {
         my ($plan, $mayalloc) = @_;
 
 	@got = ();
@@ -337,7 +340,7 @@ sub plan () {
         foreach my $req (@reqlist) {
             my $book= {
                 Reso => $req->{Reso},
-                Xinfo => "manual",
+                Xinfo => $req->{Ident},
                 Start => $planned->{Start},
                 End => $planned->{Start} + $duration,
             };
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [OSSTEST PATCH 28/29] Manual allocation: Show tty in jobinfo
  2015-09-07 16:07 [OSSTEST PATCH v2 00/29] Planner: Performance improvement Ian Jackson
                   ` (26 preceding siblings ...)
  2015-09-07 16:08 ` [OSSTEST PATCH 27/29] Manual allocation: Provide JobInfo in mg-allocate Ian Jackson
@ 2015-09-07 16:08 ` Ian Jackson
  2015-09-07 16:08 ` [OSSTEST PATCH 29/29] Manual allocation: Set $| in mg-blockage Ian Jackson
  28 siblings, 0 replies; 32+ messages in thread
From: Ian Jackson @ 2015-09-07 16:08 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Campbell, Ian Jackson

Signed-off-by: Ian Jackson <iwj@osstest.xs.citrite.net>
---
v2: New patch
---
 Osstest/Executive.pm |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/Osstest/Executive.pm b/Osstest/Executive.pm
index 1efcfd4..84600b4 100644
--- a/Osstest/Executive.pm
+++ b/Osstest/Executive.pm
@@ -498,7 +498,10 @@ END
 sub manual_allocation_base_jobinfo () {
     my $whoami = `whoami`; chomp $whoami;
     my $hostname = `uname -n`; chomp $hostname;
-    return "$whoami\@$hostname";
+    my $info = "$whoami\@$hostname";
+    my $tty = `tty 2>/dev/null`; chomp $tty;
+    $info .= " ($tty)" unless $?;
+    return $info;
 }
 
 sub alloc_resources_rollback_begin_work () {
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [OSSTEST PATCH 29/29] Manual allocation: Set $| in mg-blockage
  2015-09-07 16:07 [OSSTEST PATCH v2 00/29] Planner: Performance improvement Ian Jackson
                   ` (27 preceding siblings ...)
  2015-09-07 16:08 ` [OSSTEST PATCH 28/29] Manual allocation: Show tty in jobinfo Ian Jackson
@ 2015-09-07 16:08 ` Ian Jackson
  28 siblings, 0 replies; 32+ messages in thread
From: Ian Jackson @ 2015-09-07 16:08 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Campbell

This makes it slightly easier to see what it's happening if
mg-allocate or mg-blockage has no tty.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
v2: New patch
---
 mg-allocate |    2 ++
 mg-blockage |    2 ++
 2 files changed, 4 insertions(+)

diff --git a/mg-allocate b/mg-allocate
index 672d9ec..1e517a2 100755
--- a/mg-allocate
+++ b/mg-allocate
@@ -36,6 +36,8 @@ use Osstest::Executive;
 
 csreadconfig();
 
+$|=1;
+
 our $tid;
 our %magictask;
 
diff --git a/mg-blockage b/mg-blockage
index 90547a5..d3e6169 100755
--- a/mg-blockage
+++ b/mg-blockage
@@ -24,6 +24,8 @@ sub parsedate ($) {
     return $r;
 }
 
+$|=1;
+
 my $baseinfo = manual_allocation_base_jobinfo();
 my $info = "blockage $baseinfo [$start .. $end]";
 $info .= " $minfo" if defined $minfo;
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* Re: [OSSTEST PATCH 07/29] Planner: client side: Do not force OSSTEST_RESOURCE_PRIORITY
  2015-09-07 16:08 ` [OSSTEST PATCH 07/29] Planner: client side: Do not force OSSTEST_RESOURCE_PRIORITY Ian Jackson
@ 2015-09-08  9:45   ` Ian Campbell
  0 siblings, 0 replies; 32+ messages in thread
From: Ian Campbell @ 2015-09-08  9:45 UTC (permalink / raw)
  To: Ian Jackson, xen-devel

On Mon, 2015-09-07 at 17:08 +0100, Ian Jackson wrote:
> This makes it possible to run mg-allocate with a different priority
> simply by setting OSSTEST_RESOURCE_PRIORITY in its environment.
> 
> Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>

Acked-by: Ian Campbell <ian.campbell@citrix.com>

> ---
> v2: New patch
> ---
>  mg-allocate |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mg-allocate b/mg-allocate
> index 6dc7ddd..14c9088 100755
> --- a/mg-allocate
> +++ b/mg-allocate
> @@ -365,7 +365,7 @@ while (@ARGV && $ARGV[0] =~ m/^[-0-9]/) {
>                               $2 eq 'm' ?    60 :
>                                               1);
>          } elsif (s/^\-U/-/) {
> -            $ENV{OSSTEST_RESOURCE_PRIORITY}= -1000000;
> +            $ENV{OSSTEST_RESOURCE_PRIORITY} //= -1000000;
>          } else {
>              die "bad option \`$_'";
>          }

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [OSSTEST PATCH 25/29] Manual allocation: Break out manual_allocation_base_jobinfo from mg-blockage
  2015-09-07 16:08 ` [OSSTEST PATCH 25/29] Manual allocation: Break out manual_allocation_base_jobinfo from mg-blockage Ian Jackson
@ 2015-09-08  9:59   ` Ian Campbell
  0 siblings, 0 replies; 32+ messages in thread
From: Ian Campbell @ 2015-09-08  9:59 UTC (permalink / raw)
  To: Ian Jackson, xen-devel

On Mon, 2015-09-07 at 17:08 +0100, Ian Jackson wrote:
> This is called `jobinfo' because it ought to be used in
> alloc_resources's JobInfo xparam, rather than an Xinfo in the booking:
> JobInfo is per planning client; Xinfo is per individual resource.
> 
> mg-blockage currently gets this wrong; we will fix that shortly.
> 
> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
> ---
> v2: New patch
> ---
>  Osstest/Executive.pm |    7 +++++++
>  mg-blockage          |    5 ++---
>  2 files changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/Osstest/Executive.pm b/Osstest/Executive.pm
> index 4f51d70..1efcfd4 100644
> --- a/Osstest/Executive.pm
> +++ b/Osstest/Executive.pm
> @@ -51,6 +51,7 @@ BEGIN {
>                        report_altchangecolour
>                        report_blessingscond report_find_push_age_info
>                        tcpconnect_queuedaemon plan_search
> +                      manual_allocation_base_jobinfo
>                        alloc_resources
> alloc_resources_rollback_begin_work
>                        resource_check_allocated
> resource_shared_mark_ready
>                        duration_estimator
> @@ -494,6 +495,12 @@ END
>      return $taskid;
>  }        
>  
> +sub manual_allocation_base_jobinfo () {
> +    my $whoami = `whoami`; chomp $whoami;
> +    my $hostname = `uname -n`; chomp $hostname;
> +    return "$whoami\@$hostname";
> +}
> +
>  sub alloc_resources_rollback_begin_work () {
>      $dbh_tests->rollback();
>      db_begin_work($dbh_tests, \@all_lock_tables);
> diff --git a/mg-blockage b/mg-blockage
> index 1f66d8e..0286c27 100755
> --- a/mg-blockage
> +++ b/mg-blockage
> @@ -24,9 +24,8 @@ sub parsedate ($) {
>      return $r;
>  }
>  
> -my $whoami = `whoami`; chomp $whoami;
> -my $hostname = `uname -n`; chomp $hostname;
> -my $xinfo = "blockage $whoami\@$hostname [$start .. $end]";
> +my $basexinfo = manual_allocation_base_joinfo();

missing a b in jobinfo I think.

> +my $xinfo = "blockage $basexinfo [$start .. $end]";
>  $xinfo .= " $mxinfo" if defined $mxinfo;
>  
>  $start = parsedate $start;

^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2015-09-08  9:59 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-07 16:07 [OSSTEST PATCH v2 00/29] Planner: Performance improvement Ian Jackson
2015-09-07 16:07 ` [OSSTEST PATCH 01/29] Tcl: Use lshift instead of open-coding with lrange Ian Jackson
2015-09-07 16:08 ` [OSSTEST PATCH 02/29] Planner: docs: Minor fixes Ian Jackson
2015-09-07 16:08 ` [OSSTEST PATCH 03/29] Planner: docs: Document set-info command Ian Jackson
2015-09-07 16:08 ` [OSSTEST PATCH 04/29] Planner: Fix indefinite holdoff Ian Jackson
2015-09-07 16:08 ` [OSSTEST PATCH 05/29] Planner: client side: $mayalloc parameter to $resourcecall->() Ian Jackson
2015-09-07 16:08 ` [OSSTEST PATCH 06/29] Planner: client side: New `!OK think noalloc' protocol Ian Jackson
2015-09-07 16:08 ` [OSSTEST PATCH 07/29] Planner: client side: Do not force OSSTEST_RESOURCE_PRIORITY Ian Jackson
2015-09-08  9:45   ` Ian Campbell
2015-09-07 16:08 ` [OSSTEST PATCH 08/29] Planner: ms-planner support -w option Ian Jackson
2015-09-07 16:08 ` [OSSTEST PATCH 09/29] Planner: ms-queuedaemon: Prep for multiple walkers Ian Jackson
2015-09-07 16:08 ` [OSSTEST PATCH 10/29] Planner: ms-queuedaemon: Synchronise thinking " Ian Jackson
2015-09-07 16:08 ` [OSSTEST PATCH 11/29] Planner: ms-queuedaemon: Break out queuerun-finished/<walker> Ian Jackson
2015-09-07 16:08 ` [OSSTEST PATCH 12/29] Planner: ms-queuedaemon: Break out notify-to-think Ian Jackson
2015-09-07 16:08 ` [OSSTEST PATCH 13/29] Planner: ms-queuedaemon: Make report-plan take output walker name Ian Jackson
2015-09-07 16:08 ` [OSSTEST PATCH 14/29] Planner: ms-queuedaemon: Restart planning when resources become free Ian Jackson
2015-09-07 16:08 ` [OSSTEST PATCH 15/29] Plan reporting: Break out return-plan-to-client Ian Jackson
2015-09-07 16:08 ` [OSSTEST PATCH 16/29] Plan reporting: Provide get-last-plan queuedaemon command Ian Jackson
2015-09-07 16:08 ` [OSSTEST PATCH 17/29] Planner: ms-queuedaemon: Break out chan-plan-info Ian Jackson
2015-09-07 16:08 ` [OSSTEST PATCH 18/29] Planner: Report unprocessed planning clients Ian Jackson
2015-09-07 16:08 ` [OSSTEST PATCH 19/29] Tcl: Provide get-chan-desc in daemonlib Ian Jackson
2015-09-07 16:08 ` [OSSTEST PATCH 20/29] Planner: ms-queuedaemon: Use chan-get-desc in chan-plan-info Ian Jackson
2015-09-07 16:08 ` [OSSTEST PATCH 21/29] Planner: Remove O(n^2) problem from plan restart Ian Jackson
2015-09-07 16:08 ` [OSSTEST PATCH 22/29] Planner: ms-queuedaemon: Better log message for Tcl `after idle' Ian Jackson
2015-09-07 16:08 ` [OSSTEST PATCH 23/29] Planner: ms-queuedaemon: Reformat debugging output for more tasks Ian Jackson
2015-09-07 16:08 ` [OSSTEST PATCH 24/29] Manual allocation: Report better info in plan for rogue tasks Ian Jackson
2015-09-07 16:08 ` [OSSTEST PATCH 25/29] Manual allocation: Break out manual_allocation_base_jobinfo from mg-blockage Ian Jackson
2015-09-08  9:59   ` Ian Campbell
2015-09-07 16:08 ` [OSSTEST PATCH 26/29] Manual allocation: Provide JobInfo in mg-blockage Ian Jackson
2015-09-07 16:08 ` [OSSTEST PATCH 27/29] Manual allocation: Provide JobInfo in mg-allocate Ian Jackson
2015-09-07 16:08 ` [OSSTEST PATCH 28/29] Manual allocation: Show tty in jobinfo Ian Jackson
2015-09-07 16:08 ` [OSSTEST PATCH 29/29] Manual allocation: Set $| in mg-blockage Ian Jackson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.