Commit graph

6120 commits

Author SHA1 Message Date
e98fe1e78b Activity-Lang: scaffolding to create a simple Term 2023-08-29 03:18:47 +02:00
8e20fa6de1 Activity-Lang: framework for building an Activity-Term
While the ''general direction'' seems clear, some in-depth
analysis was required to find out what information can reasonably
be expected to be available at this point.

The decision was made to shift the actual deadline calculation
into the Job-Planning altogether, assuming that a preliminary solution
based on data implicitly available there will be enough to implement
simple linear playback, while precise management of job start times
can be added in later, when observation of actual timing behaviour
is available...
2023-08-29 01:41:17 +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
b7641115fb Block-Flow: integrate actual Gate-implementation
Each Epoch in the memory manager holds a Gate in the first slot;
after the logic for Gate-activation is worked out now, we can switch
to using this actual logic to determine when an Epoch can be released
2023-08-21 17:20:47 +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
49435c8aca Activity-Lang: investigate / fix string conversion
...turns out that util::toString does not explicitly handle pointers differently,
for very good reasons; this function must always work, always produce a simple and
compact representation, and it must be possible to instantiate the template
and take a function reference (which precludes adding an overload for pointers)
2023-08-19 02:27:06 +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
111c05a1f9 Activity-Lang: introduce a callback hook
...primarily intended for testing,
but could be helpful as generic extension point later on...
2023-08-01 15:37:56 +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
4f29d436b3 Activity-Lang: draft patterns of execution
essentially define a concept how to ''perform'' render activities in the Scheduler.
This entails to specify the operation patterns for the four known base cases
and to establish a setup for the implementation.
2023-07-28 02:21:59 +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
d557c540bf Block-Flow: tweaks to get down on par with the standard heap allocator
... while this a comparison of apples and oranges, since the standard
heap allocator does not offer any dependency and lifecycle managmenet,
while the BlockFlow scheme developed here is much more complex and
offers a lifetime and dependency control specifically tailored to
the needs of the Scheduler.

Anyway, with the latest tweaks and refactorings, the test case
now shows averaged times per allocation on a comparable level
(both in the range of ~30ns)
2023-07-21 01:52:07 +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
bf35ae030c Block-Flow: remove instrumentation of size-control
(!this changeset could be of importance for future investigation!)
2023-07-18 21:26:26 +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