Scheduler: consider what operations are necessary for layer-1

....still about to find out what kinds of Activities there are,
and what reasonably to implement on layer-2 vs. layer-1

It is clear that the worker will typically invoke a doWork()
operation on layer-2, which in turn will iterate layer-1.

Each worker pulls and performs internal managmenet tasks exclusively
until encountering the next real render task, at which point it will
drop an exclusion flag and then engage into performing the actual
extended work for rendering...
This commit is contained in:
Fischlurch 2023-06-27 03:21:10 +02:00
parent 3b6519a7c0
commit 4176576db0
5 changed files with 289 additions and 95 deletions

View file

@ -0,0 +1,116 @@
/*
SCHEDULER-COMMUTATOR.hpp - coordination layer of the render engine scheduler
Copyright (C) Lumiera.org
2023, Hermann Vosseler <Ichthyostega@web.de>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file scheduler-commutator.hpp
** Layer-2 of the Scheduler: coordination and interaction of activities.
** This is the upper layer of the implementation and provides high-level functionality.
**
** @see ////TODO_test usage example
** @see scheduler.cpp implementation
**
** @todo WIP-WIP-WIP 6/2023 »Playback Vertical Slice«
**
*/
#ifndef SRC_VAULT_GEAR_SCHEDULER_COMMUTATOR_H_
#define SRC_VAULT_GEAR_SCHEDULER_COMMUTATOR_H_
#include "vault/common.hpp"
#include "lib/nocopy.hpp"
#include "vault/gear/scheduler-invocation.hpp"
//#include "lib/symbol.hpp"
//#include "lib/util.hpp"
//#include <string>
namespace vault{
namespace gear {
// using util::isnil;
// using std::string;
/**
* Scheduler Layer-2 : coordination.
*
* @see SomeSystem
* @see NA_test
*/
class SchedulerCommutator
: util::NonCopyable
{
public:
// explicit
SchedulerCommutator()
{ }
void
doWork (SchedulerInvocation& layer1)
{
layer1.feedPriorisation();
while (layer1.isDue (currentLevel()))
{
Activity* activity = layer1.pullHead();
if (isInternalWork (activity))
performInternalWork (activity);
else
{
performExternalWork (activity);
return;
}
}
}
size_t
currentLevel() const
{
UNIMPLEMENTED ("define waterlevel based on current time");
}
bool
isInternalWork (Activity* activity)
{
UNIMPLEMENTED ("determine if an Activity counts as internal management task");
}
void
performInternalWork (Activity* activity)
{
UNIMPLEMENTED ("evaluate a term");
}
void
performExternalWork (Activity* activity)
{
UNIMPLEMENTED ("drop the exclusion flag and then engage into the external render activity");
}
};
}} // namespace vault::gear
#endif /*SRC_VAULT_GEAR_SCHEDULER_COMMUTATOR_H_*/

View file

@ -1,75 +0,0 @@
/*
SCHEDULER-CONTROL.hpp - coordination layer of the render engine scheduler
Copyright (C) Lumiera.org
2023, Hermann Vosseler <Ichthyostega@web.de>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file scheduler-control.hpp
** Layer-2 of the Scheduler: coordination of activities.
** This is the upper layer of the implementation and provides high-level functionality.
**
** @see ////TODO_test usage example
** @see scheduler.cpp implementation
**
** @todo WIP-WIP-WIP 6/2023 »Playback Vertical Slice«
**
*/
#ifndef SRC_VAULT_GEAR_SCHEDULER_CONTROL_H_
#define SRC_VAULT_GEAR_SCHEDULER_CONTROL_H_
#include "vault/common.hpp"
#include "lib/nocopy.hpp"
//#include "lib/symbol.hpp"
//#include "lib/util.hpp"
//#include <string>
namespace vault{
namespace gear {
// using util::isnil;
// using std::string;
/**
* Scheduler Layer-2 : coordination.
*
* @see SomeSystem
* @see NA_test
*/
class SchedulerControl
: util::NonCopyable
{
public:
// explicit
SchedulerControl()
{ }
};
}} // namespace vault::gear
#endif /*SRC_VAULT_GEAR_SCHEDULER_CONTROL_H_*/

