95#ifndef SRC_VAULT_GEAR_SCHEDULER_H_
96#define SRC_VAULT_GEAR_SCHEDULER_H_
123 class SchedulerService_test;
148 std::optional<activity::Term>
term_;
261 TRACE (engine,
"Ignite Scheduler Dispatch.");
262 bool force_continued_run{
true};
280 TRACE (engine,
"Forcibly terminate Scheduler Dispatch.");
337 bool isCompulsory =
true;
338 Time deadline = nextStart + DUTY_CYCLE_TOLERANCE;
387 setup.currWorkForceSize = [
this]{
return workForce_.size(); };
388 setup.stepUpWorkForce = [
this](
uint steps){
workForce_.incScale(steps); };
467 chainEvent.
refineTo (chain, when, dead);
577 term_->appendNotificationTo (*succSpec.
term_, unlimitedTime);
586 predSpec.
term_->appendNotificationTo (*
term_, unlimitedTime);
596 throw error::Logic (
"Empty event passed into Scheduler entrance");
598 throw error::Fatal (
"Attempt to schedule an Activity without valid start time");
600 throw error::Fatal (
"Attempt to schedule an Activity without valid deadline");
602 Offset toDeadline{now,
event.deathTime()};
603 if (toDeadline > FUTURE_PLANNING_LIMIT)
605 "with a deadline by %s into the future"}
663 if (not
empty() or forceContinuation)
665 Time nextTick = now + (forceContinuation? WORK_HORIZON : DUTY_CYCLE_PERIOD);
666 Time deadline = nextTick + DUTY_CYCLE_TOLERANCE;
715 UNIMPLEMENTED (
"scheduler overrun -- trigger Emergency");
A language framework to define and interconnect scheduler activity verbs.
Memory management scheme for activities and parameter data passed through the Scheduler within the Lu...
Token or Atom with distinct identity.
Framerate specified as frames per second.
Offset measures a distance in time.
a mutable time value, behaving like a plain number, allowing copy and re-accessing
Lumiera's internal time value datatype.
static const Time NEVER
border condition marker value. NEVER >= any time value
static const Time ANYTIME
border condition marker value. ANYTIME <= any time value
Types marked with this mix-in may be moved and move-assigned.
Any copy and copy construction prohibited.
A front-end for using printf-style formatting.
Term builder and execution framework to perform chains of scheduler Activities.
activity::Term buildCalculationJob(Job job, Time start, Time deadline)
Builder-API: initiate definition of render activities for a media calculation job.
void announceLoad(FrameRate fps)
void discardBefore(Time deadline)
static activity::Proc dispatchChain(Activity *chain, EXE &executionCtx)
Execution Framework: dispatch performance of a chain of Activities.
activity::Term buildMetaJob(Job job, Time start, Time deadline)
Builder-API: initiate definition of internal/planning job.
Activity & createTick(Time deadline)
Record to describe an Activity, to happen within the Scheduler's control flow.
Low-level Render Engine event — abstracted storage base.
Collector and aggregator for performance data.
void dispatchEvent(size_t, EngineEvent)
Individual frame rendering task, forwarding to a closure.
Controller to coordinate resource usage related to the Scheduler.
double effectiveLoad() const
void markWorkerExit()
statistics update on scaling down the WorkForce
void updateState(Time)
periodic call to build integrated state indicators
void ensureCapacity(Time startHorizon)
Hook to check and possibly scale up WorkForce to handle one additional job.
Marker for current (and obsolete) manifestations of a CalcStream processed by the Render-Engine.
ScheduleSpec linkToSuccessor(ScheduleSpec &, bool unlimitedTime=false)
Scheduler * theScheduler_
ScheduleSpec lifeWindow(microseconds afterStart)
ScheduleSpec startOffset(microseconds afterNow)
ScheduleSpec(Scheduler &sched, Job job)
ScheduleSpec linkToPredecessor(ScheduleSpec &, bool unlimitedTime=false)
ScheduleSpec compulsory(bool indeed=true)
ScheduleSpec startTime(Time fixedTime)
std::optional< activity::Term > term_
ScheduleSpec manifestation(ManifestationID manID)
ScheduleSpec post()
build Activity chain and hand-over to the Scheduler.
Scheduler Layer-2 : execution of Scheduler Activities.
activity::Proc postChain(ActivationEvent event, SchedulerInvocation &layer1)
This is the primary entrance point to the Scheduler.
ScopedGroomingGuard requireGroomingTokenHere()
a scope guard to force acquisition of the GroomingToken
bool maintainQueueHead(SchedulerInvocation &layer1, Time now)
update queue head to discard obsolete content.
void dropGroomingToken() noexcept
relinquish the right for internal state transitions.
activity::Proc dispatchCapacity(SchedulerInvocation &, LoadController &, DISPATCH, CLOCK)
Implementation of the worker-Functor:
Scheduler Layer-1 : time based dispatch.
void activate(ManifestationID manID)
Enable entries marked with a specific ManifestationID to be processed.
void discardSchedule()
forcibly clear out the schedule
activity::Proc tick(Time now)
λ-tick : scheduler management duty cycle
void work(Time now, size_t qualifier)
λ-work : transition Managment-Mode -> Work-Mode
activity::Proc post(Time when, Time dead, Activity *chain, ExecutionCtx &ctx)
λ-post: enqueue for time-bound execution, within given ExecutionCtx.
ExecutionCtx(Scheduler &self, ActivationEvent toDispatch)
void done(Time now, size_t qualifier)
λ-done : signal end time of actual processing
Time getSchedTime()
access high-resolution-clock, rounded to µ-Ticks
ActivationEvent rootEvent
»Scheduler-Service« : coordinate render activities.
void handleWorkerTermination(bool isFailure)
Callback invoked whenever a worker-thread is about to exit.
void continueMetaJob(Time nextStart, Job planningJob, ManifestationID manID=ManifestationID())
Place a follow-up job-planning job into the timeline.
void sanityCheck(ActivationEvent const &)
LoadController loadControl_
Scheduler(BlockFlowAlloc &activityAllocator, EngineObserver &engineObserver)
ActivityLang activityLang_
void seedCalcStream(Job planningJob, ManifestationID manID=ManifestationID(), FrameRate expectedAdditionalLoad=FrameRate(25))
Set the Scheduler to work on a new CalcStream.
Time getSchedTime()
access high-resolution-clock, rounded to µ-Ticks
LoadController::Wiring connectMonitoring()
void ignite()
Spark the engine self-regulation cycle and power up WorkForce.
SchedulerInvocation layer1_
void terminateProcessing()
Bring down processing destructively as fast as possible.
activity::Proc doWork()
The worker-Functor: called by the active Workers from the WorkForce to pull / perform the actual rend...
void postChain(ActivationEvent)
Enqueue for time-bound execution, possibly dispatch immediately.
void maybeScaleWorkForce(Time startHorizon)
Hook invoked whenever a new task is passed in.
void triggerEmergency()
Trip the emergency brake and unwind processing while retaining all state.
double getLoadIndicator()
ScheduleSpec defineSchedule(Job job)
Render Job builder: start definition of a schedule to invoke the given Job.
void handleDutyCycle(Time now, bool=false)
»Tick-hook« : code to maintain a sane running status.
EngineObserver & engineObserver_
WorkForce< Setup > workForce_
SchedulerCommutator layer2_
Pool of worker threads for rendering.
work-timing event for performance observation
static WorkTiming start(Time now)
static WorkTiming stop(Time now)
Render Engine performance data collection service.
Lumiera error handling (C++ interface).
Scheduler resource usage coordination.
boost::rational< int64_t > FSecs
rational representation of fractional seconds
LumieraError< LERR_(FATAL), Logic > Fatal
LumieraError< LERR_(LOGIC)> Logic
Test runner and basic definitions for tests.
Proc
Result instruction from Activity activation.
@ PASS
pass on the activation down the chain
Offset DUTY_CYCLE_PERIOD
period of the regular scheduler »tick« for state maintenance.
Offset FUTURE_PLANNING_LIMIT
limit timespan of deadline into the future (~360 MiB max)
const auto IDLE_WAIT
sleep-recheck cycle for workers deemed idle
Offset DUTY_CYCLE_TOLERANCE
maximum slip tolerated on duty-cycle start before triggering Scheduler-emergency
const size_t DISMISS_CYCLES
number of wait cycles before an idle worker terminates completely
Vault-Layer implementation namespace root.
Mix-Ins to allow or prohibit various degrees of copying and cloning.
Front-end for simplified access to the current wall clock time.
Layer-2 of the Scheduler: coordination and interaction of activities.
Layer-1 of the Scheduler: queueing and prioritisation of activities.
void refineTo(Activity *chain, Time when, Time dead)
Base for configuration of the worker pool.
static size_t COMPUTATION_CAPACITY
Nominal »full size« of a pool of concurrent workers.
A pool of workers for multithreaded rendering.