Commit graph

325 commits

Author SHA1 Message Date
74c97614b3 Scheduler: component wiring
The »Scheduler Service« will be assembled
from the components developed during the last months
- Layer-1
- Layer-2
- Activity-Language
- Block-Flow
- Work-Force
2023-10-20 04:36:07 +02:00
9db341bd8b Scheduler: plan for integration
identified three distinct tasks
- build the external API
- establish component integration
- performance testing
2023-10-20 00:59:50 +02:00
9ce3ad3d72 Scheduler: Layer-2 complete and tested (see #1326)
* the implementation logic of the Scheduler is essentially complete now
 * all functionality necessary for the worker-function has been demonstrated

As next step, the »Scheduler Service« can be assembled from the two
Implementation Layers, the Activity-Language and the `BlockFlow` allocator
This should then be verified by a multi-threaded integration test...
2023-10-19 01:49:08 +02:00
10a2c6908c Scheduler: Layer-2 integration scenario complete
could even rig the diagnostic Execution-Ctx
to drop the GroomingToken at the point when switching to work-mode
2023-10-18 23:02:29 +02:00
c2ddaed28e Scheduler: draft scenario for Layer-2 integration test
Idea: re-use the scenario and instrumentation from
SchedulerActivity_test::scenario_RenderJob()
2023-10-18 18:10:10 +02:00
ee09a2eff2 Scheduler: completed implementation of Layer-2
...some further checks
...one integration test case needs to be written
2023-10-18 17:29:41 +02:00
93fcebb331 Scheduler: implement and verify postDispatch 2023-10-18 16:39:08 +02:00
666546856f Scheduler: design the core API operation - postDispatch
This central operation sits at a crossroad and is used
- from external clients to fed new work to the Scheduler
- from Workers to engage into execution of the next Activity
- recursively from the execution of an Activity-chain

From these requirements the semantics of behaviour can be derived
regarding the GroomingToken and the result values, which indicate
when follow-up work should be processed
2023-10-18 15:50:11 +02:00
55967cd649 Scheduler: work retrieval implementation
- simple approach, delegating to Layer-1
- deliberately no error handling
- GroomingToken not dropped
2023-10-18 04:18:01 +02:00
b57503fb97 Scheduler: define expected behaviour for work retrieval
still not quite sure how to implement it,
but working down from first principles to define test scenarios first...
2023-10-18 02:59:58 +02:00
aa60869082 Scheduler: decision logic for actual dispatch of activities 2023-10-18 01:38:58 +02:00
fa391d1267 Scheduler: torture test the thread access logic
Ensure the GroomingToken mechanism indeed creates an
exclusive section protected against concurrent corruption:

Use a without / with-protection test and verify
the results are exact vs. grossly broken
2023-10-17 21:35:37 +02:00
1223772f14 Scheduler: implement thread access logic
T thread holding the »Grooming Token" is permitted to
manipulate scheduler internals and thus also to define new
activities; this logic is implemented as an Atomic lock,
based on the current thread's ID.
2023-10-17 20:37:32 +02:00
862933e809 Scheduler: define API for Layer-2
Notably both Layers are conceived as functionality providers;
only at Scheduler top-Level will functionality be combined with
external dependencies to create the actual service.
2023-10-17 19:20:53 +02:00
0431a14584 Scheduler: Layer-1 complete and tested 2023-10-17 04:35:58 +02:00
430f1af4c5 Scheduler: define water-level for prioritisation 2023-10-17 03:38:28 +02:00
152413589c Scheduler: clarify role of the Time parameter
At first sight, this seems confusing; there is a time window,
there is sometimes a `when` parameter, and mostly a `now` parameter
is passed through the activation chain.

However, taking the operational semantics into account, the existing
definitions seem to be (mostly) adequate already: The scheduler is
assumed to activate a chain only ''when'' the defined start time is reached.
2023-10-17 03:04:19 +02:00
c76e5488bd Scheduler: plot steps towards integration
(1) SchedulerInvocation_test
    »Layer-1« : Queue operation

(2) SchedulerCommutator_test
    »Layer-2« : Activity execution

(3) SchedulerUsage_test
    Component End-to-End
2023-10-16 23:57:22 +02:00
3af6a54219 Library/Application: complete technology switch (closes #1279)
As follow-up to the rework of thread-handling, likewise also
the implementation base for locking was switched over from direct
usage of POSIX primitives to the portable wrappers available in
the C++ standard library. All usages have been reviewed and
modernised to prefer λ-functions where possible.

With this series of changes, the old threadpool implementation
and a lot of further low-level support facilities are not used
any more and can be dismantled. Due to the integration efforts
spurred by the »Playback Vertical Slice«, several questions of
architecture could be decided over the last months. The design
of the Scheduler and Engine turned out different than previously
anticipated; notably the Scheduler now covers a wider array of
functionality, including some asynchronous messaging. This has
ramifications for the organisation of work tasks and threads,
and leads to a more deterministic memory management. Resource
management will be done on a higher level, partially superseding
some of the concepts from the early phase of the Lumiera project.
2023-10-16 01:44:04 +02:00
685be1b039 Library/Application: consolidate Monitor API and usage
This is Step-2 : change the API towards application

Notably all invocation variants to support member functions
or a reference to bool flags are retracted, since today a
λ-binding directly at usage site tends to be more readable.

The function names are harmonised with the C++ standard and
emergency shutdown in the Subsystem-Runner is rationalised.

The old thread-wrapper test is repurposed to demonstrate
the effectiveness of monitor based locking.
2023-10-15 20:42:55 +02:00
73737f2aee Library/Application: consolidate Monitor implementation
After the fundamental switch from POSIX to the C++14 wrappers
the existing implementation of the Monitor can now be drastically condensed,
removing several layers of indirection. Moreover, all signatures
shall be changed to blend in with the names and patterns established
by the C++ standard.

This is Step-1 : consolidate the Implementation.

(to ensure correctness, the existing API towards application code was retained)
2023-10-15 02:41:41 +02:00
1c4f605e8f Library/Application: switch WorkForce
The WorkForce (passive worker pool) has been coded just recently,
and -- in anticipation of this refactoring -- directly against std::thread
instead of using the old framework.

...the switch is straight-forward, using the default case
...add the ability to decorate the thread-IDs with a running counter
2023-10-12 22:00:55 +02:00
42eba8425a Library: now able to provide a self-managed thread
After quite some detours, with this take I'm finally able to
provide a stringent design to embody all the variants of thread start
encountered in practice in the Lumiera code base.

Especially the *self-managed* thread is now represented as a special-case
of a lifecycle-hook, and can be embodied into a builder front-end,
able to work with any client-provided thread-wrapper subclass.
2023-10-10 21:45:41 +02:00
332ad0e920 Testsuite: fix regression
FamilyMember::allocateNextMember() was actually a post-increment,
so (different than with TypedCounter) here no correction is necessary


As an asside, WorkForce_test is sometimes unstable immediately after a build.
Seemingly a headstart of 50µs is not enough to compensate for scheduler leeway
2023-10-05 00:39:29 +02:00
c183045dfa Library: switch Microbenchmark setup to C++17 threads
Over time, a collection of microbenchmark helper functions was
extracted from occasional use -- including a variant to perform
parallelised microbenchmarks. While not used beyond sporadic experiments yet,
this framework seems a perfect fit for measuring the SyncBarrier performance.

There is only one catch:
 - it uses the old Threadpool + POSIX thread support
 - these require the Threadpool service to be started...
 - which in turn prohibits using them for libary tests

And last but not least: this setup already requires a barrier.

==> switch the existing microbenchmark setup to c++17 threads preliminarily
    (until the thread-wrapper has been reworked).
==> also introduce the new SyncBarrier here immediately
==> use this as a validation test of the setup + SyncBarrier
2023-09-24 18:07:28 +02:00
416895b5b2 Library: prepare switch of Thread-wrapper to C++17
The investigation for #1279 leads to the following conclusions

- the features and the design of our custom thread-wrapper
  almost entirely matches the design chosen meanwhile by the C++ committee

- the implementation provided by the standard library however uses
  modern techniques (especially Atomics) and is more precisely worked out
  than our custom implementation was.

- we do not need an *active* threadpool with work-assignment,
  rather we'll use *active* workers and a *passive* pool,
  which was easy to implement based on C++17 features

==> decision to drop our POSIX based custom implementation
    and to retrofit the Thread-wrapper as a drop-in replacement

+++ start this refactoring by moving code into the Library
+++ create a copy of the Threadwrapper-code to build and test
    the refactorings while the application itself still uses
    existing code, until the transition is complete
2023-09-21 23:23:55 +02:00
997fc36c81 Workforce: implementation complete 2023-09-09 23:42:13 +02:00
397ded86df Workforce: verify error handling and wait on shutdown
...seemingly the implementation is complete now
2023-09-09 03:31:46 +02:00
9ccdfa24f7 Workforce: invoke a exit hook prior to worker termination
...essential for clean-up work, especially to drop
claimed resources reliably, even in case of error.
2023-09-09 02:31:16 +02:00
dd62240900 Workforce: terminate after excessive idle cycles
- count each consecutive idle cycle
- by default, terminate after 100 idle cycles (2 sec)
2023-09-09 01:47:15 +02:00
b493f15333 Workforce: configure and demonstrate idle-wait 2023-09-09 01:12:10 +02:00
67a3e87dbc Workforce: demonstrate controlled worker-stop
- workers can be controlled by the return-value from the work functor
- this test could be brittle, since it's based on timing and CPU speed
2023-09-08 14:32:37 +02:00
ef5365057a Workforce: demonstrate standard behaviour
- can activate / scale up
- work functor invoked repeatedly
2023-09-08 14:07:23 +02:00
81cab9a675 Workforce: emergency brake
While in principle it would be possible (and desirable)
to control worker behaviour exclusively through the Work-Functor's return code,
in practice we must concede that Exceptions can always happen from situations
beyond our control. And while it is necessary for the WorkForce-dtor to
join and block (we can not just pull away the resources from running threads),
the same destructor (when called out of order) must somehow be able
at least to ask the running threads to terminate.

Especially for unit tests this becomes an obnoxious problem -- otherwise
each test failure would cause the test runner to hang.

Thus adding an emergency halt, and also improve setup for tests
with a convenience function to inject a work-function-λ
2023-09-08 02:48:30 +02:00
b8e52d008c Workforce: configuration and initialisation of workers
- use a template parameter to allow for hook into local facilities (Scheduler)
- pass config initialisation down through constructors
2023-09-07 17:15:25 +02:00
38ab5a6aa9 Workforce: draft simple usage
...start with an oversimplified implementation...
2023-09-05 00:24:33 +02:00
70cd8af806 Workforce: requirement analysis 2023-09-05 00:22:17 +02:00
2e28f5d278 Activity-Lang: abstracted execution framework complete and tested (closes: #1319) 2023-09-03 01:50:50 +02:00
95ae12bba1 Activity-Lang: complete handling of IO activities 2023-09-03 00:40:37 +02:00
b3b6f7524c Activity-Lang: outline for wiring async IO activities
...relies on the same building pattern, with the notable difference
that the chain is severed, providing an additional NOTIFY as re-entrance point
2023-09-02 22:36:02 +02:00
73a67886f0 Activity-Lang: wiring for internal/planning job
...uses just the minimal wiring and is thus already implemented :-)
2023-09-02 03:35:02 +02:00
e6d233def2 Activity-Lang: instrumentation to make the complete call sequence visible
No new functionality, and implementation works as expected.

This test case covers an especially tricky setup, where a calculation
shall be triggered from an external event, while ensuring that the actual
processing can start only after also the regular time-bound scheduling
has taken place (this might be used to prevent an unexpectedly early
external signal to cause writing into an output buffer before the
defined window of data delivery)
2023-09-02 03:08:13 +02:00
6563688e07 Activity-Lang: now able to demonstrate the intended call sequence
...based on the new ability in the ActivityDetector, we can now assign
a custom λ, which deflects back the ctx.post() call into the ActivityLang
instance used for this test case.

While the previously seen behaviour was correct, it was not the call sequence
expected in the real implementation; with this change, on the main-chain
activation the post() now immediately dispatches the notification, which in turn
dispatches the rest of the chain, so that the JobFunctor is indeed
called in this second test case as expected
2023-09-02 01:48:25 +02:00
f3cf178388 Activity-Lang: ability to hook in a fake implementation
Up to now, the DiagnosticFun mock in ActivityDetector only
created an EventLog entry on invocation and was able to retunr
a canned result value. Yet for the job invocation scenario test,
it would be desirable to hook-in a λ with a fake implementation
into the ExecutionContext. As a further convenience, the
return value is now default initialised, instead of being
marked as uninitialised until invocation of "returning(val)"
2023-09-01 21:59:25 +02:00
fd8716d398 Activity-Lang: demonstrate multi-stage Gate
...seems to work, but not really happy with the test setup,
since in real usage the post()-calls would dispatch, while here,
using the ActivityDetector, these calls just log invoation,
and thus the activation is not passed on
2023-09-01 19:23:27 +02:00
44e840f27c Activity-Lang: implement optional notification builders 2023-09-01 19:03:37 +02:00
963dc38088 Activity-Lang: introduce some shorthand notation
...regarding the kind of activity (the verb),
and also for some special case access of payload data;
deliberately asserting the correct verb, but no mandatory check,
since this whole Activity-Language is conceived as cohesive
and essentially sealed (not meant to be extended)
2023-09-01 17:41:40 +02:00
789bcd72c2 Activity-Lang: better solution to demonstrate time access
...to show in test that indeed the actual time is retrieved on each activation,
we can assign a λ -- which is rigged to increase the time on each access
2023-09-01 17:18:32 +02:00
67c71725a4 Activity-Lang: access current scheduler time dynamically
It is not sufficient just to pass this "current time" as parameter
into the ActivityLang::dispatchChain(), since some Activities within
this chain will essentially be long-running (think rendering); thus
we need a real callback from within the chain. The obvious solution
is to make this part of the Execution Context, which is an abstraction
of the scheduler environment anyway
2023-09-01 02:44:29 +02:00
14effc2349 Activity-Lang: consider logic for dependency notification
...turns out there is still a lot of leeway in the possible implementation,
and seemingly it is too early to decide which case to consider the default.
Thus I'll proceed with the drafted preliminary solution...

- on primary-chain, an inhibited Gate dispatches itself into future for re-check
- on Notification, activation happens if and only if this very notification opens the Gate
- provide a specifically wired requireDirectActivation() to allow enforcing a minimal start time
2023-08-31 20:18:35 +02:00
07fcc89e6a Activity-Lang: complete execution of the basic CalculationJob scheme
...assembled from parts already implemented

TODO
 - need a way to access the »current scheduler time«
 - need builder extension points to connect notifications
2023-08-31 02:24:01 +02:00
32c08c0307 Activity-Lang: also dispatch notifications 2023-08-31 02:11:07 +02:00
900f46b1d5 Activity-Lang: framework to execute a chain of Activities
without and error or concurrency handling (which is the responsibility
of the Scheduler-Layer-2; just the sequencing of individual activations
2023-08-30 22:19:57 +02:00
2746743135 Activity-Lang: invoke the configured Job-Functor
...this completes the basic setup
- Term builder mechanism working properly
- Memory allocator behaves sane
- the simple default wiring allows to invoke a Job
2023-08-29 19:10:24 +02:00
cda1cdd975 Activity-Lang: verify memory allocation and connectivity 2023-08-29 18:46:37 +02:00
80a48abcf4 Activity-Lang: determine role of the time window parameters 2023-08-29 16:40:52 +02:00
ae89831275 Activity-Lang: wire Job invocation in the activity::Term builder 2023-08-29 04:19:19 +02:00
e98fe1e78b Activity-Lang: scaffolding to create a simple Term 2023-08-29 03:18:47 +02:00
568957b75d Activity-Lang: prevent spurious activations after notification
Solved by special treatment of a notification, which happens
to decrement the latch to zero: in this case, the chain is
dispatched, but also the Gate is locked permanently to block
any further activations scheduled or forwareded otherwise
2023-08-23 01:03:11 +02:00
2f042ce6c0 Activity-Lang: cover all cases of Gate-behaviour
TODO: while correct as implemented, the handling of the
notification seems questionable, since re-scheduling the chain immediately
may lead to multiple invocations of the chain, since it might have been "spinned"
and thus re-scheduled already, and we have no way to find out about that
2023-08-22 20:13:13 +02:00
f1a446d85c Activity-Lang: notification settled and covered 2023-08-22 18:57:25 +02:00
4fed0b8cd2 Activity-Lang: clarify and fix behaviour of POST
...can not take a shortcut here, since the timing information
embedded into the POST-Activity must somehow be transported
to the Scheduler; key point to note is that the chain will
be performed in »management mode« (single threaded)
2023-08-22 18:38:40 +02:00
4c0e58849a Activity-Lang: define test cases for basic Activities 2023-08-22 17:37:58 +02:00
4e6ee0ec9c Activity-Lang: notification to Gate now working
...also diagnostics helper now able to trace notifications
...and additionally the Gate now triggers as planned
2023-08-21 18:23:57 +02:00
108a5e7ca5 Activity-Lang: work out activation-dispatch-notification sequence
...attempt to get this intricate state machine sorted out

Notification turned out quite tricky, since it may emanate
from a concurrently executed phase and we try to avoid having
to protect the gate directly with a lock; rather we re-dispatch
the notification through the queue, which indirectly also ensures
that the worker de-queuing the NOTIFY-Activity operates in
management mode (single threaded, holding the GroomingToken)
2023-08-21 17:32:52 +02:00
abc29eaa31 Activity-Lang: complete implementation for Gate (conditional)
Decision how to handle a failed Gate-check
- spin forward (re-scheduler) by some time amount
- this spin-offset parameter is retrieved from the Execution Context
- thus it will be some kind of engine parameter

With these determinations and the framework for the Execution Context
it is now possible to code up the logic for Gate check, which in turn
can then be verified by the watchGate diagnostics
2023-08-20 02:39:57 +02:00
8a85e57235 Activity-Lang: setup to watch a Gate-Activity
ouch... this becomes kindof convoluted,
due to the lack of dynamic extension points
2023-08-20 01:35:14 +02:00
f0d71672d8 Activity-Lang: allow to inject the activation detector
...by prepending it into existing wiring
2023-08-20 00:59:47 +02:00
7debaaca48 Activity-Lang: adaptor to watch existing Activity's activation
due to technical limitations this requires to wire the adaptor
as replacement for the subject Activity, so that it can capture
and log the activation, and then pass it on to its watched subject
2023-08-19 19:06:44 +02:00
d9f2909b07 Activity-Lang: simple activation working 2023-08-19 17:48:38 +02:00
3784bd7252 Activity-Lang: build activation detector
...using a HOOK-Activity as prepended adaptor,
optionally forwarding the activation to the inferior
2023-08-18 19:37:44 +02:00
9cdfdf3d18 Activity-Lang: activate a Job invocation
this verifies the most relevant core operation,
which is to trigger a job computation and pass arguments.
2023-08-18 16:54:35 +02:00
8c36e0a93b Activity-Lang: diagnostics for Activity and Execution Context 2023-08-18 16:25:09 +02:00
dd44373166 Activity-Lang: a way how to provide a faked Execution Context
...basically just delegated to DiagnosticFun instances,
yet the actual setup is somwewhat tricky to get right
2023-08-17 19:37:38 +02:00
1c6ee62c1a Activity-Lang: allow to verify invocation param in test
requires to supplement EventLog matching primitives
to pick and verify a specific positional argument.

Moreover, it is more or less arbitrary which job invocation parameters
are unpacked and exposed for verification; we'll have to see what is
actually required for writing tests...
2023-08-15 20:03:01 +02:00
161f604cbd Activity-Lang: setup a mocked JobFunctor for diagnostics
...now step by step building up the scaffolding
to build and verify Activity terms...
2023-08-15 18:52:51 +02:00
ab7f506f4b Activity-Lang: failure will certainly not be signalled to the Job
doing so would contradict the fundamental architecture,
all kinds of failures and timeouts need to be handled within
Scheduler-Layer-2 rather.

Jobs are never aborted, nor do they need to know if and when they are invoked
2023-08-15 17:18:30 +02:00
94528d67dc Activity-Lang: complete first test verification tool
...now able to verify that arbitrary functions have been invoked
...all of this is still preparatory work
2023-08-15 02:23:40 +02:00
e3f1aa4f7c Activity-Lang: support negative assertions for tests
Testcase (detect function invocation) passes now as expected


Some Library / Framework changes

- rename event-log-test.cpp
- allow the ExpectString also to work with concatenated expectation strings


Remark: there was a warning in the comment in event-log.hpp,
pointing out that negative assertions are shallow.

However, after the rework in 9/2018 (commit: d923138d1)
...this should no longer be true, since we perform proper backtracking,
leading to an exhaustive search.
2023-08-14 19:25:56 +02:00
25ad461a28 Activity-Lang: switch invocation detection to delegated matcher
ActivityMatch inherits privately from the EventMatch object,
and is thus able to delegate relevant matching queries, but
also to provide high-level special matchers.

This new design resolves the ambiguity regarding function arguments.
Moreover, we can now record the current sequence-Number as *attribute*
in the respective log record (this is the benefit of using structured
log entries instead of just a textual log), thereby avoiding the various
pitfalls with explicit bracketing sequence-number log entries

bottom line: this reworked design seems to be a better fit,
even while technically the implementation with the wrapped matcher
is somewhat ugly...
2023-08-14 02:05:13 +02:00
ff4acb04d7 Activity-Lang: investigate ways to verify invocation sequences
The EventLog seems to provide all the building blocks, but we need
some higher level special matchers (and maybe we also want to hide
some of the basic EventLog matchers). A soulution might be to wrap
the EventMatcher and delegate all follow-up builder calls.

This seems adequate, since the EventLog-Matcher is basically used as black box,
building up more elaborate matchers from the provided basic matchers...


Spent some time again to understand how EventLog matching works.

My feelings towards this piece of code are always the same: it is
somewhat too "tricky", but I am not aware of any other technique
to get this degree of elaborate chained matching on structured records,
short of building a dedicated matching engine from scratch.

The other alternative would be to use a flat textual log (instead of
the structured log records from EventLog), but then we'd have to
generate quite intricate regular expressions from the builder,
and I'm really doubtful it would be easier and clearer....
2023-08-13 20:49:30 +02:00
6e42e81546 Activity-Lang: draft invocation verification 2023-08-01 21:42:18 +02:00
49f2e34e4c Library: extract type rebinding helper
...turns out this is entirely generic and not tied to the context
within ActivityDetector, where it was first introduced to build a
mock functor to log all invocations.

Basically this meta-function generates a new instantiation of the
template X, using the variadic argument pack from template U<ARGS...>
2023-08-01 14:52:20 +02:00
db1adb63a7 Activity-Lang: draft a diagnostic helper
...for coverage of the Activity-Language,
various invocations of unspecific functions must be verified,
with the additional twist that the implementation avoids indirections
and is thus hard to rig for tests.

Solution-Idea: provide a λ-mock to log any invocation into the
Event-Log helper, which was created some years ago to trace GUI communication...
2023-07-31 21:53:16 +02:00
26c2e835c3 Activity-Lang: setup skeleton of the activation function
- complete spec of Activity processing
- define the invocation structure
- implement basic cases of activation
2023-07-30 22:06:06 +02:00
28b3900284 Block-Flow: final adjustments from performance test (closes: #1311)
Further extensive testing with parameter variations,
using the test setup in `BlockFlow_test::storageFlow()`

- Tweaks to improve convergence under extreme overload;
  sudden load peaks are now accomodated typically < 5 sec

- Make the test definition parametric, to simplify variations

- Extract the generic microbenchmark helper function

- Documentation
2023-07-22 06:07:35 +02:00
049ca833a0 Block-Flow: optimise parameters for performance
There seems to be a ''sweet spot'' for somewhat larger Epoch sizes around 500 slots.
At least in the test setup used here, which works with a load of 200 Frames / sec,
which is significantly over the typical value of 50fps (video + audio) for simple playback.

The optimisation of averaged allocation times can not be much improved **below 30ns**.

Overall, this can be considered a good result,
since this allocation scheme does way more than just allocate memory,
it also provides a means to track dependencies and lifecycle.

__For context__:
 - we should strive at processing one frame in ~ 10ms
 - for 10 Activity records per Frame, we currently use < 0.5 µs for
   memory and dependency management in the scheduler
 - this leaves enough room for the further administrative efforts
   (priority queue, job planning, buffer management)
2023-07-21 04:34:04 +02:00
2977076b7f Block-Flow: switch to using the reworked config
BUT -> +50% runtime in -O3  (+20ns)

Investigation seems to indicate
 - that the increased (+1 Epochs, 10 -> 11) moving average
   caused the Algo to perform worse (strong effect)
 - that the Optimiser has problems with boost::rational, which however
   yields only a minute effect (+5ns), and only on the critical path

The access via Meyers Singleton has no adverse effect,
rather the new setup gives a tiny benefit (46ns -> 37ns).
Surprisingly, the increased pre-allocation has no observable effect.
2023-07-20 21:47:18 +02:00
ca502aa826 Block-Flow: introduce config through a policy mix-in
...measured running time reproduced unaltered for -O3
2023-07-20 19:28:20 +02:00
5803fed544 Block-Flow: draft for re-arranged configuration
On the long run, there will be a central Render Engine parametrisation;
some parameters can even be expected to be dynamic; thus prepare the
BlockFlow allocator to fit in with this expectation
2023-07-20 16:46:54 +02:00
14a5200cc0 Block-Flow: more runtime observation and fine-tuning
For comparison: use individual managment by refcount.
This supports the conclusion that BlockFlow is more than just a
custom allocator; it also supports a non-trivial lifetime management,
and this comes at a cost.

Playing around with various load patterns uncovers further weak spots
in the regulation mechanism. As a remedy, introduce a stronger feed-back
and especially set the target load factor from 100% -> 90%
to add some headroom to absorb intermittent load peaks

Presumably ''much more observation and fine-tuning'' will be necessary
under real-world load conditions (⟹ Ticket #1318 for later)
2023-07-19 03:29:09 +02:00
c008858d8f Block-Flow: investigate, fix and fine-tune Epoch size control
- BUG: must prevent the Epoch size to become excessive low
- Problem: feedback signal should not be overly aggressive

Fine-Tuning:
- Dose for Overflow-compensation is delicate
- Moving average and Overflow should be balanced
- ideally the compensatory actions should be one order of magnitude
  slower than the characteristic regulation time

Improvement: perform Moving-Average calculations in doubles
2023-07-18 21:23:00 +02:00
c7d6f3e24c Block-Flow: Load-Test indicates problem in Epoch control
...leading to PATHETICALLY bad timing comparison
...it seems clear that the Epoch-Step went to zero
   (which was neither anticipated, nor protected against)

However, even individual heap allocations fare surprisingly well
under full optimisation; just they don't solve our problem with
tracking dependencies; the most simplest solution that would
also fulfil this requirement would be using shared_ptr
2023-07-18 01:59:17 +02:00
c1001064e3 Block-Flow: draft Load/Stress-Test
- use a midrange load scenario
- but play this at saturation level
2023-07-17 18:36:12 +02:00
a4365a24f8 Block-Flow: feed size regulation on clean-up
Generate a signal based on actual Epoch length and
observed fill ratio, assuming even distribution of load.
2023-07-17 04:32:10 +02:00
9d040dc49c Block-Flow: compute exponential moving average
..as a heuristic to regulate optimal Epoch duration;
when Epochs are discarded, the effective fill factor can be used
to guess an Epoch duration time, which would (in hindsight)
lead to perfect usage of storage space
2023-07-17 03:00:56 +02:00
bd353d768a Block-Flow: detect and react on Epoch overflow
..using a simplistic implementation for now: scale down the
Epoch-stepping by 0.9 to increase capacity accordingly.
This is done on each separate overflow event, and will be
counterbalanced by the observation of Epoch fill ratio
performed later on clean-up of completed Epochs
2023-07-16 20:47:39 +02:00
6d75a82932 Block-Flow: introduce backlink into AllocationHandle
further implementation makes clear that the AllocationHandle,
which is the primary usage front-end, has to rely both on
services of the underlying ExtentFamily allocator, as well
as on the BlockFlow itself for managing the Epoch spacing.
2023-07-16 18:03:27 +02:00
e4b74f3ae1 Block-Flow: handle Epoch overflow
...draft of control logic, does not work correct in all cases
2023-07-16 03:06:02 +02:00
dce65104aa Block-Flow: select suitable Epoch for new allocation 2023-07-15 21:37:58 +02:00
cb2ee9466b Block-Flow: add diagnostics and define further expectations
- fix a bug in IterExplorer: when iterating a »state core« directly,
  the helper CoreYield passed the detected type through ValueTypeBindings.
  This is logically wrong, because we never want to pick up some typedefs,
  rather we always want to use the type directly returned from CORE::yield()
  Here the iterator returns an Epoch&, which itself is again iterable
  (it inherits from std::array<Activity, N>). However, it is clear
  that we must not descent into such a "flatMap" style recursive expansion

- draft a simple scheme how to regulate Epoch lengths dynamically

- add diagnostics to pinpoint a given Activity and find out into which
  Epoch it has been allocated; used to cover the allocator behaviour
2023-07-15 18:54:59 +02:00
7167ad6d96 Block-Flow: define expected behaviour for Epoch association
...how new Activities are placed into Epochs, incl. overflow
2023-07-14 05:03:01 +02:00
d0fd7f32a9 Block-Flow: verify handling of Activity records within the Epoch 2023-07-14 01:51:00 +02:00
af8f84a72d Block-Flow: complete simple use case (see #1311)
- add preliminary deadline-check (directly instead of using the Activity)
- with this shortcut, now able to implement discarding obsoleted Epochs
- Iteration and use of the underlying `ExtentFamily` is also settled by now

💡 ''Implementation concept for the allocation scheme complete and validated''
2023-07-13 19:43:22 +02:00
5055ba7144 Block-Flow: rationalise iterator usage
...with the preceding IterableDecorator refactoring,
the navigation and access to the storage extents can now be
organised into a clear progression

Allocator::iterator -> EpochIter -> Epoch&

Convenience management and support functions can then be
pushed down into Epoch, while iteration control can be done
high-level in BlockFlow, based on the helpers in Epoch
2023-07-13 18:35:10 +02:00
946f7c17f7 Block-Flow: implement opening a new Epoch
..this is the most simple case, where no Epochs are opened yet
..add diagnostics to inspect alloc count and deadlines
..add accessors for the first/last underlying Extent
2023-07-13 04:41:58 +02:00
180c6b8d84 Block-Flow: define next steps to construct
...continue to proceed test-driven
...scheduler internals turn out to be intricate and cohesive,
   and thus the only hope is to adhere to strict testing discipline
2023-07-13 01:51:21 +02:00
18904e5b58 Block-Flow: completed implementation of low-level cyclic extent storage
..verified boundary cases for expansion while retaining addresses
of currently active extents...
2023-07-12 21:55:50 +02:00
824a626c2e Block-Flow: investigate proper working of on-demand allocation
Library: add "obvious" utility to the IterExplorer, allowing to
         materialise all contents of the Pipeline into a container

...use this to take a snapshot of all currently active Extent addresses
2023-07-12 19:19:41 +02:00
f5813a1f29 Block-Flow: veryfy proper handling of extent reuse
- use a checksum to prove that ctor / dtor of "content" is not invoked
- let the usage of active extents "wrap around" so that the mem block is re-used
- verify that the same data is still there
2023-07-12 04:53:30 +02:00
6409e0eb36 Block-Flow: implement iteration and expansion of ExtentFamily
The low-level allocator is basically implemented now,
but we still need to check thoroughly that the tricky
wrap-around and expansion logic behaves sane...
(see #1311)
2023-07-11 03:52:24 +02:00
3401f18c2c Block-Flow: consider usage in ActivityTerm and rectify iteration
Iteration should just yield an Reference to an Extent,
thereby hiding all details of the actual raw storage (char[]).
This can be achieved by usind a wrapper type around a pointer
into the managing vector; from this pointer we may convert
into a vector::iterator with the trick described here

https://stackoverflow.com/a/37101607/444796


Furthermore, continued planning of the Activity-Language,
basically clarified the complete usage scenario for now;
seems all implementable right away without further difficulties
2023-07-11 01:08:26 +02:00
c1b16349f2 Block-Flow: define next steps for implementation of low-level allocator 2023-07-09 04:03:02 +02:00
ccf0710903 Block-Flow: maintain an »Epoch« within the raw allocation Extent
- the idea is to use slot-0 in each extent for administrative metadata
- to that end, a specialised GATE-Activity is placed into slot-0
- decision to use the next-pointer for managing the next free slot
- thus we need the help of the underlying ExtentFamily for navigating Extents

Decision to refrain from any attempt to "fix" excessive memory usage,
caused by Epochs still blocked by pending IO operations. Rather, we
assume the engine uses sane parametrisation (possibly with dynamic adjustment)
Yet still there will be some safety limit, but when exceeding this limit,
the allocator will just throw, thereby killing the playback/render process
2023-07-09 01:32:27 +02:00
533112a4b0 Block-Flow: provide specialised ctor notation
...now able to create instances for all the relevant Activity verbs
2023-07-07 03:41:30 +02:00
f34ecafa1a Block-Flow: consider data storage for render activities
- decision to favour small memory footprint
- rather use several Activity records to express invocation
- design Activity record as »POD with constructor«
- conceptually, Activity is polymorphic, but on implementation
  level, this is "folded down" into union-based data storage,
  layering accessor functions on top
2023-07-06 16:35:42 +02:00
4ac995548a Block-Flow: identify required API operations
- decision how to handle the Extent storage (by forced-cast)
- decision to place the administrative record directly into the Extent

TODO not clear yet how to handle the implicit limitation for future deadlines
2023-07-05 15:12:20 +02:00
022d40a8cf Block-Flow: initial draft of ExtentFamily storage
using a simple yet performant data structure.
Not clear yet if this approach is sustainable

- assuming that no value initialisation happens for POD payload
- performance trade-off growth when in wrapped-state vs using a list
2023-07-04 04:42:53 +02:00
23a6fbdf4f Scheduler: investigate modes of operation
- analysis of Activity usage
- derive possible memory management schemes
- research regarding asynchronous IO
- decision regarding the memory management scheme
2023-07-03 18:40:37 +02:00
421a2ed49a C++17: some related clean-up 2020-02-21 23:55:09 +01:00
d3d7ea35ad Global-Layer-Renaming: fix remaining textual usages and IDs in the code
- most notably the NOBUG logging flags have been renamed now
 - but for the configuration, I'll stick to "GUI" for now,
   since "Stage" would be bewildering for an occasional user
 - in a similar vein, most documentation continues to refer to the GUI
2018-12-10 00:09:56 +01:00
02c5809707 Global-Layer-Renaming: adjust namespace qualification 2018-11-15 23:59:23 +01:00
555ca0bff9 Global-Layer-Renaming: rename namespaces 2018-11-15 23:55:13 +01:00
2d5ebcd5fa Global-Layer-Renaming: adjust header includes 2018-11-15 23:42:43 +01:00
6261779531 Global-Layer-Renaming: rearrange directories
backend -> vault
proc -> steam
gui -> stage
2018-11-15 23:28:03 +01:00