View file

@ -110,29 +110,49 @@ namespace gear {
/**
* Pick up a new Activity and enqueue it according to time order
* Pick up all new Activities from the entrance queue
* and enqueue them according to time order
*/
void
prioriseNext()
feedPriorisation()
{
ActOrder actOrder;
bool hasInput = instruct_.pop (actOrder);
if (not hasInput)
return;
priority_.push (move (actOrder));
while (instruct_.pop (actOrder))
priority_.push (move (actOrder));
}
/**
* If there is an Activity to process now, pick it from the scheduling queue
* @return `nullptr` if the queue is empty, else the Activity corresponding
* to the currently most urgent element (without dequeuing it).
*/
Activity&
acceptHead()
Activity*
peekHead()
{
Activity* activity = priority_.top().activity;
///////////////////////////////////////////////////////////////////////////////OOO need to handle an empty queue or an Activity not ready to schedule yet
priority_.pop();
return *activity;
return priority_.empty()? nullptr
: priority_.top().activity;
}
/**
* If there is an Activity to process now, pick it from the scheduling queue
* @return `nullptr` if the prioritisation queue is empty,
* else a pointer to the most urgent Activity dequeued thereby.
*/
Activity*
pullHead()
{
Activity* activity = peekHead();
if (activity)
priority_.pop();
return activity;
}
/** Determine if there is work to do right now */
bool
isDue (size_t level) const
{
return not priority_.empty()
and priority_.top().waterlevel <= level;
}
};

View file

