Scheduler: pass activity marker (low-level)
- define a simple record to represent the Activity - define a handle with an ordering function - low-level functions to... + accept such a handle + pick it from the entrace queue + pass it for priorisation into the PriQueue + dequeue the top priority element
This commit is contained in:
parent
bdcfc94b57
commit
3b6519a7c0
6 changed files with 143 additions and 23 deletions
|
|
@ -61,17 +61,27 @@ namespace gear {
|
|||
|
||||
|
||||
/**
|
||||
* Basic (abstracted) view of...
|
||||
*
|
||||
* @see SomeSystem
|
||||
* @see NA_test
|
||||
* Term to describe an Activity,
|
||||
* to happen within the Scheduler's control flow.
|
||||
*/
|
||||
class Activity
|
||||
{
|
||||
|
||||
public:
|
||||
// explicit
|
||||
Activity ()
|
||||
enum Verb {INVOKE ///< dispatches a JobFunctor into a worker thread
|
||||
,DEPEND ///< verify a given number of dependencies has been satisfied
|
||||
,TIMESTART ///< signal start of some processing (for timing measurement)
|
||||
,TIMESTOP ///< correspondingly signal end of some processing
|
||||
,NOTIFY ///< push a message to another Activity
|
||||
,PROBE ///< evaluate a condition and inhibit another target Activity
|
||||
,TICK ///< internal engine »heart beat« for internal maintenance hook(s)
|
||||
};
|
||||
|
||||
const Verb verb_;
|
||||
|
||||
explicit
|
||||
Activity (Verb verb)
|
||||
: verb_{verb}
|
||||
{ }
|
||||
|
||||
// using default copy/assignment
|
||||
|
|
|
|||
|
|
@ -63,8 +63,8 @@ namespace gear {
|
|||
{
|
||||
|
||||
public:
|
||||
explicit
|
||||
SchedulerControl (int const& b)
|
||||
// explicit
|
||||
SchedulerControl()
|
||||
{ }
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -47,13 +47,17 @@
|
|||
//#include <string>
|
||||
#include <queue>
|
||||
#include <boost/lockfree/queue.hpp>
|
||||
#include <utility>
|
||||
|
||||
namespace vault{
|
||||
namespace gear {
|
||||
|
||||
namespace error = lumiera::error;
|
||||
// using util::isnil;
|
||||
// using std::string;
|
||||
|
||||
using std::move;
|
||||
|
||||
|
||||
/**
|
||||
* Scheduler Layer-2 : invocation.
|
||||
|
|
@ -68,6 +72,16 @@ namespace gear {
|
|||
{
|
||||
size_t waterlevel{0};
|
||||
Activity* activity{nullptr};
|
||||
|
||||
/** @internal ordering function for time based scheduling
|
||||
* @note reversed order as required by std::priority_queue
|
||||
* to get the earliest element at top of the queue
|
||||
*/
|
||||
bool
|
||||
operator< (ActOrder const& o) const
|
||||
{
|
||||
return waterlevel > o.waterlevel;
|
||||
}
|
||||
};
|
||||
|
||||
using InstructQueue = boost::lockfree::queue<ActOrder>;
|
||||
|
|
@ -77,10 +91,49 @@ namespace gear {
|
|||
PriorityQueue priority_;
|
||||
|
||||
public:
|
||||
explicit
|
||||
SchedulerInvocation (int const& moo)
|
||||
// explicit
|
||||
SchedulerInvocation()
|
||||
{ }
|
||||
|
||||
|
||||
/**
|
||||
* Accept an Activity for time-bound execution
|
||||
*/
|
||||
void
|
||||
instruct (Activity& activity)
|
||||
{
|
||||
size_t waterLevel = 123; /////////////////////////////////////////////////////OOO derive water level from time window
|
||||
bool success = instruct_.push (ActOrder{waterLevel, &activity});
|
||||
if (not success)
|
||||
throw error::Fatal{"Scheduler entrance: memory allocation failed"};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Pick up a new Activity and enqueue it according to time order
|
||||
*/
|
||||
void
|
||||
prioriseNext()
|
||||
{
|
||||
ActOrder actOrder;
|
||||
bool hasInput = instruct_.pop (actOrder);
|
||||
if (not hasInput)
|
||||
return;
|
||||
priority_.push (move (actOrder));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* If there is an Activity to process now, pick it from the scheduling queue
|
||||
*/
|
||||
Activity&
|
||||
acceptHead()
|
||||
{
|
||||
Activity* activity = priority_.top().activity;
|
||||
///////////////////////////////////////////////////////////////////////////////OOO need to handle an empty queue or an Activity not ready to schedule yet
|
||||
priority_.pop();
|
||||
return *activity;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -66,12 +66,14 @@ namespace gear {
|
|||
*/
|
||||
class Scheduler
|
||||
{
|
||||
int nothing_;
|
||||
SchedulerInvocation layer1_;
|
||||
SchedulerControl layer2_;
|
||||
|
||||
public:
|
||||
explicit
|
||||
Scheduler (int const& boo)
|
||||
: nothing_(boo)
|
||||
Scheduler()
|
||||
: layer1_{}
|
||||
, layer2_{}
|
||||
{ }
|
||||
|
||||
// using default copy/assignment
|
||||
|
|
|
|||
|
|
@ -6843,7 +6843,7 @@ At first sight the link between asset and clip-MO is a simple logical relation b
|
|||
|
||||
{{red{Note 1/2015}}} several aspects regarding the relation of clips and single/multichannel media are not yet settled. There is a preliminary implementation in the code base, but it is not sure yet how multichnnel media will actually be modelled. Currently, we tend to treat the channel multiplicity rather as a property of the involved media, i.e we have //one// clip object.</pre>
|
||||
</div>
|
||||
<div title="RenderActivity" creator="Ichthyostega" modifier="Ichthyostega" created="202304140145" modified="202304140215" tags="Rendering spec draft" changecount="2">
|
||||
<div title="RenderActivity" creator="Ichthyostega" modifier="Ichthyostega" created="202304140145" modified="202306252308" tags="Rendering spec draft" changecount="4">
|
||||
<pre>//Render Activities define the execution language of the render engine.//
|
||||
The [[Scheduler]] maintains the ability to perform these Activities, in a time-bound fashion, observing dependency relations; activities allow for notification of completed work, tracking of dependencies, timing measurements, re-scheduling of other activities -- and last but not least the dispatch of actual [[render jobs|RenderJob]]. Activities are what is actually enqueued with priority in the scheduler implementation, they are planned for a »µ-tick slot«, activated once when the activation time is reached, and then forgotten. Each Activity is a //verb//, but can be inhibited by conditions and carry operation object data. Formally, activating an Activity equates to a predication, and the subject of that utterance is »the render process«.
|
||||
|
||||
|
|
@ -6853,13 +6853,13 @@ The [[Scheduler]] maintains the ability to perform these Activities, in a time-b
|
|||
:no further dependency checks; Activities attached to the job are re-dispatched after the job function's completion
|
||||
;depend
|
||||
:verify a given number of dependencies has been satisfied, otherwise inhibit the indicated target Activity
|
||||
;starttime
|
||||
;timestart
|
||||
:signal start of some processing -- for the purpose of timing measurement, but also to detect crashed tasks
|
||||
;stoptime
|
||||
;timestop
|
||||
:correspondingly signal end of some processing
|
||||
;notify
|
||||
:push a message to another Activity or process record
|
||||
;check
|
||||
;probe
|
||||
:invoke a closure within engine context; inhibit another target Activity, depending on the result.
|
||||
;tick
|
||||
:internal engine »heart beat« -- invoke internal maintenance hook(s)
|
||||
|
|
|
|||
|
|
@ -77773,7 +77773,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200<br/>
|
|||
</body>
|
||||
</html></richcontent>
|
||||
</node>
|
||||
<node CREATED="1684980900583" ID="ID_896772403" MODIFIED="1684980933730" TEXT="starttime">
|
||||
<node CREATED="1684980900583" ID="ID_896772403" MODIFIED="1687733911963" TEXT="timestart">
|
||||
<richcontent TYPE="NOTE"><html>
|
||||
<head>
|
||||
|
||||
|
|
@ -77785,7 +77785,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200<br/>
|
|||
</body>
|
||||
</html></richcontent>
|
||||
</node>
|
||||
<node CREATED="1684980900585" ID="ID_1179349638" MODIFIED="1684980938862" TEXT="stoptime">
|
||||
<node CREATED="1684980900585" ID="ID_1179349638" MODIFIED="1687733917360" TEXT="timestop">
|
||||
<richcontent TYPE="NOTE"><html>
|
||||
<head>
|
||||
|
||||
|
|
@ -77809,7 +77809,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200<br/>
|
|||
</body>
|
||||
</html></richcontent>
|
||||
</node>
|
||||
<node CREATED="1684980900587" ID="ID_1255388864" MODIFIED="1684980973980" TEXT="check">
|
||||
<node CREATED="1684980900587" ID="ID_1255388864" MODIFIED="1687734557301" TEXT="probe">
|
||||
<richcontent TYPE="NOTE"><html>
|
||||
<head>
|
||||
|
||||
|
|
@ -77935,7 +77935,8 @@ Date:   Thu Apr 20 18:53:17 2023 +0200<br/>
|
|||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1684973294743" ID="ID_495348423" MODIFIED="1684973356775" TEXT="Strukturen und Repräsentation">
|
||||
<arrowlink COLOR="#fe6d01" DESTINATION="ID_1599285907" ENDARROW="Default" ENDINCLINATION="-183;0;" ID="Arrow_ID_1756942771" STARTARROW="None" STARTINCLINATION="-502;-42;"/>
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node CREATED="1687653152145" ID="ID_1131516416" MODIFIED="1687653156132" TEXT="Technologie">
|
||||
<node CREATED="1687653152145" ID="ID_1131516416" MODIFIED="1687733723146" TEXT="Technologie">
|
||||
<icon BUILTIN="info"/>
|
||||
<node CREATED="1687653184679" ID="ID_354837865" MODIFIED="1687653275259" TEXT="Priority-Queue">
|
||||
<arrowlink COLOR="#7583c0" DESTINATION="ID_625176524" ENDARROW="Default" ENDINCLINATION="-651;120;" ID="Arrow_ID_1958287800" STARTARROW="None" STARTINCLINATION="-260;47;"/>
|
||||
<node CREATED="1687732117240" ID="ID_580535539" MODIFIED="1687732219469" TEXT="STL container adapter">
|
||||
|
|
@ -77965,6 +77966,42 @@ Date:   Thu Apr 20 18:53:17 2023 +0200<br/>
|
|||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1687737433506" ID="ID_1608121280" MODIFIED="1687737442698" TEXT="einfacher Activity-Transport">
|
||||
<icon BUILTIN="pencil"/>
|
||||
<node COLOR="#338800" CREATED="1687738213842" ID="ID_683259902" MODIFIED="1687738250423" TEXT="Payload: ActOrder">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
<node COLOR="#338800" CREATED="1687738222176" ID="ID_777939699" MODIFIED="1687738267070" TEXT="»waterlevel« für Zeit-Ordnung">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
<node CREATED="1687738270537" ID="ID_655072800" MODIFIED="1687738313630" TEXT="soll die Start-Zeit oder nominelle Zeit sein">
|
||||
<icon BUILTIN="yes"/>
|
||||
</node>
|
||||
<node CREATED="1687738289111" ID="ID_1129171046" MODIFIED="1687738310678" TEXT="Prioritätsklassen sollen hier mit Offset abgebildet werden">
|
||||
<icon BUILTIN="idea"/>
|
||||
</node>
|
||||
</node>
|
||||
<node COLOR="#338800" CREATED="1687738237630" ID="ID_706592774" MODIFIED="1687738266530" TEXT="Pointer auf die Activity (im BlockFlow)">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node COLOR="#338800" CREATED="1687738251598" ID="ID_1828364822" MODIFIED="1687738265443" TEXT="scheduling-Ordnungs-Operator">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
</node>
|
||||
<node CREATED="1687737451105" ID="ID_925616893" MODIFIED="1687737457699" TEXT="Basis-Operationen">
|
||||
<node CREATED="1687737459167" ID="ID_1982661220" MODIFIED="1687737469329" TEXT="instruct">
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1687737917521" ID="ID_1306162732" MODIFIED="1687737926950" TEXT="water-level definieren">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
</node>
|
||||
</node>
|
||||
<node COLOR="#338800" CREATED="1687737461343" ID="ID_1187886360" MODIFIED="1687737929340" TEXT="prioriseNext">
|
||||
<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ärt: leere Queue?, Zeitfenster?">
|
||||
<icon BUILTIN="flag-pink"/>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node CREATED="1680565476652" ID="ID_1218283238" MODIFIED="1684973201854" TEXT="Dependency-Notification">
|
||||
<linktarget COLOR="#fec499" DESTINATION="ID_1218283238" ENDARROW="Default" ENDINCLINATION="-664;74;" ID="Arrow_ID_443600884" SOURCE="ID_695181807" STARTARROW="None" STARTINCLINATION="-240;29;"/>
|
||||
|
|
@ -78664,7 +78701,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200<br/>
|
|||
<node CREATED="1685321445292" ID="ID_79914114" MODIFIED="1685321462397" TEXT="aber auch Activities rekursiv re-priorisiert"/>
|
||||
</node>
|
||||
<node CREATED="1685321483574" ID="ID_1477143023" MODIFIED="1685321501986" TEXT="Tile-based Activity Storage">
|
||||
<node CREATED="1685321607585" ID="ID_1565711693" MODIFIED="1685321636487">
|
||||
<node COLOR="#5b280f" CREATED="1685321607585" FOLDED="true" ID="ID_1565711693" MODIFIED="1687733705351">
|
||||
<richcontent TYPE="NODE"><html>
|
||||
<head>
|
||||
|
||||
|
|
@ -78675,8 +78712,22 @@ Date:   Thu Apr 20 18:53:17 2023 +0200<br/>
|
|||
</p>
|
||||
</body>
|
||||
</html></richcontent>
|
||||
<node BACKGROUND_COLOR="#f0d5c5" COLOR="#990033" CREATED="1685321654984" ID="ID_1291294754" MODIFIED="1685321668634" TEXT="geht das direkt?">
|
||||
<icon BUILTIN="button_cancel"/>
|
||||
<node COLOR="#435e98" CREATED="1685321654984" ID="ID_1291294754" MODIFIED="1687733565888" TEXT="geht das direkt?">
|
||||
<icon BUILTIN="help"/>
|
||||
<node CREATED="1687733555787" ID="ID_885750637" MODIFIED="1687733563308" TEXT="mäh"/>
|
||||
<node CREATED="1687733550692" ID="ID_700678765" MODIFIED="1687733593245" TEXT="im Prinzip ja">
|
||||
<richcontent TYPE="NOTE"><html>
|
||||
<head>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
is ja eine linked List
|
||||
</p>
|
||||
</body>
|
||||
</html></richcontent>
|
||||
</node>
|
||||
</node>
|
||||
<node CREATED="1685321679399" ID="ID_1492241069" MODIFIED="1685321797340" TEXT="Grund: lock-contention auf Memory-Management vermeiden">
|
||||
<richcontent TYPE="NOTE"><html>
|
||||
|
|
@ -78696,7 +78747,11 @@ Date:   Thu Apr 20 18:53:17 2023 +0200<br/>
|
|||
<node CREATED="1685321848944" ID="ID_1429281514" MODIFIED="1685321863381" TEXT="und diese wird chunk-wise single-threaded ausgeführt"/>
|
||||
<node CREATED="1685321874220" ID="ID_1713195430" MODIFIED="1685321882281" TEXT="ab diesem Punkt sind Activities langlebig"/>
|
||||
</node>
|
||||
<node CREATED="1687733598318" ID="ID_294366771" MODIFIED="1687733640177" TEXT="das bringt gar nix; dann ist die contention im Allocator der lock-free-Queue">
|
||||
<icon BUILTIN="stop-sign"/>
|
||||
</node>
|
||||
</node>
|
||||
<node CREATED="1687733658309" ID="ID_878694774" MODIFIED="1687733688708" TEXT="Activities werden aus Pools-pro-Thread geschöpft"/>
|
||||
<node CREATED="1685321970159" ID="ID_1733911974" MODIFIED="1685321991606" TEXT="Activities müssen bis zu ihrer Abarbeitung erhalten bleiben"/>
|
||||
<node CREATED="1685322001687" ID="ID_1323039724" MODIFIED="1685322028521" TEXT="da sie sich benachrichtigen können, brauchen sie stabile Adressen">
|
||||
<node CREATED="1685322042500" ID="ID_150807049" MODIFIED="1685322061645" TEXT="Vorsicht: das widerspricht dem Verschieben durch die Eingangsqueue"/>
|
||||
|
|
|
|||
Loading…
Reference in a new issue