[mythtv] Re: Re: Scheduler behavior, why?

David Engel gigem at comcast.net
Sun Feb 13 01:37:49 UTC 2005


On Sat, Feb 12, 2005 at 12:28:04PM -0800, Bruce Markey wrote:
> Anduin Withers wrote:
> >"Reschedule Higher Priorities" I don't know how I could have possibly
> >misinterpreted that.
> 
> Most likely because you misinterpreted what "Higher Priorities"
> means.

I think I need to reiterate some of the goals from when the scheduler
was written.  I thought these were made pretty clear then and are
captured in the documentation Bruce has written.

First, above all else, the behavior must be deterministic.  The
scheduler is run many times and the results can't change just because
something comes out of the database in a different order.  Maybe there
are other ways, but to me this implies having specific rules to break
priority ties when they occur.

Second, by default, the behavior is strictly priority based, whether
the priorities are explicit or implicit when used to break ties.  The
intent is to never risk missing a higher priority show in favor of a
lower one.  The SchedMoveHigher option is specifically there for
people who want to loosen this restriction.

Third, the scheduler will not expend inordinate effort trying to find
the best results for everyone's definition of best.  Instead it will
attempt to do a reasonable job in most cases and provide flexibility
via priorities, overrides or other means for users to tweak the
behavior when needed.  To anyone unsatisfied with this, they're
welcome to welcome to submit patches or write their own scheduler.

Now, that all being said, I think the SchedMoveHigher behavior can be
extended to automatically apply to programs of equal priority without
violating the above goals.  The attached patch attempts to do this for
anyone who wants to test it.

David
-- 
David Engel
gigem at comcast.net
-------------- next part --------------
Index: programs/mythbackend/scheduler.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythbackend/scheduler.cpp,v
retrieving revision 1.133
diff -u -u -r1.133 scheduler.cpp
--- programs/mythbackend/scheduler.cpp	9 Feb 2005 21:35:13 -0000	1.133
+++ programs/mythbackend/scheduler.cpp	13 Feb 2005 01:21:31 -0000
@@ -252,14 +252,11 @@
     VERBOSE(VB_SCHEDULE, "SchedNewRecords...");
     SchedNewRecords();
 
-    if (schedMoveHigher)
-    {
-        VERBOSE(VB_SCHEDULE, "Sort retrylist...");
-        retrylist.sort(comp_retry);
-        VERBOSE(VB_SCHEDULE, "MoveHigherRecords...");
-        MoveHigherRecords();
-        retrylist.clear();
-    }
+    VERBOSE(VB_SCHEDULE, "Sort retrylist...");
+    retrylist.sort(comp_retry);
+    VERBOSE(VB_SCHEDULE, "MoveHigherRecords...");
+    MoveHigherRecords();
+    retrylist.clear();
 
     VERBOSE(VB_SCHEDULE, "ClearListMaps...");
     ClearListMaps();
@@ -619,7 +616,7 @@
             MarkOtherShowings(titlelist, p);
             PrintRec(p, "  +");
         }
-        else if (schedMoveHigher)
+        else
         {
             for (k++; !FindNextConflict(cardlist, p, k); k++)
                 ;
@@ -651,7 +648,8 @@
         for ( ; FindNextConflict(cardlist, p, k); k++)
         {
             RecList &ktitlelist = titlelistmap[(*k)->title];
-            if (!TryAnotherShowing(ktitlelist, *k))
+            if ((p->recpriority < (*k)->recpriority && !schedMoveHigher) ||
+                !TryAnotherShowing(ktitlelist, *k))
             {
                 RestoreRecStatus();
                 break;


More information about the mythtv-dev mailing list