@ -42,7 +42,7 @@
#include "lib/error.hpp"
#include "vault/gear/block-flow.hpp"
#include "vault/gear/scheduler-control.hpp"
#include "vault/gear/scheduler-commutator.hpp"
#include "vault/gear/scheduler-invocation.hpp"
//#include "lib/symbol.hpp"
#include "lib/nocopy.hpp"
@ -67,7 +67,7 @@ namespace gear {
class Scheduler
{
SchedulerInvocation layer1_;
SchedulerControl layer2_;
SchedulerCommutator layer2_;
public:
explicit

View file

@ -77919,7 +77919,7 @@ Date:&#160;&#160;&#160;Thu Apr 20 18:53:17 2023 +0200<br/>
<node CREATED="1687484635170" ID="ID_1036236582" MODIFIED="1687484638425" TEXT="scheduler.hpp"/>
</node>
<node CREATED="1687475927002" ID="ID_1686499468" MODIFIED="1687475972136" TEXT="Baueinheiten">
<node CREATED="1687484825582" ID="ID_940173275" MODIFIED="1687556670006" TEXT="SchedulerControl">
<node CREATED="1687484825582" ID="ID_940173275" MODIFIED="1687788222303" TEXT="SchedulerCommutator">
<node CREATED="1687484855082" ID="ID_1615253188" MODIFIED="1687484859590" TEXT="&#x2261; Layer-2"/>
</node>
<node CREATED="1687484832866" ID="ID_922933023" MODIFIED="1687556674341" TEXT="SchedulerInvocation">
@ -77992,12 +77992,88 @@ Date:&#160;&#160;&#160;Thu Apr 20 18:53:17 2023 +0200<br/>
<icon BUILTIN="flag-yellow"/>
</node>
</node>
<node COLOR="#338800" CREATED="1687737461343" ID="ID_1187886360" MODIFIED="1687737929340" TEXT="prioriseNext">
<node COLOR="#5b280f" CREATED="1687737461343" ID="ID_1187886360" MODIFIED="1687825920257" TEXT="prioriseNext">
<icon BUILTIN="button_cancel"/>
<node CREATED="1687825948966" ID="ID_1180959210" MODIFIED="1687825956567" TEXT="wird stets iteriert werden">
<icon BUILTIN="messagebox_warning"/>
</node>
<node CREATED="1687825921441" ID="ID_167939453" MODIFIED="1687826410948" TEXT="stattdessen gleich die Eingangsqueue leeren">
<arrowlink COLOR="#31c960" DESTINATION="ID_254177626" ENDARROW="Default" ENDINCLINATION="169;9;" ID="Arrow_ID_1506119350" STARTARROW="None" STARTINCLINATION="-2;9;"/>
<icon BUILTIN="yes"/>
</node>
</node>
<node COLOR="#338800" CREATED="1687825916348" ID="ID_254177626" MODIFIED="1687826402411" TEXT="feedPriorisation">
<linktarget COLOR="#31c960" DESTINATION="ID_254177626" ENDARROW="Default" ENDINCLINATION="169;9;" ID="Arrow_ID_1506119350" SOURCE="ID_167939453" STARTARROW="None" STARTINCLINATION="-2;9;"/>
<icon BUILTIN="button_ok"/>
</node>
<node COLOR="#338800" CREATED="1687737502608" ID="ID_191302870" MODIFIED="1687826469913" TEXT="pullHead">
<icon BUILTIN="button_ok"/>
<node CREATED="1687826432255" ID="ID_499644502" MODIFIED="1687826482383" TEXT="pr&#xfc;ft nur auf leere Queue">
<icon BUILTIN="info"/>
</node>
<node CREATED="1687826441291" ID="ID_1200213778" MODIFIED="1687826472723" TEXT="ansonsten Kopf ab und gut is....">
<icon BUILTIN="ksmiletris"/>
</node>
<node CREATED="1687826450250" ID="ID_1322915953" MODIFIED="1687826464259" TEXT="alle weiteren Entscheidungen geh&#xf6;ren in Layer-2">
<icon BUILTIN="yes"/>
</node>
</node>
</node>
<node CREATED="1687789568770" ID="ID_1189205980" MODIFIED="1687789575453" TEXT="Iterations-Schnittstelle">
<node CREATED="1687789602339" ID="ID_1200625458" MODIFIED="1687789718505" TEXT="Zugang zum Head"/>
<node CREATED="1687789719097" ID="ID_908739206" MODIFIED="1687789773087" TEXT="Inkrement konsumiert Head"/>
<node COLOR="#435e98" CREATED="1687790434754" ID="ID_792756614" MODIFIED="1687790579147" TEXT="sind Iteratoren nicht zu aufwendig?">
<node CREATED="1687790448568" ID="ID_1298616776" MODIFIED="1687790588655" TEXT="Antwort: man kann von voller Optimierung ausgehen">
<icon BUILTIN="forward"/>
</node>
<node CREATED="1687790477442" ID="ID_1056199596" MODIFIED="1687790501011" TEXT="das hei&#xdf;t, duplikate Aufrufe werden nur einmal get&#xe4;tigt">
<richcontent TYPE="NOTE"><html>
<head>
</head>
<body>
<p>
Beispiel: __throw_if_empty()
</p>
</body>
</html></richcontent>
</node>
<node CREATED="1687790502105" ID="ID_1681570091" MODIFIED="1687790521163" TEXT="aber die Checks als Solche finden statt"/>
<node CREATED="1687790522630" ID="ID_21793953" MODIFIED="1687790577625" TEXT="das ist gut so">
<richcontent TYPE="NOTE"><html>
<head>
</head>
<body>
<p>
und sollte nur in Frage gestellt werden, sofern daf&#252;r <b>explizit</b>&#160; ein unverh&#228;ltnism&#228;&#223;iger Overhead nachweisbar ist...
</p>
</body>
</html></richcontent>
<icon BUILTIN="yes"/>
</node>
</node>
<node BACKGROUND_COLOR="#e0ceaa" COLOR="#690f14" CREATED="1687821034786" ID="ID_937800494" MODIFIED="1687821061014" TEXT="Aber: Formulierung als Iterator ist unn&#xf6;tig indirekt">
<icon BUILTIN="messagebox_warning"/>
<node CREATED="1687821070069" ID="ID_1435925687" MODIFIED="1687821077039" TEXT="es wird eine State-Core konstruiert"/>
<node CREATED="1687821077531" ID="ID_1082196031" MODIFIED="1687821081494" TEXT="darum ein Iterator gewickelt"/>
<node CREATED="1687821082602" ID="ID_1775935535" MODIFIED="1687821106963" TEXT="und dann in einem Loop-Konstrukt mit end() verglichen"/>
<node CREATED="1687821108615" ID="ID_1285462887" MODIFIED="1687821127384" TEXT="wozu unn&#xf6;tigerweise eine leere State-Core konstruiert wird"/>
<node CREATED="1687821133067" ID="ID_360125612" MODIFIED="1687821148773" TEXT="wenn es gut geht optimiert der Compiler das dann alles weg"/>
</node>
<node COLOR="#338800" CREATED="1687821381309" ID="ID_172756997" MODIFIED="1687827017617" TEXT="besser direkt auf den Nutzen hin implementieren">
<icon BUILTIN="yes"/>
<node CREATED="1687821414065" ID="ID_546937431" MODIFIED="1687821452581" TEXT="das hei&#xdf;t: f&#xfc;r eine while-Loop">
<icon BUILTIN="idea"/>
</node>
<node CREATED="1687821457099" ID="ID_1145270526" MODIFIED="1687823212479" TEXT="pr&#xfc;fen, entnehmen, weiterschalten">
<icon BUILTIN="forward"/>
<node COLOR="#338800" CREATED="1687826999365" ID="ID_924847659" MODIFIED="1687827009768" TEXT="peekHead()">
<icon BUILTIN="button_ok"/>
</node>
<node COLOR="#338800" CREATED="1687827002743" ID="ID_90050132" MODIFIED="1687827009768" TEXT="pullHead()">
<icon BUILTIN="button_ok"/>
</node>
<node CREATED="1687737502608" ID="ID_191302870" MODIFIED="1687737504869" TEXT="acceptHead">
<node BACKGROUND_COLOR="#fdfdcf" COLOR="#ff0000" CREATED="1687737932088" ID="ID_1987059198" MODIFIED="1687737955549" TEXT="Logik ungekl&#xe4;rt: leere Queue?, Zeitfenster?">
<icon BUILTIN="flag-pink"/>
</node>
</node>
</node>
@ -78008,6 +78084,18 @@ Date:&#160;&#160;&#160;Thu Apr 20 18:53:17 2023 +0200<br/>
<node CREATED="1685029743471" ID="ID_662250285" MODIFIED="1685029748808" TEXT="Benachrichtigungen">
<node BACKGROUND_COLOR="#f0d5c5" COLOR="#990033" CREATED="1685029752445" ID="ID_1073371022" MODIFIED="1685029779621" TEXT="wohin? andere Threads &#x27f9; lock-free Messaging-Queue">
<icon BUILTIN="help"/>
<node CREATED="1687788312178" ID="ID_1597757912" MODIFIED="1687788330482">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
<p>
ja &#8212; und zwar &#252;ber <i>den Scheduler selbst</i>
</p>
</body>
</html></richcontent>
</node>
</node>
<node BACKGROUND_COLOR="#f0d5c5" COLOR="#990033" CREATED="1685029812065" ID="ID_930725673" MODIFIED="1685029830507" TEXT="welcher Art Nachrichten treten auf?">
<icon BUILTIN="help"/>
@ -78020,9 +78108,48 @@ Date:&#160;&#160;&#160;Thu Apr 20 18:53:17 2023 +0200<br/>
</node>
</node>
</node>
<node CREATED="1687788623248" ID="ID_1335631068" MODIFIED="1687788627335" TEXT="Ausf&#xfc;hrungs-Struktur">
<node CREATED="1685029833448" ID="ID_1405359337" MODIFIED="1685029836621" TEXT="Verzweigungen">
<node BACKGROUND_COLOR="#f0d5c5" COLOR="#990033" CREATED="1685029839057" ID="ID_1926570028" MODIFIED="1685029854988" TEXT="verzweigte Ausf&#xfc;hrungs-Strukur oder nur Entscheidungs-Struktur?">
<icon BUILTIN="help"/>
<node CREATED="1687823249714" ID="ID_1864655181" MODIFIED="1687825736511">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
<p>
die <b>Ausf&#252;hrungs</b>-Struktur liegt in den Termen (nicht in der Queue)
</p>
</body>
</html></richcontent>
<icon BUILTIN="yes"/>
</node>
<node BACKGROUND_COLOR="#f0d5c5" COLOR="#990033" CREATED="1687823355712" ID="ID_1307602651" MODIFIED="1687823376918" TEXT="Welche Entscheidungs-Strukturen k&#xf6;nnten in der Queue stattfinden?">
<icon BUILTIN="help"/>
<node CREATED="1687823967742" ID="ID_854344895" MODIFIED="1687823989409" TEXT="eine Pr&#xfc;fung regelm&#xe4;&#xdf;ig wiederholen"/>
<node CREATED="1687824048509" ID="ID_713697923" MODIFIED="1687824058560" TEXT="bei Erfolg einen anderen Term einf&#xfc;gen"/>
<node CREATED="1687824086888" ID="ID_1796701768" MODIFIED="1687824103613" TEXT="oder einen anderen Term deaktivieren (=l&#xf6;schen)"/>
</node>
<node BACKGROUND_COLOR="#f0d5c5" COLOR="#990033" CREATED="1687824184209" ID="ID_1244600209" MODIFIED="1687825709638" TEXT="Event-getriebene Entscheidungs-Strukturen...?">
<icon BUILTIN="help"/>
<node CREATED="1687824217830" ID="ID_290545800" MODIFIED="1687824234977" TEXT="nach dem Ende eines Job wird noch ein Activity-Term abgefeuert"/>
<node CREATED="1687824273791" ID="ID_143043563" MODIFIED="1687824299591" TEXT="ein Term ist mit einem externen Signal verbunden"/>
<node CREATED="1687824301438" ID="ID_1540430139" MODIFIED="1687824323069" TEXT="...und das Signal f&#xfc;hrt dann zum Abfeuern eines weiteren Terms"/>
<node CREATED="1687825665315" ID="ID_402640209" MODIFIED="1687825688256">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
<p>
wichtig f&#252;r die <b>IO-Jobs</b>
</p>
</body>
</html></richcontent>
<icon BUILTIN="forward"/>
</node>
</node>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1685029859862" ID="ID_60316038" MODIFIED="1685029875094" TEXT="Pr&#xe4;dikat: Auswertung im Engine-Kontext">
<icon BUILTIN="flag-yellow"/>
@ -78038,6 +78165,12 @@ Date:&#160;&#160;&#160;Thu Apr 20 18:53:17 2023 +0200<br/>
</node>
</node>
</node>
<node CREATED="1687788654684" ID="ID_1528240185" MODIFIED="1687788658716" TEXT="Terme">
<node CREATED="1687788659433" ID="ID_1507624704" MODIFIED="1687788784350" TEXT="es werden Satz-artige Terme ausgewertet">
<icon BUILTIN="yes"/>
</node>
</node>
</node>
<node BACKGROUND_COLOR="#d2beaf" COLOR="#5c4d6e" CREATED="1684980732965" ID="ID_1914429002" MODIFIED="1684980742528" TEXT="Thema: Timing-Updates">
<icon BUILTIN="hourglass"/>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1684980744406" ID="ID_1565158605" LINK="https://issues.lumiera.org/ticket/1302" MODIFIED="1684981025601" TEXT="#1302 maintain consistent job timings">