Commit graph

2445 commits

Author SHA1 Message Date
a20e233ca0 Library: now using controlled seed and replaced rand (closes #1378)
After augmenting our `lib/random.hpp` abstraction framework to add the necessary flexibility,
a common seeding scheme was ''built into the Test-Runner.''
 * all tests relying on some kind of randomness should invoke `seedRand()`
 * this draws a seed from the `entropyGen` — which is also documented in the log
 * individual tests can now be launched with `--seed` to force a dedicated seed
 * moreover, tests should build a coherent structure of linked generators,
   especially when running concurrently. The existing tests were adapted accordingly

All usages of `rand()` in the code base were investigated and replaced
by suitable calls to our abstraction framework; the code base is thus
isolated from the actual implementation, simplifying further adaptation.
2024-11-17 19:45:41 +01:00
693ba32c8e Library: sharpen criteria for detecting glitches
A deeper investigation revealed that we can show the result of glitches
for each relevant situation, simply by scrutinising the produced distribution.
Even the 64-bit-Variant shows a skewed distribuion, in spite of all numbers
being within definition range.

So the conclusion is: we can expect tilted results, but in many cases
this might not be an issue, if the result range is properly wrapped / clipped.
Notably this is the case if we just want to inject a randomised sleep into a multithreaded test setup

Build a self-contained test case to document these findings.
2024-11-16 19:34:37 +01:00
a0336685dc Library: investigate glitches when drawing concurrently
Further investigation shows that the ''data type used for computation'' plays a crucial role.
The (recommended) 64bit mersenne twister uses the full value range of the working data type,
which on a typical 64bit system is also `uint64_t`. In this case, values corrupted by concurrency
go unnoticed. This can be **verified empirically** : the distribution
of shifts from the theoretical mean value is in the expected low range < 2‰

However, when using the 32bit mersenne engine, the working data type is still uint64_t.
In this case a **significant number of glitches** can be shown empricially.
When drawing 1 Million values, in 80% of all runs at least one glitch and up to 5 glitches
can happen, and the mean values are **significantly skewed**
2024-11-16 13:30:22 +01:00
a15006d11a Library: investigate drawing random numbers concurrently
''In theory,'' the random number generators are in no way threadsafe,
neither the old `rand()`, nor the mersenne twister of the C++ standard.

However, since all we want is some arbitrarily diffused numbers,
chances are that this issue can be safely ignored; because a random
number computation broken by concurrency will most likely generate --
well, a garbled number or "randomly" corrupted internal state.

Validating this reasoning by an empiric investigation seems advisable though.
2024-11-16 04:52:58 +01:00
606669aa1b Scheduler: further investigation but no solution for the emergency-trigger
Last summer, I already identified a problmatic aspect
which could cause the Scheduler to fall idle without further notice:
5b62438eb4

Basically this situation should raise a **Scheduler-Emergency**,
but the only location where it can be easily detected is way down
in the implementation and has currently no clean way of signalling.
Moreover, how to handle a Scheduler-Emergency is likewise an open
question, an will in turn require even more cross-cutting notifications
and trigger actions somewhere at Render-Engine top-level.

By marking the location where this problem could be detected,
inadvertently I broke the SchedulerCommutator_test, which of course
must execute precisely this logic and check for the proper result.

Yet the problem as such is tricky and possibly far-reaching;
notably when processing long-running render jobs will reliably trigger
this situation — unless we establish additional dedicated control-logic
especially to cope with long-running jobs (opened #1382 for this topic)

__Bottom line__: we are far from addressing any of these issues right now,
and thus I reduced that failure to a warning message, so that at least
`SchedulerCommutator_test` passes again (it's not actually a defect there)
2024-11-16 00:55:10 +01:00
bf41474004 Library: investigate Scheduler test failures
...which turn out not to be due to the PRNG changes
 * the SchedulerCommutator_test was inadvertently broken 2024-04-10
 * SchedulerStress_test simply runs for 4min, which is not tolerated by our Testsuite setup

see also:
5b62438eb
2024-11-15 02:20:36 +01:00
7ed8486774 Library: rework detection of ''same object''
We use the memory address to detect reference to ''the same language object.''
While primarily a testing tool, this predicate is also used in the
core application at places, especially to prevent self-assignment
and to handle custom allocations.

It turns out that actually we need two flavours for convenient usage
 - `isSameObject` uses strict comparison of address and accepts only references
 - `isSameAdr` can also accept pointers and even void*, but will dereference pointers
This leads to some further improvements of helper utilities related to memory addresses...
2024-11-15 00:11:14 +01:00
766da84a62 Library: fix failed tests(1) -- Rational_test
Problems in `Rational_test` were caused by `#include' reorderings regarding ''rational'' and ''intgral'' numbers.

The actual root cause is the fact that `FSecs` is only a typedef,
which prevents us from providing a string conversion for rational numbers without ambiguity
2024-11-14 05:27:14 +01:00
0b9e184fa3 Library: replace usages of rand() in the whole code base
* most usages are drop-in replacements
 * occasionally the other convenience functions can be used
 * verify call-paths from core code to identify usages
 * ensure reseeding for all tests involving some kind of randomness...

__Note__: some tests were not yet converted,
since their usage of randomness is actually not thread-safe.
This problem existed previously, since also `rand()` is not thread safe,
albeit in most cases it is possible to ignore this problem, as
''garbled internal state'' is also somehow „random“
2024-11-13 04:23:46 +01:00
064484450e Library: adapt some existing usages to the convenience API 2024-11-12 22:35:54 +01:00
2883a8619f Library: investigate usage of rand() and consider replacement
As it turns out, by far margin we mostly use rand() to generate
test values within a limited interval, using the ''modulo trick''
and thus excluding the upper bound.

Looking into the implementation of the distributions in the
libStdC++ shows that ''constructing'' a distribution on-the-fly
is cheap and boils down to checking and then storing the bounds;
so basically there is no need to keep ''cached distribution objects''
around, because for all practical purposes these behave like free functions

What is required occasionally is a non-zero HashValue, and sometimes
an interval of floating-point number or a normal distribution seem useful.

Providing these as free-standing convenience functions,
implicitly accessing the default PRNG.
2024-11-12 21:10:14 +01:00
ce2116fccd Library: option to provide an explicit random seed for tests
* add new option to the commandline option parser
 * pass this as std::optional to the test-suite constructor
 * use this value optionally to inject a fixed value on re-seeding
 * provide diagnostic output to show the actual seed value used
2024-11-12 15:49:15 +01:00
cffa2cd6c2 Library: implement test access to hidden global RandomSequencer
this seems to be the ''classical problem situation''
where a »clean« Dependency-Injection would require to waste storage
for a pointer to the same global resource in each and every distinct test class.

Since the Test-Suite is effectively global — even more so now due to
the reliance on "the" global `RandomSequencer` (PNRG) — we'll have to
bite the bullet and access a global static variable hidden behind teh scenes.
2024-11-10 16:22:46 +01:00
c13d6d45f4 Library: add new API for random seeding
...to the base-class of all tests
 * `seedRand()` shall be invoked by every test using randomisation
   * it will draw a new seed for the implicit default-PRNG
   * it will document this seed value
   * but when a seed was given via cmdline, it will inject that instead
 * `makeRandGen()` will create a new dedicated generator instance,
   attached (by seeding) to the current default-PRNG

It is not clear yet how to pass the actual `SeedNucleus`, which
for obvious reasons must be maintained by the `test::Suite`
2024-11-10 04:40:39 +01:00
92bc044e9e Library: consider how to handle randomness in tests
Using random or pseudo-random numbers as input for tests
can be a very effective tool to spot unintended behaviour in
corner cases, and also helps writing more principled test verifications.
However, investigating failures in randomised tests can be challenging.

A well-proven solution is to exploit the **determinism** of pseudo-random-numbers
by documenting a randomly generated seed, that can be re-injected for investigation.

Up to now, most tests rely on the old library function `rand()`, while
at some places already the C++ standard framework for random number generation
is used, packaged into a custom wrapper. Adding adequate support for
documented seed values seems to be easy to achieve, after switching
existing usages of `rand()` to a suitable drop-in replacement.

After some consideration, I decided ''against'' wiring random generator instances
explicitly, while allowing to do so on occasion, when necessary. Thus
the planned seeding mechanism will rather re-seed a ''implicit default''
generator, which could then be used to construct explicit generator instances
when required (e.g. for multithreaded tests)

As a starting point, this changeset replaces the `randomise()` API call
by a direct access to the ''reseeding functionality'' exposed by the
C++ framework and all default generators. Since we already provide a
dedicated static instance of the plattform entropy source, re-randomisation
can be achieved by seeding from there.

NOTE: there was extended debate in the net, questioning the viability
of the `std::random_seq` -- these arguments, while valid from a theoretical
point of view, seem rather moot when placed into a practical context,
where even 2^32 different generation-paths(cycles) are more than enough
to provide sufficient diffusion of results (unless the goal is really to
engage into Monte-Carlo simulations for scientific research or large model
simulations).

Notable most of the more catchy reprovals raised by Melissa O'Neill
have been refuted by experts of the field, even while being still propagated
at various places in the net, often combined with promoting PCG-Random.
2024-11-10 03:25:45 +01:00
7960017403 Invocation: add some test coverage for the basic genrator function
Nothing surprising here...

Writing just some dull tests to avoid biting my nails while watching the US election....
2024-11-06 04:13:49 +01:00
c04a465134 Invocation: add some test-data manipulation functions
This is the first step towards a »Test Domain Ongology« #1372,
which is a systematic arrangement of test-dummy functionality assumed
to mirror the actual media processing functionality present in external libs.

Each media-processing library not only provides functions to crunch data,
but also establishes a framework of entities and classification to determine
what »media« is an how it is structured and can be generated, transformed
and qualified. Since a essential goal for Lumiera is to be **library agnostic,**
it is important to avoid naïvely to take some popular library's choices
as universal truth regarding structure and nature of »media« as such.
Rather, the architecture of the Lumiera Render Engine must be kept
sufficiently open to accommodate the working style of various libraries,
even ones not known today.

To validate this architectural openness, we use a set of test functions
unrelated to any existing library to validate access to and usage of
rendering functionality — followed by further steps to adopt existing
popular libraries like **FFmpeg** or **Gstreamer**, without tilting
the basic structure of the Render Engine one way or the other.
2024-11-05 21:23:13 +01:00
a84dbd7bfb Invocation: develop an abbreviated node spec
showing the Node-symbol and a reduced rendering of
either the predecessor or a collection of source nodes.

For this we need functionality to traverse the node graph depth-first
and collect all leaf nodes (which are the source nodes without predecessor);
such can be implemented with the help of the expandAll() functionality
of `lib::IterExplorer`. In addition we need to collect, sort and deduplicate
all the source-node specs; since this is a common requirement, a new
convenience builder was added to `lib::IterExplorer`
2024-11-05 03:56:38 +01:00
85e2966975 Invocation: implement deduplication of spec strings
* verify hash and identity of the generated `ProcID` records
 * also verify format of the generated Proc-Spec for a `Turnout`
2024-11-04 03:14:41 +01:00
53ac1911e7 Invocation: render a processing-spec for a port 2024-11-04 02:02:58 +01:00
5df93f01fc Invocation: pass symbolic spec through the node builder
...taking into account the prospecive usage context
where the builder expressions will be invoked from within
a media-library plug-in, using std::string_view to pass
the symbolic information seems like a good fit, because
the given spec will typically be assembled from some
building blocks, and thus in itself not be literal data.
2024-11-03 22:55:06 +01:00
4b6d812578 Invocation: provide access to a deduplicated ProcID
...as follow-up to yesterday's decisions
 - each Port will just feature a (stable) reference to a ProcID record
 - which is deduplicated and likewise refers to deduplicated symbolic tags
 - and further spec and hash values are computed on-demand by this entity

__Note__: all functionality belonging to the ''Builder'' can be assumed to run **non-concurrent**
2024-11-03 21:03:34 +01:00
f8642b3459 Invocation: consider how to establish a stable cache key
Building a precise Frame Cache is a tough job, and is doomed to fail
when attempting to tie cache invalidation to state changes. The only
viable path is to create a system of systematic tagging of processing
steps, and use this as foundation for chained hash values, linked
in accordance to the actual processing structure.

This is complicated by the secondary concern of maintaining memory efficacy
for the render node model, which can be expected to grow to massive scale.
And even while this invocation can not be fully devised right now,
an attempt can be made to build a foundation that is not outright
wasteful, by detaching the logical information from the specific
weaving pattern used for implementation, and by minimising the
representation in memory and computing the compound information
on-demand....
2024-11-03 03:06:54 +01:00
96d30cb5e7 Invocation: further considerations regarding diagnostics
Requirement analysis indicates that a »Node ID« is rather tangential
to the core operation of calculating media; the only infliction point
seems to be the generation of ''systematic cache keys.''

A spec — especially for the `Turnout` however is very relevant for
diagnostics, error reporting and unit testing. So we are in the
difficult situation where rather elaborate functionality is
required only for a secondary concern, and moreover the
node data structure imposes a critical memory leverage.
2024-11-02 02:57:35 +01:00
aab8278579 Invocation: Analysis regarding node and turnout identity
The immediate next goal is to verify properties of render nodes
generated by the builder framework; two kinds of validations
can be distinguished
 * structural aspects of the wiring
 * the fact that processing functionality is invoked in proper order

Looking into the structural aspects brings about the necessity
to identify the actual processing function bound into some functor.
Some recapitulation of goals and requirements revealed, that this
can not be a merely technical identity record — because the intention
is to base the ''cache key'' on chained processing node identities,
so that the key is stable as long as the user-visible results will be
equivalent. And while structural data can be aggregated, at the
core this information must be provided by the scheme embedded
into the domain ontology, which is tasked with invoking the
builder in order to implement a ''specific processing-asset''
2024-11-01 03:51:53 +01:00
9022a69a71 Invocation: simplest render-node test PASS
Review the achievements from the last days and map out the further path
for test-driven build-up of a render-node network and invocation.

Notably ''several layers of prototyping'' are in the works now;
it is important to understand the purpose of each such round of
prototyping and to draw the necessary conclusions after closing out.

The next topic to investigate relates to the ''identity'' of nodes and
ports within nodes; this entails to generate a ''symbolic spec'' that
can be verified and used as base for a systematic hash-ID and cache-key...
2024-10-27 02:45:15 +02:00
c29c10fd62 Invocation: runtime error checks for auto-wiring
Since it would in fact be possible to access and write beyond the configured storage,
simply by using the builder API without considering consistency,
it seems advisable to use explicit runtime checks here, instead of
only assertions, and to throw an exception when violating bounds.

Moreover, unsuccessfully attempted to better arrange the functionality
between PortBuilder and WeavingBuilder; seemingly we have an rather tight
coupling here, and also the expectations regarding the processing function
seem to be too tight (but that's the reason why it's an prototype...)
2024-10-26 04:11:36 +02:00
d91d0b5926 Invocation: provide functionality to connect lead ports explicitly
...which then also allow to fill in the missing parts for the
default 1:1 wiring scheme, which connects each »input slot«
of the processing function with the corresponding ''lead node''
2024-10-25 18:13:55 +02:00
43373e11e7 Invocation: prepare mechanism for default input wiring
The intention is to offer an automatic 1:1 association
between the »input parameter slots« of the processing function
and the ''lead nodes,'' thereby always using the same default
port, corresponding to the current port number under construction.

Unfortunately, the preceding refactoring removed the information
necessary for a simple implementation, as the port array is now
built up late, in the final build() function...
2024-10-25 05:10:16 +02:00
0144049f9d Invocation: reconsider data access and allocator usage from Builder
The next step is to round out the first prototypical implementation,
which requires access to ''lead node ports'' and thereby generally
places focus on the interplay of ''data builders'' within the ongoing
build process. While the prototype still uses the fall-back to simple
heap allocation, notably the intended usage will require to wire-through
the connection to a single `AllocationCluster`. This poses some
challenge, since further ''data builders'' will be added step-wise,
implying that this wiring can not be completed at construction time.

Thus it seems indicated to slightly open-up the internal allocator
policy base template used by `lib::SeveralBuilder` to allow for some
kind of ''cross building'' based on a shared compatible base allocator
type, so that the allocation policy wiring can be passed-on from an
existing `SeveralBuilder`
2024-10-23 16:27:09 +02:00
554a64e212 Invocation: solve passing of the function definition
- the chaining constructor is picked reliably when the
  slicing is done by a direct static_cast

- the function definition can be passed reliably in all cases
  after it has been ''decayed,'' which is done here simply by
  taking it by-value. This is adequate, since the function
  definition must be copied / inlined for each invocation.

With these fixes, the simplest test case now for the first time
**runs through without failure**
2024-10-22 05:59:00 +02:00
df37fec500 Invocation: switch WeavingBuilder to produce the result via λ
This change allows to disentangle the usages of `lib::SeveralBuilder`,
so that at any time during the build process only a single instance is
actively populated, all in one row — and thus the required storage can
either be pre-allocated, or dynamically extended and shrinked (when
filling elements into the last `SeveralBuilder` currently activated)

By packaging into a λ-closure, the building of the actual `Port`
implementation objects (≙ `Turnout` instances) is delayed until the
very end of the build process, and then unloaded into yet another
`lib::Several` in one strike. Temporarily, those building functor
objects are „hidden“ in the current stack frame, as a new `NodeBuilder`
instance is dropped off with an adapted type parameter (embedding the
λ-type produced by the last nested `PortBuilder` invocation, while
inheriting from previous ones.

However, defining a special constructor to cause this »chaining«
poses some challenge (regarding overload resolution). Moreover,
since the actual processing function shall be embedded directly
(as opposed to wrapping it into a `std::function`), further problems
can arise when this function is given as a ''function reference''
2024-10-22 03:20:50 +02:00
0de7905444 Invocation: introduce pattern data holder into NodeBuilder
- add an unspecified data holder type into the NodeBuilder
- establish ability to cross-build a `NodeBuilder` with adapted data holder
2024-10-21 04:40:51 +02:00
b4aee6fba8 Invocation: work out solution for a precisely fitting allocation
Conduct in-depth analysis to handle a secondary, implementation-related
(and frankly quite challenging) concern regarding the placement of node
and port connectivity data in memory. The intention is for the low-level
model to use a custom data structure based on `lib::Several`, allowing for
flexible and compact arrangement of the connectivity descriptors within
tiled memory blocks, which can then later be discarded in bulk, whenever
a segment of the render graph is superseded. Yet since the generated
descriptors are heterogeneous and, due to virtual functions, can not be
trivially copied, the corresponding placement invocations on the
data builder API must not be mixed, but rather given in ordered strikes
and preceded by a dimensioning call to pre-reserve a bulk of storage

However, doing so directly would jeopardise the open and flexible nature
of the node builder API, thereby creating a dangerous coupling between
the implementation levels of the node graph and of prospective library
wrapper plug-ins in charge of controlling details of the graph layout.

The solution devised here entails a functional helper data structure
created temporarily within the builder API stack frames; the detailed
and local type information provided from within the library plug-in
can thereby be embedded into opaque builder functors, allowing to
delay the actual data generation up until the final builder step,
at which point the complete number and size requirements of
connectivity data is known and can be used for dimensioning.
2024-10-20 21:52:00 +02:00
634df743f0 Invocation: investigate Problems with allocation-growing
This investigation was set off by a warning regarding an
unused argument in `SeveralBuilder`, using `AllocationPolicy::moveElem()`
This warning is correct and easy to fix, but (luckily) it brought my
attention to the fact that a `SeveralBuilder<Port>` can not grow dynamically,
which is somewhat mitigated by the default policy to pre-allocate several
elements, which would work to some degree but waste a lot of memory.

This points to a deeper problem with the implementation pattern used for
all those Builders: they create their product by-value, which must then
be moved into the intended target location.
And doing so is **extremely dangerous**, given that our very goal is to
build a complex data structure internally connected by direct references
and ideally also allocated with a high degree of memory locality.

Unfortunately I do not see any favourable alternative yet;
Ideally all products should be `NonCopyable` — but then, the builder
implementation scheme would become even more complicated and less intuitive
and additionally the client code would need to pre-declare the number of
expected Leads and Ports (not clear if this is even feasible)
2024-10-14 18:29:29 +02:00
4a963c9fee Invocation: draft how the 1:1-fallback wiring could work
...and as expected, this turns up quite some inconsistencies,
especially regarding usage of the »buffer types«.

Basically, the `PortBuilder` is responsible for the high-level functionality
and thus must ensure the nested `WiringBuilder` is addressed and parameterised
properly to connect all »slots« of the processing function.
 - can use a helper function in the WiringBuilder to fill in connections
 - but the actual buffer types passed over these connectinos are totally
   unchecked at that level, and can not see yet how this danger can be
   mitigated one level above, where the PortBuilder is used.
 - it is still unclear what a »buffer type« actually means; it could
   be the pointer type, but it could also imply a class or struct type
   to be emplaced into the buffer, which is a special extension to the
   `BufferProvider` protocol, yet seems to be used here rather to transport
   specific data types required by the actual media handling library (e.g. FFmpeg)
2024-10-14 04:07:47 +02:00
4df4ff2792 Invocation: consider minimal test setup and verification
__Analysis__: what kind of verifications are sensible to employ
to cover building, wiring and invocation of render nodes?
Notably, a test should cover requirements and observable functionality,
while ''avoiding direct hard coupling to implementation internals...''

__Draft__: the most simple node builder invocation conceivable...
2024-10-13 03:49:01 +02:00
bb9d0107cd Invocation: setup preliminary engine-context
* decision how to provide a default service for tests
   while also allow for configuration of more specific services
 * as starting point for the prototype: use the `TrackingHeapBlockProvider`
   (simply because this is the only implementation available and tested)
2024-10-12 04:17:39 +02:00
4a83f97c9e Invocation: draft setup for engine context and config
Prototyping and analysis revealed that some aspects of the render node wiring
refers to effectively global services and can thus be taken out of the picture
by relying on classical ''Dependency Injection''

Consequently, `EngineCtx` needs a default implementation, which brings up
a simplistic fall-back version of those services in support for prototyping.
Moreover, dedicated lifecycle functionality must be provided to bring up
and shut down the actual service instances intended for operational use.
2024-10-11 16:57:10 +02:00
a02873a015 Invocation: pass the actual processing function
...need to pass a binding for the actual processing function
in a way that it acts as a ''prototype'' — since the `Feed`,
i.e. the ''Invocation Adapter'' must be generated for each
invocation anew within the current stack frame
(so to avoid spurious heap allocations)
2024-10-11 04:39:40 +02:00
9490192ef8 Invocation: integrate WeavingBuilder into PortBuilder
...seems that the former is well suited to serve as detail builder
used internally by the latter to provide a simplified standard adaptation
for a given processing function.

The integration can be achieved to layer a specialised detail builder class
on top, which can be entered only by specifying the concrete function or lambda
to wrap for the processing; the further builder-API-functions to control
the wiring in detail become thus only accessible after the function type
is known; this allows to place the detail builder as member into the
enclosing port builder and thus to allocate everything within the current
stack frame invoking the builder chain.
2024-10-11 02:45:51 +02:00
5f0b8b8a81 Invocation: usage analysis for prototype
...after having determined the several levels of prototyping
currently employed, an important step ahead could be achieved
by analysing the intended and implied usage context of this
builder scheme, while still assuming the simplifications
related to prototyping.

It can be assumed that
 * the Level-2 builder object is ''somehow provided''
 * the invocation happens from within a media-handling lib-plugin
 * alongside with the desired `ProcAsset` spec, an `ExpectationContext`
   will be provided, allowing to pass-through additional semantic tags

The implementation in the lib-plugin is then able to draw from specific
knowledge related to the **Domain Ontology** for ''especially for this library''
and provide the necessary wrappers and parameter mapping information.

⟹ the **Level-2**-builder should thus expose an API to
 * set up a straight forward mapping, based on a given wrapper functor
   to delegate to the actual library invocation
 * allow optionally to override some of the input connections
 * alternatively allow to use a complete `InvocationAdapter`,
   including a `FeedManifold`, as provided directly by the library-plugin
2024-10-10 21:35:02 +02:00
bad6751aae (after extended break)
...caused by personal circumstances
...attempt to understand the context I was working on

 * Integration is driven by the `NodeLinkage_test`
 * the near-term goal is to ''get any node built'' — simplified
 * the outline of the `NodeBuilder` and `PortBuilder` is settled
 * the task at hand is how to fill in the definition of a `Port`
 * which in turn ''requires prototyping'' — to establish a kind of weaving-pattern
 * the immediate next thing to do is to ''build an `InvocationAdapter` within the »test-ontology«''
2024-10-09 03:48:18 +02:00
409f2f20b8 Invocation: introduce engine-context for dependency injection
...by relying on DI for some effectively global services, notably
the cache provider, the API for building and wiring render nodes
can be simplified to cover only the actual node connectivity
2024-08-03 03:21:59 +02:00
38dd3a738e Invocation: introduce optional output buffer
Doing so directly seems to be a better solution than to inject an OutputBufferProvider;
the latter will still be needed, yet will not be part of the regular weaving pattern,
but used directly at top-level to obtain the output `BuffHandle`, which is then
passed to the `Port::weave()` call
2024-07-31 19:20:44 +02:00
4bda550f68 Invocation: investigate ways to configure the output-info
...still not convinced that this is a good design,
since it seems to subvert the general design to treat one special case.
However, I can't see a good way to address this special case directly
2024-07-30 23:44:55 +02:00
a4ff2081b9 Invocation: explore variants to pass output connection
There might be one specific output result buffer at top level
for each invocation, which must be delivered into a prepared
output sink. This amounts to one special case, cross-cutting
an otherwise completely generic data flow scheme.

After considering several solutions, it seems most straight-forward
to configure a specific `OutputBufferProvider` to serve as a proxy for
the `OutputSlot` / `DataSink` provided at top-level to the Render-Job.

As an asside, this analyis reveals that the result-slot number does
not belong into the `FeedManifold`, which is dynamic (on the stack);
rather, it's a fixed value configured as part of the `WeavingPattern`
2024-07-30 20:05:48 +02:00
9a23aa773b Invocation: analyse usage of buffer metadata entries
Code clean-up: mark all buffers with a dedicated tagging type


The point in question is: if we work the LocalTag into the type-hash,
could it be possible to miss an existing entry in the metadata registry?
This could cause two entries to be locked for a single buffer address,
leading to data corruption.

As far as I can see, in the current usage this would not happen,
but unfortunately this problem can not be ruled out, since the BufferProvider
API and protocol is designed to be open for various usage patterns.

However, the same potentially disastrous pattern could also materialise
when registering two different buffer types, and then locking each
for the same buffer location.
2024-07-28 19:29:27 +02:00
72c7386435 Invocation: apply a consistent ordering on the chained hash calculation
...this seems to be a tricky aspect; we use hash-chaining to create
derived entries, which may cause the identity of an entry to depend
on the order of specialisation. Looked through the possible code paths,
but these seem to be quite complicated; I see the lurking danger of
creating a second entry (with a different hash), and then in worst case
even locking/unlocking a given buffer twice....
2024-07-27 23:53:27 +02:00
6d7a814495 Invocation: settle upon a way to mark the output buffer
...this is a surprisingly tricky issue, since it undercuts the
generic and recursive implementation of buffer handling;

fortunately I've foreseen such demands may arise down the road
and I've reserved an »Local Key« (now renamed into `LocalTag`),
whose meaning is implementation defined and interpreted by
the specific `BufferProvider`
2024-07-27 17:17:02 +02:00
ea183086ca Invocation: Prototyping to clarify buffer type marking
Requirement analysis shows that the ''actual buffer provider'' to use
constitutes yet another independent degree of freedom, which conceivably
must be handled by the Builder internals rather than by the Domain Ontology.

Thus the simple solution to use a `BuffDescr` to mark the type must be augmented
to also allow configuration of the underlying `BufferProvider`, which generates
the descriptor and can later be invoked with this descriptor to ''lock  an actual Buffer.''

In some cases, setup of the buffer types could even be more complicated and require
access to the actual (runtime) invocaton context; such extreme cases however
could be rendered as an extension of the scheme established here,
by storing the (up to now transient) constructor functors persistently.
Which leads to the decision not to care for those extremely complicated
corner cases right now, and thus to construct all buffer descriptors
in the `build()` call
2024-07-24 20:29:37 +02:00
42f8f8d5af Invocation: Prototyping how to setup invocation wiring
...still fighting to find a suitable API to define
how inputs and outputs are connected and mapped to function parameters.

The solution drafted here uses the reshaped `DataBuilder` (≙`lib::SeveralBuilder`)
to add up connections for each »slot«, disregarding the possibility of permutations.
Similar to `NodeBuilder`, a policy template is used to pass down the setup
for an actual custom allocator.
2024-07-24 03:52:44 +02:00
352ef31ab0 Invocation: further condense the allocator-selector definition
After applying all the preceding refactorings, it turns out that
the `DataBuilder` defined here ''is essentially `lib::SeveralBuilder`'',
only with a different arrangement of the type parameters, due to the
specific usage context here.

It is thus possible to replace all the interim / helper / rebinding templates
by simple templated typedefs. The only tangible difference is that for
usage in the Builder, a ''selector policy'' is passed as a simple type argument,
which in practice wires the concrete allocator information down into each
sub-builder created during the ongoing construction of a node structure.
2024-07-23 02:38:06 +02:00
1705c40dc2 Invocation: rearrange SeveralBuilder policy
redefine the policy for `lib::SeveralBuilder` to be a template-template parameter.
In fact it should have been this way from start, yet defining this kind of
very elaborate code bottom-up lets you sometime miss the wood for the trees

So to restate: `lib::SeveralBuilder` takes a ''policy template,''
which then in turn will be instantiated with the same types `I` (interface)
and `E` (element type) used on `SeveralBuilder` itself. Obviously, there can be
further types involved and thus additional type parameters may be necessary,
notably the ''Allocator'' — yet these are better injected when ''defining''
the policy template itself.

The default binding for this policy template is defined as `allo::HeapOwn`,
which causes the builder to allocate the storage extents through the standard
heap allocator, and for the created `lib::Several` to take full ownership of
embedded objects, invoking their destructors when falling out of scope.
2024-07-17 01:43:17 +02:00
2fd3629d80 Invocation: difficulties with defining a suitable DataBuilder
As a direct consequence of the insights regarding Dependency-Injection,
a ''Builder Toolkit'' is required, which can be used to adapt various
kinds of ''Weaving Patterns'' — since obviously it is not possible to
settle down on a single Pattern, and thus several ''families of builders''
will emerge, one for each ''line of construction'' for ''Weaving Patterns''.

To stress this point, what I am coding here is a prototype, aimed at
being used as part of a **Test Domain Ontology** — and other Domain Ontologies
(e.g. für FFmpeg) will certainly require other construction schemes
for their Weaving Patterns. So this is an open field, and can not be
settled once and for all.

This immediately leads to another, rather technical problem:
If we're about to work with ''delegate Builders,'' then also
a way to pass-down the allocator configuration is required.

We had settled on a preliminary solution with the helper `DataBuilder`,
yet this solution looks like it defines how `lib::SeveralBuilder`
should be used in most of the cases. So there is now a conflict
between the existing definition scheme for `lib::SeveralBuilder`,
which was achieved in a bottom-up way, and a slightly different
definition scheme ''as it should be''

Starting to attack this latter detail problem, as a first step,
the definition of `DataBuilder` can be simplified by collapsing
it with the `lib::allo::SetupSeveral`
2024-07-17 02:35:05 +02:00
fc9ff9252a Invocation: clarify role of Buffer-Descriptor and Dependency-Injection
It became clear that a secondary system of connections must be added,
running top-down from a global model context, and thus contrary to the
regular orientation of the node network, which connects upwards from
predecessor to successor, in accordance with the pull principle.

If we accept this wiring as part of the primary structure, it can be
established immediately while building the nodes, thus adding a preconfigured
''pattern of Buffer Descriptors'' to each node, since there is no further
''moving part'' — beyond the wiring to the `BufferProvider`, which thus
becomes part of a global `ModelContext`

As an immediate consequence, the storage for this configuraion should
also be switched to `lib::Several` and handled similar to the primary
node wiring in the Builder...
2024-07-15 18:52:59 +02:00
968bfb8fab Invocation: look for ways how to build the Turnout
It seems we need a `WeavingPattern`-Builder, which obviously
must be rather flexible, since those patterns are to be composed
from several layers, which should be extensible within a given ''Domain Ontology''

So this seems to lead to a builder-DSL which creates »**onion layers**«
of builders, with the ability to extend and specialise the type on each layer.

''As it will be quite challenging to get this into usable shape,
it seems best to approach this step by step through prototyping...''
2024-07-15 02:26:53 +02:00
95046489d2 Invocation: release buffer after completed calculation
Not entirely sure how to use the `emit()` call properly,
assuming that it means that data is complete in buffer,
but can still be read after that point
2024-07-15 00:36:20 +02:00
133dd9e8ce Invocation: now able to implement connecting of buffers
* at least for a simple, prototypical setup
 * and actually shifting the onerous into the Level-1 builder \\
   ''(which is precisely the intention here)''
2024-07-12 03:06:11 +02:00
1955d28087 Invocation: use introspection to setup an example
The deeper problem is that we must not engage into any premature decisions
regarding the structure or layout of the actual processing function invocation.

Thus attempting to create a kind of »firewall« of sorts, by connecting
the building blocks strictly through template parameter and preferably
figuring out any detailed knowledge locally, through ''compile-time introspection...''
2024-07-11 18:35:17 +02:00
e7b68427d3 Invocation: look for ways to build an example InvocationAdapter
...even the initial effort to stub its operation turns into a
challenge, since honestly there is near nothing we can assume safely,
without sliding into uncovered provisions regarding the ''Domain Ontology''
2024-07-11 16:31:11 +02:00
0d7d4b5afa Invocation: consider how to arrange the InvocationAdapter
- it is clear that this adaptor will be a ''Concept''
- yet it must in some way access the `FeedManifold` and also control additional storage
- a rather obvious solution is to layer it ''on top'' of the manifold
2024-07-11 02:41:33 +02:00
ec65e2b7b9 Invocation: continue draft of a simple 1:1 WeavingPattern
...which brings about various (preliminary) decisions regarding
Metadata storage in the `Turnout`-object, which acts as a guidance
and specification for the actual invocation for this specific node.

As starting point, I choose the ''KISS'' solution of embedding some
blocks of `UninitialisedStorage` directly into the `Turnout`; obviously
these blocks must be oversized, since we can not effort emitting a
dedicated template instance for each different count of input / output
feeds. Moreover, these data buffers are assumed to be filled with
valid objects by the builder ''(this is a lurking danger)''
2024-07-10 03:35:51 +02:00
0b938320ea Invocation: draft a simplified prototype for an invocation
...attempt to somehow get my foot into the door...
2024-07-09 21:06:38 +02:00
3d6515acca Invocation: further analysis of invocation structure
...turns out that the intended structure is still too fine grained
and explicit and many operational steps can be collapsed into a single
virtual scope, wherein they can be deemed implementation detail...
2024-07-09 18:03:13 +02:00
d09b061434 Invocation: add nested builder to configure a port
...which brings us right into the middle of the task of building a Turnout...
2024-07-08 19:24:03 +02:00
d3344e7dd3 Invocation: improve notation by using a wrapper
...so the solution is to build up the working data as `lib::SeveralBuilder`;
however, a more concise notation can be achieved with a suitably configured
wrapping subclass; together with the cross-builder trick, this allows
to write the allocation configuration in a clearly libelled way,
while the field definition and the builder constructor hides the
complexities of picking up the extension point and passing on the
wiring to the allocator instance.
2024-07-08 05:41:31 +02:00
cedb1830dc Invocation: work out solution for builder initialisation
...turns out to be surprisingly tricky, since the nested
lib::SeveralBuilder instances require parametrisation by a
''policy template,'' which in turn relies on the actual allocator.
And we want to provide the allocator as a constructor parameter,
including the ability to pick up a custom specialisation for
some specific allocator (notably AllocationCluster requires
to hook into this kind of extension point, to be able to
employ its dedicated API for dynamic allocation adjustment)
2024-07-08 03:56:38 +02:00
b01fc6e350 Invocation: adjustments to lib::Several to prepare for allocator use
* conduct analysis regarding allocator handling in the Builder
 * turns out we'll have to keep around two different allocators while building
 * ⟹ establish the goal to confine usage of the Node allocator to the lower Levels
 * consequently must open up the `lib::SeveralBuilder` to be usable
   as an intermediary data structure, while building up the target data
 * in the initial design, the `SeveralBuilder` was kept opaque, since
   contents can be expected to be re-located frequently and thus exposing
   elements and taking references could be dangerous — yet this is also
   true for `std::vector` however, so people are assumed to know
   when they want to shoot themselves into their own foot
2024-07-07 16:12:22 +02:00
58a955a879 Invocation: first draft of the node builder invocation 2024-07-06 21:31:03 +02:00
7c554caf08 Invocation: clarify further requirements for the Level-2 builder
...especially what is necessary to represent at this level and what information
is implicit; notably there will be an implicit default wiring, but we allow
for case-by-case deviations
2024-07-06 04:37:36 +02:00
1f7ddbe5ec Invocation: draft possible syntactic structure based on these conjectures
The Builder will have to perform several passes, gradually refining
the model into the low-level Render Node network. Right now, some
guesses regarding the last steps of this process are possible,
thus defining the lowest level of a model builder structure
 * Level-3 : mapping data flow paths
 * Level-2 : detailed configuration of data buffer passing
 * Level-1 : build the actual parameter structures for invocation

In the current »Vertical Slice« we're able to fully define Level-1
and maybe Level-2
2024-07-06 01:28:18 +02:00
ce9bf7f143 Invocation: conjectures pertaining an implementation of Node-Graph generation
To escape a possible deadlock in analysis, I resort to developing
some kind of free-wheeling presupposition how the **Builder** could
be implemented — a centrepiece of the Lumiera architecture envisioned
thus far — which ''unfortunately'' can only be planned and developed
in a more solid way ''after'' the current »Vertical Slice« is completed.

Thus I find myself in the uncomfortable situation of having to work towards
a core piece, which can not yet be built, since it relies heavily on
the very structures to be built...
2024-07-06 01:13:23 +02:00
604c4b580b Invocation: painstaking analysis of calculation requirements
...the complexity of details is a nightmare
...still fighting to grasp a generic structure allowing to ''fold down''
   the details into the specific ''domain ontologies'' for the media libraries
2024-07-03 04:34:04 +02:00
8c536fc637 Invocation: consider what is required to setup a FeedManifold
...and this line of analysis brings us deep into the ''Buffer Provider''
concept developed in 2012 — which appears to be very well to the point
and stands the test of time.

Adding some ''variadic arguments'' at the right place surprisingly leads
to an ''extension point'' — which in turn directly taps into the
still quite uncharted territory interfacing to a **Domain Ontology**;
the latter is assumed to define how to deal with entities and relationships
defined by some media handling library like e.g. FFmpeg.
So what we're set to do here is actually ''ontology mapping....''
2024-06-29 04:22:23 +02:00
717af81986 Invocation: Identify parts relevant for a node builder
The immediate next step is to build some render nodes directly
in a test setting, without using any kind of ''node factory.''
Getting ahead with this task requires to identify the constituents
to be represented on the first code layer for the reworked code
(here ''first layer'' means any part that are ''not'' supplied
by generic, templated building blocks).

Notably we need to build a descriptor for the `FeedManifold` —
which in turn implies we have to decide on some fundamental aspects
of handling buffers in the render process.

To allow rework of the `ProcNode` connectivity, a lot of presumably obsoleted
draft code from 2011 has to be detached, to be able to keep it in-tree
for further reference (until the rework and refactoring is settled).
2024-06-25 04:54:39 +02:00
9f233f1e90 Invocation: Detail-planning of node invocation
* consider which operations to provide where
 * collect components to be built for a basic node wiring
 * define an entrance point for node invocation
2024-06-23 19:40:43 +02:00
17dcb7495f Invocation: establish a concept for the rework
As outlined in #1367, the integration effort requires some rework
of existing code, which will be driven ahead by the `NodeLinkage_test`
 * redefine Node Connectivity
 * build simple `ProcNode` directly in scope
 * create an `TurnoutSystem` instance
 * perform a ''dummy Node-Invocation''
2024-06-21 16:22:58 +02:00
f632701f48 Library: lib::Several complete and tested (see #473)
As a replacement for the `RefArray` a new generic container
has been implemented and tested, in interplay with `AllocationCluster`
 * the front-end container `lib::Several<I>` exposes only a reference
   to the ''interface type'' `I`, while hiding any storage details
 * data can only be populated through the `lib::SeveralBuilder`
 * a lot of flexibility is allowed for the actual element data types
 * element storage is maintained in a storage extent, managed through
   a custom allocator (defaulting to `std::allocator` ⟹ heap storage)
2024-06-19 19:40:03 +02:00
cf6abf6a3b Library: observe allocator limits on exponential expansion
The `SeveralBuilder` employs the same tactic as `std::vector`,
by over-allocating a reserve buffer, which grows in exponential
increments, to amortise better the costs of re-allocation.

This tactic does not play well with space limited allocators
like `AllocationCluster` however; it is thus necessary to provide
an extension point where the actuall allocator's limitation can be
queried, allowing to use what is available as reserve, but not more.

With these adaptations, a full usage cycle backed by `AllocationCluster`
can be demonstrated, including variations of dynamic allocation adjustment.
2024-06-19 17:35:46 +02:00
39e9ecd90e Library: AllocationCluster and SeveralBuilder logic tweaks
...identified as part of bug investigation

 * make clear that reserve() prepares for an absolute capacity
 * clarify that, to the contrary, ensureStorageCapaciy() means the delta

Moreover, it turns out that the assertion regarding storage limits
triggers frequently while writing the test code; so we can conclude
that the `AllocationCluster` interface lures into allocating without
previous check. Consequently, this check now throws a runtime exception.

As an aside, the size limitation should be accessible on the interface,
similar to `std::vector::max_size()`
2024-06-19 15:45:12 +02:00
9709309186 Library: setup adaptor for dynamic adjustments
By means of the extension point, which produces a dedicated policy
for use with `AllocationCluster`, it becomes possible to use the
specialised API to adjust the latest allocation in the cluster.
When this is not actually usable, the policy will fall back
on the standard implementation (which is wasteful when
applied to `AllocationCluster`, since memory for the
obsoleted, smaller blocks not de-allocated then...
2024-06-19 03:26:36 +02:00
7d066a85ee Library: now use AllocationCluster as custom allocator
* this validates usage of the extension point
 * however, there is no special treatment yet,
   and thus a re-alloc leves the previoius block as waste
2024-06-19 01:29:46 +02:00
aacea3c10a Library: lib::Several container now passes test with TrackingAllocator
- decided to allow creating empty lib::Several;
  no need to be overly rigid in this point,
  since it is move-assignable anyway...

- populate with enough elements to provoke several reallocations
  with copying over the existing elements
- precisely calculate and verify the expected allocation size
- verify the use-count due to dedicated allocator instances
  being embedded into both the builder and hidden in the deleter
- move-assign data
- all checksums go to zero at end
2024-06-18 19:09:21 +02:00
50306db164 Library: more stringent deleter logic
The setup for `ArrayBucket` is special, insofar it shell de-allocate itself,
which creates the danger of re-entrant calls, or to the contrary, the danger
to invoke this clean-up function without actually invoking the destructor.

These problems become relevant once the destructor function itself is statefull,
as is the case when embedding a non-trivial, instance bound allocator
to be used for the clean-up work. Using the new `lib::TrackingAllocator`
highlighted this potential problem, since the allocator maintains a use-count.

Thus I decided to move the »destruction mechanics« one level down into
a dedicated and well encapsulated base class; invoking ArrayBucket's destructor
thereby becomes the only way to trigger the clean-up, and even ElementFactory::destroy()
can now safely check if the destructor was already invoked, and otherwise
re-invoke itself through this embedded destructor function. Moreover,
as an additional safety measure, the actual destructor function is now
moved into the local stack frame of the object's destructor call, removing
any possibility for the de-allocation to interfere with the destructor
invokation itself
2024-06-18 18:15:58 +02:00
31c24e0017 Library: investigate discrepancy in allocator
part of the observed deviation stems form bugs in logging and checksum calculation;
but there seems to be a real problem hidden in the allocator usage of the
new component, since the use-cnt of the handle does not drop to zero
2024-06-18 17:20:23 +02:00
09c8c2a29f Library: better handle the alignment issues explicitly
While there might be the possibility to use the magic of the standard library,
it seems prudent rather to handle this insidious problem explicitly,
to make clear what is going on here.

To allow for such explicit alignment handling, I have now changed the
scheme of the storage definition; the actual buffer now starts ''behind''
the `ArrayBucket<I>` object, which thereby becomes a metadata managing header.

__To summarise the problem__: since we are maintaining a dynamically sized buffer,
and since we do not want to expose the actual element type through the
front-end object, we're necessarily bound to perform a raw-memory allocation.
This is denoted in bytes, and thus the allocator can no longer manage
the proper alignment automatically. Rather, we get a storage buffer with
just ''some accidental'' alignment, and we must care to request a sufficient
overhead to be able to shift the actual storage area forward to the next
proper alignment boundary. Obviously this also implies that we must
store this individual padding adjustment somewhere in the metadata,
in order to be able to report the correct size of the block later
on de-allocation.
2024-06-18 03:16:26 +02:00
dc6c8e0858 Library: investigate alignment issues
The solution implemented thus far turns out to be not sufficient
for ''over-aligned-data'', as the raw-allocator can not perform the
''magic work'' because we're exposing only `std::byte` data.
2024-06-17 16:58:07 +02:00
055df59dde Library: tracking diagnostic allocator now complete and tested 2024-06-17 01:55:49 +02:00
10edc31eac Library: build adaptor for automated unique-ownership
This adaptor works in concert with the generic allocator
building blocks (prospective ''Concepts'') and automatically
registers a either static or dynamic back-link to the factory
for clean-up.

Use this wrapper fore more in-depth test of the new `TrackingAllocator`
and verify proper behaviour through the `EventLog`
2024-06-16 19:31:16 +02:00
be3cf61111 Library: verify fundamental properties of TrackingAllocator
* implement some further statistic and diagnostic helpers
 * explicitly create and discard a base allocation for test
2024-06-16 15:44:43 +02:00
32bea9521b Library: get the simple testcase to work
- create two vectors, attached to the `TrackingAllocator`
- emplace Tracker-Objects
- move an object to the other vector
- destroy the containers

🠲 Event-Log looks plausible!
2024-06-16 04:23:06 +02:00
a3fb6f46ed Library: implement the MemoryPool for TrackingAllocator
- use a meta-registry of pools
- retrieve and manage the `MemoryPool` instances by shared_ptr, with a weak registry entry
- use a hastable for the allocations, keyed by the allocated memory address
2024-06-16 04:22:29 +02:00
ad90b7d687 Library: define requirements for tracking test-allocator
- ability to verify a hash-checksum
- ability to watch number of allocations and allotted bytes
- using either a common global pool or a separate dedicated pool
- log all operations into a common `EventLog` instance
- front-end adaptors for use as C++ custom allocator
2024-06-16 04:22:29 +02:00
e82dd86b39 Library: reorganise test helpers and cover logging tracker object
...these features are now used quite regularly,
and so a dedicated documentation test seems indicated.

Actually my intention is to add a tracking allocator to these test helpers
(and then to use that to verify the custom allocator usage of `lib::Several`)
2024-06-16 04:22:29 +02:00
d327094603 Library: draft a scheme to configure lib::Several with a custom allocator
Phew... this was a tough one — and not sure yet if this even remotely works...

Anyway, the `lib::SeveralBuilder` is already prepared for collaboration with a
custom allocator, since it delegates all memory handling through a base policy,
which in turn relies on std::allocator_traits.

The challenge however is to find a way...
 * to make this clear and easy to use
 * to expose an extension point for specific tweaks
 * and to make all this work without excessive header cross dependencies
2024-06-16 04:22:28 +02:00
bb164e37c8 Library: allow for dynamic adjustments in AllocationCluster
This is a low-level interface to allow changing the size of
the currently latest allocation in `AllocationCluster`; a client
aware of this capability can perform a real »in-place re-alloc«,
assuming the very specific usage constraints can be met.

`lib::Several<X>` will use this feature when attached to an
`AllocationCluster`; with this special setup, an previously
unknown number of non-copyable objects can be built without
wasting any storage, as long as the storage reserve in the
current extent of the `AllocationCluster` is sufficient.
2024-06-16 04:22:28 +02:00
3bbdf40c32 Library: verify element placement into storage
...use some pointer arithmetic for this test to verify
some important cases of object placement empirically.

Note: there is possibly a very special problematic case
when ''over aligned objects'' are not placed in accordance
to their alignment requirements. Fixing this problem would
be non-trivial, and thus I have only left a note in #1204
2024-06-16 04:22:28 +02:00
fd1ed7e78f Library: finish coverage of element handling limits and failures
...including the interesting cases where objects are relocated
and the element spread is changed. With the help of the checksum
feature built into the test-dummy objects, the properly balanced
invocation of constructors can be demonstrated


PS: for historical context...
Last week the "Big F**cking Rocket" successfully performed the
test flight 4; both booster and Starship made it back to the
water surface and performed a soft splash-down after decelerating
to speed zero. The Starship was even able to maintain control
in spite of quite some heat damage on the steering flaps.
Yes ... all techies around the world are thrilled...
2024-06-16 04:22:28 +02:00
00287360be Library: rework handling of resize and spread changes
- spread change now retains the nominal element reserve
- `capacity()` and `capReserve()` now exposed on the builder API
- factor out the handling check safety functions
- rewrite the `resize()` builder function to be more generic

__Test now covers__ example with trivial data type, which can
indeed be resized and allows to grow buffer on-the fly without
requiring any knowledge of the actual type (due to using `memmove`)
2024-06-16 04:22:28 +02:00
89dd35e70d Library: cover handling limits for virtual baseclass scenario
building on the preceding analysis, we can now demonstrate that
the container is initially able to grow, but looses this capability
after accepting one element of unknown subclass type...
2024-06-16 04:22:28 +02:00
85e3780a34 Library: reassess logic to reject some types for existing container
`lib::Several` is designed to be highly adaptable, allowing for
several quite distinct usage styles. On the downside, this requires
to perform some checks at runtime only, since the ability to handle
some element depends on specific circumstances.

This is a notable difference to `std::vector`, which is simply not capable
of handling ''non-copyable'' types, even if given an up-front memory reservation.

The last test case provided with the previous changeset did not trigger
an exception, but closer investigation revealed that this is correct,
since in this specific situation the container can accept this object type,
thereby just loosing the ability to move-relocate further objects.

A slightly re-arranged test scenario can be used to demonstrate this fine point.
2024-06-16 04:22:28 +02:00
d9f86ad891 Library: investigate case with known element type
- the test-dummy objects need a `noexcept` move ctor
- **bug** here: need an explicit check to prevent other types
  than the known element type from ''sneaking in''
2024-06-16 04:22:28 +02:00
006809712e Library: some coverage for rejected type placements
The `SeveralBuilder` is very flexible with respect to added elements,
but it will investigate the provided type information and reject any
further build operation that can not be carried out safely.
2024-06-16 04:22:28 +02:00
1169b6272e Library: test coverage for some ''special'' builder usages 2024-06-16 04:22:28 +02:00
601a555e6c Library: builder to add heterogeneous elements
...turns out that we must ensure to pass a plain "object" type
to the standard allocator framework (no const, no references).
Here, ''object in C++ terminology'' means a scalar or record type,
but no functor, no references and no void,
2024-06-16 04:22:28 +02:00
1a76fb46f3 Library: elaborate SeveralBuilder operations
Consider what (not) to support.
Notably I decided ''not to support'' moving out of an iterator,
since doing so would contradict the fundamental assumptions of
the »Lumiera Forward Iterator« Concept.

Start verifying some variations of element placement,
still focussing on the simple cases
2024-06-16 04:22:28 +02:00
773325f1bc Library: rearrange strategy code
Parts of the decision logic for element handling was packaged
as separate »strategy« class — but this turned out to be neither
a real abstraction, nor configurable in any way. Thus it is better
to simplify the structure and turn these type predicates into simple
private member functions of the SeveralBuilder itself
2024-06-16 04:22:28 +02:00
6f3bfb5ff3 Library: better alignment handling
Elements maintained within the storage should be placed such
as to comply with their alignment requirements; the element spacing
thus must be increased to be a multiple of the given type's alignment.

This solution works in most common cases, where the alignement is
not larger as the platform's bus width (typically 64bit); but for
''over-aligned types'' this scheme may still generate wrong object
start positions (a completely correct solution would require to
add a fixed offset to the beginning of the storage array and also
to capture the alignment requirements during population and to
re-check for each new type.
2024-06-16 04:22:28 +02:00
66a1f6f8ab Library: add iteration capability to the Several-container
...and the nice thing is, the recently built `IterIndex` iteration wrapper
covers this functionality right away, simply because `lib::Several`
is a generic container with subscript operator.
2024-06-16 04:22:27 +02:00
a3e8579e4a Library: basic functionality of the Several-container working
...passes the simplest unit test
 * create a Several<int>
 * populate from `std::initializer_list`
 * random-access to elements

''next step would be to implement iteration''
2024-06-16 04:22:27 +02:00
8534914c71 Library: work out a solution how to store a Deleter functor
After some fruitless attempts, I settled for using std::function directly,
in order to establish a working baseline of this (tremendously complicated)
allocation logic. Storing a std::function in the ArrayBucket is certainly
wasteful (it costs 4 »slots« of memory), but has the upside that
it handles all those tricky corner cases magically; notably
the functor can be stored completely inline in the most relevant
case where the allocator is a monostate; moreover we bind a lambda,
which can be optimised very effectively, so that in the simplest case
there will be only the single indirection through the ''invoker''.

This **completes the code path for a simple usage cycle**

🠲 ''and hooray ... the test crashes with a double-free''
2024-06-09 23:45:24 +02:00
954a399b1c Library: logic to select a suitable deleter
- ensure the ''deleter function'' is invoked
- care for proper ''deleter'' setup in case of exception while copying
- need to »lock-in« on one specific kind of ''destructor invocation scheme,''
  since we do not keep track of individual concrete element types
2024-06-09 17:19:40 +02:00
54bd568714 Library: integrate storage-management logic
Parts of this logic were first coded down in the `realloc` template method,
where it did not really belong; thus reintegrate similar logic one level above,
in the SeveralBuilder::adjustStorage(). Moreover, for performance reasons,
always start with an initial chunk, similar to what `std::vector` does...
2024-06-09 03:00:12 +02:00
e99f4d531b Library: simplified and generic realloc
since this is meant as a policy implementation, reduce it to the bare operation;
the actual container storage handling logic shall be implemented in the container
and based on those primitive and configurable base operations
2024-06-09 02:06:41 +02:00
3a263c8c63 Library: rearrange logic for trivial move detection
...still fighting to get the design of the `AllocationPolicy`
settled to work well with `AllocationCluster` while also allowing
to handle data types which are (not) trivially copyable.

This changeset attempts to turn the logic round: now we capture
an ''move exclusion flag'' and otherwise allow the Policy to
decide on its own, based on the ''element type''
2024-06-09 00:58:42 +02:00
446f133c09 Library: logic to accept further elements
- verifies if new element can just fit in
- otherwise ensure the storage adjustments are basically possible
- throw exception in case the new element can not be accommodated
- else request possible storage adjustments
- and finally let the allocator place the new element
2024-06-08 17:35:14 +02:00
0a788570a9 Library: integrate strategy for acceptable element types
Draft skeleton of the logic for element creation.
This turns out to be a rather challenging piece of code,
since we have to rely on logical reasoning about properties
of the element types in order to decide if and how these
elements can be emplaced, including the possibility to
re-allocate and move existing data to a new location.

- if we know the exact element type, we can handle any
  copyable or movable object
- however, if the container is filled with a mixture of types,
  we can not re-allocate or grow dynamically, unless all data
  is trivially copyable (and can thus be handled through memmove)
- moreover we must ensure the ability to invoke the proper destructor
2024-06-08 03:52:05 +02:00
bbec35ce65 Library: switch rest of implementation
...and remove now obsolete metadata fields in the collection and builder classes
2024-06-08 02:03:07 +02:00
deaabcda6e Library: adapt allocation and realloc to new layout
significantly simplifies both API and calculations,
since all necessary data is now within the ArrayBucket
2024-06-08 01:50:50 +02:00
130a021020 Library: rearrange storage layout
In-depth analysis of storage management revealed a misconception
with respect to possible storage optimisations, requiring more
metadata fields to handle all corner cases correctly.

It seems prudent to avoid any but the most obvious optimisations
and wait for real-world usage for a better understanding of the
prevalent access patterns. However, in preparation for any future
optimisations, all access coordination and storage metadata is
now relocated into the `ArrayBucket`, and thus resides within the
managed allocation, allowing for localised layout optimisations.

To place this into context: the expected prevalent use case is
for the »Render Nodes Network«, which relies on `AllocationCluster`
for storage management; most nodes will have only a single predecessor
or successor, leading to a large number of lib::Several intsances
populated with a single data element. In such a scenario, it is
indeed rather wasteful to allocate four »slot« of metadata for
each container instance; even more so since most of this
metadata is not even required in such a scenario.
2024-06-08 00:23:42 +02:00
154a7018be Library: attempt to build a re-alloc on top of the new adapter
...which basically ''seems doable'' now, yet turns up several unsolved problems
- need a way to handle excess storage for the raw allocation
- generally should relocate all metadata into the ArrayBucket
- mismatch at various APIs; must re-think where to pass size explicitly
- unclear yet how and where to pass the actual element type to create
2024-06-07 19:04:06 +02:00
24b3e5ceba Library: work out adaptor solution for custom allocator
...turns out to be rather challenging, due to the far reaching requirements
 * the default case (heap allocation) ''must work out-of-the box''
 * optionally a C++ standard conformant `Allocator` can be adapted
 * which works correct even in case this allocator is ''not a monostate''
 * **essential requirement** is to pass an `AllocationCluster` reference directly
 * need a ''generic extension point'' to adapt to similar elaborate custom schemes

__Note__: especially we want to create a direct collaboration between the allocation policy and the underlying allocator to allow support for a dedicate ''realloc operation''
2024-06-07 03:36:25 +02:00
c5d1a7d0df Library: rearrange into standard allocation factory
- code spelled out as intended, according to generic scheme
 - can now encode the »unmanaged« case directly as `null`-deleter,
   because in all other cases a deleter function is mandatory now
 - add default constructor to `ArrayBucket`, detailing the default spread
2024-06-07 01:53:38 +02:00
0e2ca6ee1c Library: consider to align this with the »Factory« concept
even while at first sight only a ''deleter instance'' is required,
it seems prudent to rearrange the code in accordance to the prospective
Allocator / Object Factory concept, and rather try to incorporate
the specifics of the memory layout into this generic view, thereby
abstracting the actual allocator away.

This can be achieved by using a standard-allocator for `std::byte`
as the base allocator and treat each individual element allocator
as a specialised cross-allocator (assuming that this cross adaptation
is actually trivial in almost all cases)
2024-06-07 01:14:55 +02:00
bf74ba6292 Library: sketch for a deleter trampoline
for simple allocators this can be static
2024-06-06 18:41:07 +02:00
98d5b2962c Library: analyse options for passing a deleter function
The fundamental decision is that we want to have a single generic front-end,
meaning that we must jump dynamically into a configured deleter function.
And on top of that comes the additional requirement that ''some allocators''
are in fact tied to a specific instance, while other allocators are monostate.

However, we can distinguish both by probing if the allocator can be default constructed,
and if a default constructed allocator is equivalent to the currently used alloctor instance.

If this test fails, we must indeed maintain a single allocator instance,
and (to avoid overengineering for this rather special use case) we will
place this allocator instance into heap memory then, with a self-cleanup mechanism
On the other hand, all monostate allocators can be handled through static trapolines.
2024-06-06 02:46:05 +02:00
802fef9b7c Library: work out Skeleton for memory-handling strategy
- the basic decision is to implement ''realloc'' similar to `std::vector`
- however the situation is complicated by the desire to allow arbitrary element types
- ⟹ must build a strategy based on the properties of the target type
- the completely dynamic growth is only possibly for trivially-movable types
- can introduce a dedicated ''element type'' though, and store a trampolin handler
2024-06-05 02:24:39 +02:00
2abbae77d7 Library: draft memory rearrangements
not clear yet how to handle the classical "realloc" situation
2024-05-29 01:01:16 +02:00
feeee4096d Library: draft skeleton of builder operations
- create by forwarding allocator arguments to policy
- builder-Op to append from iterator
- decide to collapse the ArrayBucket class, since
  access is going through unsafe pointer arithmetic anyway
2024-05-28 18:52:01 +02:00
27b36f0679 Library: implement access to storage and subscript
...not sure if this approach works out OK,
since we can not make a safe downcast to a size known at runtime
2024-05-28 18:07:08 +02:00
f6e4358259 Library: data layout for the new Several container
- favour dynamic polymorphism
- use additional memory for management data alongside the element allocation
- encode a flag and a deleter pointer to enable ownership of the allocation
- inherit base container privately into builder, so the build ends with a slice
2024-05-28 17:20:34 +02:00
73dd24ecef Library: start design draft to replace RefArray
Some decisions
 - use a single template with policy base
 - population via separate builder class
 - implemented similar to vector (start/end)
 - but able to hold larger (subclass) objects
2024-05-28 04:03:51 +02:00
e4f91ecb4d Library: document usage of AllocationCluster for STL containers
- basically works out-of-the-box now
- the hard wired fixed Extent size is a serious limitation
- however, this is not the intended primary use, rather complementary
2024-05-28 00:36:32 +02:00
178107e8b9 Library: enable empty-base optimisation for allocator
...this is an important detail: quite commonly, a custom allocator
is actually implemented as monostate, to avoid bloating every client container
with a backlink pointer; by inheriting the `StdFactory` adapter from the
allocator, the empty-base optimisation can be exploited.

In the standard case thus LinkedElements is the same size as a single
pointer, which is already exploited at several places in the code base.
Notably `AllocationCluster` uses a »virtual overlay« to dress-up the
position pointer as `LinkedElements`, allowing to delegate most of the
administration and memory management to existing and verified code.


With this adjustments, `LinkedElements` pass the tests again
and the rework of `AllocationCluster` is considered complete.
2024-05-27 19:02:31 +02:00
cf80a292c1 Library: adapt LinkedElements to use the new StdFactory adaptor
This is the first validation of the new design:
the policy to take ownership can be reimplemented simply
by delegating to the adaptor for a C++ standard allocator
2024-05-27 02:06:06 +02:00
8ca3c61c6f Library: Analysis and planning towards a generic Allocator Concept
The following structure can be expected, after __switching to C++20__
 * Concept **Allocator** deals with the bare memory allocation
 * Concept **Factory** handles object creation and disposal by delegation
 * Concept **Handle** is a ready-made functor for dependency-injection

Right now, an implementation of the ''prospective Factory Concept''
can be provided, by delegating through `std::allocator_traits` to a given
`std::allocator` or compatible object
2024-05-26 19:31:30 +02:00
5259000bc4 Library: how to use a standard allocator for LinkedElements
By default, LinkedElements uses a policy OwningHeapAllocated;
while retaining this interface, this policy should be recast
to rely on a standard compliant allocator, with a default
fallback to `std::allocator<T>`

This way, a single policy would serve all the cases where
objects are actually owned and managed by `LinkedElements`,
and most special policies would be redundant.

This turns out to be quite tedious and technical however,
since the newer standard mandates to use std::allocator_traits
as front-end, and moreover the standard allocators are always
tied to one specific target type, while `LinkedElements` is
deliberately used to maintain a polymorphic sequence.
2024-05-26 02:51:47 +02:00
08e0f52e61 Library: low-level implementation internals covered
...including overflow into new extents, alignment padding
and chaining and invocation of destructors.
2024-05-25 20:01:23 +02:00
be398e950a Library: better let C++ handle the destructors
...what I've implemented yesterday is effectively the same functionality
as provided automatically by the C++ object system when using a virtual destructor.
Thus a much cleaner solution is to turn `Destructor` into a interface
and let C++ do all the hard work.

Verified in test: works as intended
2024-05-25 19:27:17 +02:00
71d5851701 Library: implement optional invocation of destructors
This is the first draft, implementing the invocation explicitly
through a trampoline function. While it seems to work,
the formulation can probably be simplified....
2024-05-25 05:14:36 +02:00
31f8664725 Library: verify overflow to second extent 2024-05-25 01:28:29 +02:00
841234684b Library: verify further simple allocations and alignment 2024-05-24 19:06:33 +02:00
037a5f2dd0 Library: verify the simplest possible allocation
...by inspecting the raw memory locations -- looks good thus far...
2024-05-24 18:05:21 +02:00
e8d9dcd9bf Library: implement accounting of storage size
These diagnostics helpers must rely on low-level trickery,
since the implementation strives at avoiding unnecessary storage overhead.
Since `AllocationCluster` is move-only (for good reasons) and `StorageManager`
can not be constructed independently, a »backdoor« is created by
forced cast, relying on the known memory layout
2024-05-24 17:05:50 +02:00
13e22f315a Library: clarify details of the low-level allocation
- rather accept hard-wired limits than making the implementation excessively generic
- by exploiting the layout, the administrative overhead can be reduced significantly
- the trick with the "virtual managment overlay" allows to hand-off most of the
  clean-up work to C++ destructor invocation
- it is important to verify these low-level arrangements explicitly by unit-test
2024-05-19 17:53:51 +02:00
72aea53ac3 Library: idea for an extent management mechanism
* this is pure old-style low-level trickery
 * using a layout trick, the `AllocationCluster`
   can be operated with the bare minimum of overhead
 * this trick relies on the memory layout of `lib::LinkedElements`
2024-05-18 02:35:20 +02:00
c623298ac8 Library: draft standard case for actual memory allocation
- attempt to use the minimal possible storage for the management itself
- rely on the `std::align()` function to do the actual placement
2024-05-16 02:47:01 +02:00
eeda3aaa56 Library: remove elaborate allocation logic
...due to the decision to use a much simpler allocation scheme
to increase probability for actual savings, after switching the API
and removing all trading related aspects, a lot of further code is obsoleted
2024-05-16 01:46:41 +02:00
13f51c910c Library: work out ramifications of the changed design
Notably this raises the difficult question,
whether to ensure **invocation of destructors**.

Not invoking dtors ''breaks one of the most fundamental contracts''
of the C++ language — yet the infrastructure to invoke dtors in such
a heterogeneous cluster of allocations creates a hugely significant
overhead and is bound to poison the caches (objects to be deallocated
typically sit in cold memory pages).

What makes this decision especially daunting is the fact that the
low-level-Model can be expected to be one of the largest systemic
data structures (letting aside the media buffers).

I am leaning towards a compromise: turn down this decision
towards the user of the `AllocationCluster`
2024-05-15 19:59:05 +02:00
fd49c68096 Library: draft a simpler STL complient allocation interface
After some analysis, it became clear that the existing code for
`AllocationCluster` (while in itself valid) will likely miss the point
for the expected usage in the low-level Model: most segments of the
model will be rather small, and thus there is not enough potential for
amortisation when using such a per-type and per-segment scheme;
a rather simplistic linear allocator will be sufficient.

On the other hand, with the current C++ standard it is easy to provide
a complient allocator implementation for STL containers, and thus the
interface should be retro-fitted accordingly.
2024-05-15 01:38:16 +02:00
db30da90ce Invocation: consider storage and allocation of fan-in/fan-out
At the time of the initial design attempts, I naively created a
classic interface to describe an fixed container allocated ''elsewhere.''

Meanwhile the C++ language has evolved and this whole idea looks
much more as if it could be a ''Concept'' (C++20). Moreover, having
several implementations of such a container interface is deemed inadequate,
since it would necessitate ''at least two indirections'' — while
going the Concept + Template route would allow to work without any
indirection, given our current understanding that the `ProcNode` itself
is ''not an interface'' — rather a building block.
2024-05-13 18:34:42 +02:00
c0d5341b15 Invocation: capture idea for sharpened invocation structure
- the starting point is the idea to build a dedicated ''turnout system''
- `StateAdapter`, `BuffTable` ⟶ `FeedManifold` and _Invocation_ will be fused
- actually, the `TurnoutSystem` will be ''pulled'' and orchestrate the invocation
- the structure is assumed to be recursive

The essence of the Node-Invocation, as developed 2009 / 2011 remains intact,
yet it will be organised along a clearer structure
2024-05-12 17:27:07 +02:00
bd9527716a Invocation: segregate first and second buffer feed implementation
Within the existing body of code, there are two unfinished attempts
towards building a node invocation and management of data buffers.

The first attempt was entirely driven from the angle of invoking a
processing function, while the second one draws from a wider scope
and can be considered the solution to build upon regarding data buffers
in general. However, the results of the first approach are well suited
for their specific purpose, so both solutions will be combined.

Thus the arrangement of data feeds going in and out of the render node
shall be renamed into `BuffTable` -> `FeedManifold`
2024-05-11 17:06:12 +02:00
9a435a667e Invocation: start with some rename-refactorings
... to plot a clearer understanding of the intended usage
2024-05-11 16:39:58 +02:00
bb3d565436 Invocation: Reassessment of existing code
...which seems to be basically fine thus far
...beyond some renaming and rearranging

''it turns out that the final, crucial links,
necessary to tie all together, are yet to be developed''
2024-05-05 15:12:23 +02:00
a11ee34fc8 Invocation: forge a path for integration
Facing quite some difficulties here, since there are (at least)
two abandoned past efforts towards building a render node network
in the code base; the structure and architecture decisions from these
previous attempts seem largely valid still, yet on a technical level,
the style of construction evolved considerably in the meantime. Moreover,
these old fragments of code, written during the early stages of the
project, were lacking clear goals and anchor points at places;
the situation is quite different now in this respect.

Sticking to well proven practice, the rework will be driven by a test setup,
and will progress over three steps with increasing levels of integration.
2024-04-23 01:13:40 +02:00
47e26e2a65 Invocation: initial considerations...
Looks like some code archaeology is required
to sort apart the various effort to get this topic started....
2024-04-21 02:58:30 +02:00
d71eb37b52 Scheduler-test: complete and document stress testing effort (closes #1344)
The initial effort of building a Scheduler can now be **considered complete**
Reaching this milestone required considerable time and effort, including
an extended series of tests to weld out obvious design and implementation flaws.

While the assessment of the new Scheduler's limitation and traits is ''far from complete,''
some basic achievements could be confirmed through this extended testing effort:
 * the Scheduler is able to follow a given schedule effectively,
   until close up to the load limit
 * the ''stochastic load management'' causes some latency on isolated events,
   in the order of magnitude < 5ms
 * the Scheduler is susceptible to degradation through Contention
 * as mitigation, the Scheduler prefers to reduce capacity in such a situation
 * operating the Scheduler effectively thus requires a minimum job size of 2ms
 * the ability for sustained operation under full nominal load has been confirmed
   by performing **test sequences with over 80 seconds**
 * beyond the mentioned latency (<5ms) and a typical turnaround of 100µs per job
   (for debug builds), **no further significant overhead** was found.

Design, Implementation and Testing were documented extensively in the [https://lumiera.org/wiki/renderengine.html#Scheduler%20SchedulerProcessing%20SchedulerTest%20SchedulerWorker%20SchedulerMemory%20RenderActivity%20JobPlanningPipeline%20PlayProcess%20Rendering »TiddlyWiki« #Scheduler]
2024-04-20 01:56:54 +02:00
a46449d5ac Scheduler-test: stable-state run > 1sec
This test completes the stress-testing effort
and summarises the findings
 * Scheduler performs within relevant parameter range without significant overhead
 * Scheduler can operate with full load in stable state, with 100% correct result
2024-04-18 01:39:28 +02:00
177e241060 Scheduler-test: investigate extended loads with different patterns
The behaviour seems consistent and the schedule breaks at the expected point.
At first sight, concurrency seems slightly to low; detailed investigation
however shows that this is due to the structure of the load graph,
and in fact the run time comes close to optimal values.
2024-04-18 01:39:28 +02:00
c934e7f079 Scheduler-test: reduce impact of scale adjustments on breakpoint-search
the `BreakingPoint` tool conducts a binary search to find the ''stress factor''
where a given schedule breaks. There are some known deviations related to the
measurement setup, which unfortunately impact the interpretation of the
''stress factor'' scale. Earlier, an attempt was made, to watch those factors
empirically and work a ''form factor'' into the ''effective stress factor''
used to guide this measurement method.

Closer investigation with extended and elastic load patters now revealed
a strong tendency of the Scheduler to scale down the work resources when not
fully loaded. This may be mistaken by the above mentioned adjustments as a sign
of a structural limiation of the possible concurrency.

Thus, as a mitigation, those adjustments are now only performed at the
beginning of the measurement series, and also only when the stress factor
is high (implying that the scheduler is actually overloaded and thus has
no incentive for scaling down).

These observations indicate that the »Breaking Point« search must be taken
with a grain of salt: Especially when the test load does ''not'' contain
a high degree of inter dependencies, it will be ''stretched elastically''
rather than outright broken. And under such circumstances, this measurement
actually gauges the Scheduler's ability to comply to an established
load and computation goal.
2024-04-18 01:39:27 +02:00
55842a8d4f Scheduler-test: identify and fix bug in allocator
...well — more of a logical contradiction, not so much a bug.
The underlying problematic situation arises when meanwhile the
Extent storage has been expanded, and especially the active slots
are in »wrapped state«. In this case, the newly allocated extents
must be rotated in, which invalidates existing index numbers.

This problem was amended by exploting a chaching mechanism, allowing
to re-attach and validate an index position still stored in an old
iterator; especially this can happen when attempting to attach a
follow-up dependency onto a job planned earlier, but not yet scheduled.

The problem here was an assertion failure, which was triggered with a
high probability; the fix for the problem detailed above used the yield()
function, while it actually was only interested in retrieving the
Extent's address to probe if the extent matches an known storage location.

The solution is to provide a dedicated function for this check, which
can then skip the sanity check (because in this case we do not want
to use the Extent, and thus can touch obsoleted/inactive Extents
without problem)
2024-04-18 01:39:27 +02:00
7c2b9a8ba5 Scheduler-test: investigate extended load patterns
...this seems to be the last topic for this investigation of Scheduler behaviour;
the goal is to demonstrate readiness for stable-state operation over an extended period of time
2024-04-18 01:39:26 +02:00
1d4f6afd18 Scheduler-test: complete and document the Load-peak tests
- use parameters known to produce a clean linear model
- assert on properties of this linear model

Add extended documentation into the !TiddlyWiki,
with a textual account of the various findings,
also including some of the images and diagrams,
rendered as SVG
2024-04-12 02:23:31 +02:00
5b62438eb4 Scheduler-test: investigate logic problem related to the »Tick« deadline
In the end, I decided that it ''is to early to decide anything'' in this respect...

The actual situation encountered is a **Catch-22**:
 * in its current form, the »Tick« handler detects compulsory jobs beyond deadline
 * since such a Job ''must not be touched anymore,'' there is no way scheduling can proceed
 * so this would constitute a ''Scheduler Emergency''
All fine — just the »Tick« handler ''itself is a compulsory job'' — and being a job, it can well be driven beyond its deadline. In fact this situation was encountered as part of stress testing.

Several mitigations or real solutions are conceivable, but in the end,
too little is known yet regarding the integration of the scheduler within the Engine
Thus I'll marked the problematic location and opened #1362
2024-04-12 02:23:31 +02:00
1316ee2c7f Scheduler-test: adjust contention mitigation as result of testing
Investigate the behaviour over a wider range of job loads,
job count and worker pool sizes. Seemingly the processing
can not fully utilise the available worker pool capacity.

By inspection of trace-dumps, one impeding mechanism could
be identified: the »stickiness« of the contention mitigation.
Whenever a worker encounters repeated contention, it steps up
and adds more and more wait cycles to remove pressure from the
schedule coordination. As such this is fine and prevents further
degradation of performance by repeated atomic synchronisation.
However, this throttling was kept up needlessly after further
successful work-pulls. Since job times of several milliseconds
can be expected on average in media processing, such a long
retention would spread a performance degradation over a duration
of several frames. Thus, the scheme for step-down was changed
to decrease the throttling by a power series rather than just
documenting the level.
2024-04-12 02:23:31 +02:00
a6a9155cd9 Scheduler-test: measurements documented 2024-04-09 17:10:21 +02:00
6e7f9edf43 Scheduler-test: calculate linear model as test result
Use the statistic functions imported recently from Yoshimi-test
to compute a linear regression model as immediate test result.

Combining several measurement series, this allows to draw conclusions
about some generic traits and limitations of the scheduler.
2024-04-09 17:10:21 +02:00
3517ab6965 Scheduler-test: fine-tuning of result presentation (Gnuplot)
Visual tweaks specific to this measurement setup
 * include a numeric representation of the regression line
 * include descriptive axis labels
 * improve the key names to clarify their meaning
 * heuristic code for the x-ticks
Package these customisations as a helper function into the measurement tool
2024-04-08 18:45:02 +02:00
8e33194882 Scheduler-test: settle definition of specific test setup and data
After a lot of further tinkering, seemingly arriving at a
somewhat satisfactory solution for the layout and arrangement of
test definitions and especially the table for measurement series.

While the complete setup remains fragile indeed, and complexity is more
hidden than reduced — the pragmatic compromise established yesterday
at least allows to reduce the amount of boilerplate in the test or
measurement setup to make the actual specifics stand out clearly.

----

As an aside, the usage of the `DataFile` type imported from Yoshimi-test
recently was re-shaped more towards a generic handling of tabular data with
CSV storage option; thus renaming the type now into `DataTable`.
Persistent storage is now just one option, while another usage pattern
compounds observation data into table rows, which are then directly
rendered into a CSV string, e.g. for visualisation as Gnuplot graph.
2024-04-08 03:58:15 +02:00
10fa0aaa79 Scheduler-test: design problems impeding clean test-setup
Encountering ''just some design problems related to the test setup,''
which however turn out hard to overcome. Seems that, in my eagerness
to create a succinct and clear presentation of the test, I went into
danger territory, overstretching the abilities of the C++ language.

After working with a set of tools created step by step over an extended span of time,
''for me'' the machinations of this setup seem to be reduced to flipping a toggle
here and there, and I want to focus these active parts while laying out this test.
''This would require'' to create a system of nested scopes, while getting more and more
specific gradually, and moving to the individual case at question; notably any
clarification and definition within those inner focused contexts would have to be
picked up and linked in dynamically.

Yet the C++ language only allows to be ''either'' open and flexible towards
the actual types, or ''alternatively'' to select dynamically within a fixed
set of (virtual) methods, which then must be determined from the beginning.
It is not possible to tweak and adjust base definitions after the fact,
and it is not possible to fill in constant definitions dynamically
with late binding to some specific implementation type provided only
at current scope.

Seems that I am running against that brick wall over and over again,
piling up complexities driven by an desire for succinctness and clarity.

Now attempting to resolve this quite frustrating situation...
- fix the actual type of the TestChainLoad by a typedef in test context
- avoid the definitions (and thus the danger of shadowing)
  and use one `testSetup()` method to place all local adjustments.
2024-04-08 03:54:00 +02:00
d47f24d745 Scheduler-test: reorganise test-setup in Stress-test-rig
With the addition of a second tool `bench::ParameterRange`,
the setup of the test-context for measurement became confusing,
since the original scheme was mostly oriented towards the
''breaking point search.''

On close investigation, I discovered several redundancies, and
moreover, it seems questionable to generate an ''adapted-schedule''
for the Parameter-Range measurement method, which aims at overloading
the scheduler and watch the time to resolve such a load peak.

The solution entertained here is to move most of the schedule-ctx setup
into the base implementation, which is typically just inherited by the
actual testcase setup. This allows to leave the decision whether to build
an adapted schedule to the actual tool. So `bench::BreakingPoint` can
always setup the adapted schedule with a specific stress-factor,
while `bench::ParameterRange` by default does nothing in this
respect, and thus the `ScheduleCtx` will provide a default schedule
with the configured level-duration (and the default for this is
lowered to 200µs here).

In a similar vein, calculation of result data points from the raw measurement
is moved over into the actual test setup, thereby gaining flexibility.
2024-04-08 03:54:00 +02:00
0d3dc91584 Scheduler-test: rework ParameterRange tool for data visualisation
Rework the existing tool to capture the measurement series
into the newly integrated CSV-based data storage, allowing
to turn the results into a Gnuplot-visualisation.
2024-04-04 02:52:57 +02:00
55f8f229f1 Library: customisation of the generated Gnuplot diagram 2024-04-03 19:31:00 +02:00
96202f845a Library: example to schow the secondary diagram
...which is added automatically whenever additional data columns are present

Result can only be verified visually

 * the upper diagram should show the first fibonacci points
 * a (correct) linear regression line should be overlayed in red
 * below, a secondary diagram should appear, with aligned axis
 * the row "one" in this diagram should be shown as impulses
 * the further rows "two" and "three" should be drawn as
   green points, using the secondary Y-axis (values 100-250)
 * Gnuplot can handle missing data points
2024-04-03 00:29:27 +02:00
c997fc2341 Library: develop Gnuplot code for flexible scatter-regression
The idea is to build the Layout-branching into the generated Gnuplot script,
based on the number of data columns detected. If there is at least one further
data column, then the "mulitplot" layout will be used to feature this
additional data in a secondary diagram below with aligned axis;
if more than one additional data column is present, all further
visualisation will draw points, using the secondary Y-axis

Moreover, Gnuplot can calculate the linear regresssion line itself,
and the drawing will then be done using an `arrow` command,
defining a function regLine(x) based on the linear model.
2024-04-02 23:59:59 +02:00
f37e651b61 Library: add some mutual integration between DataFile and CSVData
...both are related to CSV, and it is conceivable
to create inline CSVData in a test case to populate a DataFile
2024-04-02 21:18:23 +02:00
03c2191649 Library: rearrange support for CSV notation
- `forElse` belongs to the metaprogramming utils

- have a CSVLine, which is a string with custom appending mechanism

- this in turn allows CSVData to accept arbitrary sized tuples,
  by rendering them into CSVLine
2024-04-01 22:33:55 +02:00
fc084c1ca5 Library: find a better organisation of entrance points to plotting
The intention is to create a library of convenient building blocks;
providing a visualisation should be as simple as invoking a free function
with CSV data, yet with the ability to tweak some lables or display
variations if desired.

This can be achieved by..
 * having a series of ready-made standard visualisations
 * expose a function call for each, accepting a data-context builder
 * provide secondary convenience shortcuts, which add some of the expected bindings
 * notably a shortcut is provided to take the data as CSV-string
 * augmented by a wrapper/builder to allow defining data points inline
2024-03-31 19:12:43 +02:00
a6084bd2d6 Library: implement generation of a simple data visualisation
CSV data -> Gnuplot script
2024-03-31 01:46:12 +01:00
db0838ddcc Library: draft invocation framework for generating a Gnuplot
Deliberately keep it unstructured and add dedicated functions
for each new emerging use case; hopefully some commen usage scheme
will emerge over time.

 * Data is to be handed in as an iterator over CSV-strings.
 * will have to find out about additional parametrisation on a case-by-case base
2024-03-31 01:45:23 +01:00
f627d42b6e Library: develop a suitable gnuplot layout and styling
The default visuals of gnuplot are simple,
yet tend to look cluttered and are not well suited for our purpose

We need the following presentation
 * a scatter diagram with a regression line
 * additionally a secondary diagram stacked below, with aligned axis

Thus 🠲 R-T-F-M
 * The [http://gnuplot.info/ Gnuplot docu] is exhaustive, yet hard to get into
 * Helpful was this collection of [http://gnuplotting.org/ example solutions for scientific plots]
 * and — Stackoverflow...
2024-03-30 04:08:45 +01:00
918f96bb6f Library: complete ETD data-source binding and test (closes #1359)
A minimalist `TextTemplate` engine is available for in-project use.

 * supports only the bare minimum of features (no programming language)
   * substitution of `${placeholder}` by key-name data access
   * conditional section `${if key}...${end if}`
   * iteration over a data sequence
 * other then most solutions available as library,
   this implementation does **not require** a specific data type,
   nor does it invent a dynamic object system or JSON backend;
   rather, a generic ''Data Source Adapter'' is used, which can
   be specialised to access any kind of ''structured data''
 * the following `DataSource` specialisations are provided
   * `std::map<string,string>`
   * Lumiera »External Tree Description« (based on `GenNode`)
   * a string-based spec for testing
2024-03-28 03:18:02 +01:00
4c4ae0691c Library: verify DataSrc binding for Map 2024-03-28 03:14:21 +01:00
597d8191c7 Library: code the DataSource template
...turns out challenging, since our intention here
is borderline to the intended design of the Lumiera ETD.
It ''should work'' though, when combined with a Variant-visitor...
2024-03-27 04:07:55 +01:00
64f60356b7 Library: prepare for a ETD binding
Document existing data binding logic and investigate in detail
what must be done to enable a similar binding backed by Lumiera's ETD structures.
This analysis highlights some tricky aspects, which can be accommodated by
slight adjustments and generalisations in the `TextTemplate` implementation
 * `GenNode` is not structured string data, rather binary data
 * thus exposing a std::string_view is not adequate, requiring to
   pick up the result type from the actual data binding
 * moreover, to allow for arbitrary nested scopes, a back-pointer
   to the parent scope must be maintained, which requires stable memory locations.
   This can best be solved within the InstanceCore itself, which manages
   the actual hierarchy of data source references.
 * the existing code happens already to fulfil this requirement, but
   for sake of clarity, handling of such a nested scope is now extracted
   into a dedicated operation, to highlight the guaranteed memory layout.
2024-03-27 01:24:41 +01:00
c0439b265c Library: verify proper working of logic constructs
uncovers some minor implementation bugs, as can be expected...
2024-03-26 06:30:23 +01:00
4e26d655a8 Library: workaround for tricky problems with Template-Argument-Deduction
We use a DataSrc<DAT> template to access the actual data to be substituted.
However, when applying the Text-Template, we need to pick the right
specialisation, based on the type of the actual data provided.

Here we face several challenges:

 * Class-Template-Argument-Deduction starts from the *primary* template's constructors.
   Without that, the compiler will only try the copy constructor and will
   never see the constructors of partial specialisations.
   This can be fixed by providing a ''dummy constructor''.
 * The specifics of how to provide a custom CTAD deduction guide
   for a **nested template** are not well documented. I have found
   several bug reports, and seemingly one of these bugs failed my
   my various attempts. Moreover it is ''not clear if such a deduction
   guide can even be given outside of the class definition scope.''
   For the intended usage pattern this would be crucial, since users
   are expected to provide further specialisations of the DataSrc-template
 * Thus I resorted to the ''old school solution,'' which is to use
   a ''free builder function'' as an extension point. Thus users could
   provide further overloads for the `buildDataSrc()` function.
 * Unfortunately, SFINAE-Tricks are way more limited for function overload.
   Thus it seems impossible to have a generic and more specialised cases,
   unless all special cases are disjoint.

Thus the solution is far from perfect, ''yet for the current situation it seems
sufficient'' (and C++20 Concepts will greatly help to resolve this kind of problems)
2024-03-26 02:41:42 +01:00
a89e272e35 Library: supply a string-spec-binding for tests
...implemented by simply parsing the string into key=value pairs,
which are then stored into a shared map. The actual data binding
implementation can thus be inherited from the existing Map-binding
2024-03-25 18:26:17 +01:00
9b6fc3ebe5 Library: fix handling of escapes
While they were detected just fine, thy were passed-through
unaltered, which subverts the purpose of such an escape,
which is to allow for the tag syntax to be present in the
processed, substituted document (e.g. when generating a
shell script)

thus `\${escaped}` becomes `${escaped}`
2024-03-25 15:44:48 +01:00
c09f44e20f Library: complete implementation of Map-databinding
...using a ''special protocol'' to represent iterative data sequences
 * use an Index-Key with a CSV list of element prefixes
 * synthesise key-prefixes for each data element
 * perform lookup with the decorated key first

This allows to somehow ''emulate'' nested associations within a single, flat Map.
Obviously this is more like a proof-of-concept; actually the Map-databinding
is meant to handle the simple cases, where just placeholders are to be substituted.

The logic structures are much more relevant when binding to structural data,
most notably to the Lumiera _External Tree Description_ format, which is
used for model data and inter-layer communication.
2024-03-25 04:23:59 +01:00
58ffbac7f3 Library: implement logic-interpretation
- the basic interpretation of Action-tokens is already in place
 - add the interpretation of conditional and looping constructs
 - this includes helpers for
   * reset to another Action-token index
   * recursive interpretation of the next token
   * handling of nested loop evaluation context

In order to make this implementation compile, also the skeleton
of the Map-string-string data binding must be completed, including
a draft how to handle nested keys in a simple map
2024-03-25 03:30:16 +01:00
dd67b9f97b Library: cover some definition errors 2024-03-25 00:38:35 +01:00
20f2b1b90a Library: complete implementation of code generation
...including the handling of cross jumps / links
...verified by one elaborate example in the tests
2024-03-24 21:42:38 +01:00
aab446ce48 Library: further straighten iteration logic
playing the »fence post problem« the other way round
and abandoning the ''pull processing'' in favour of direct manipulation
leads to much clearer formulation of the code-generation logic
2024-03-24 15:51:38 +01:00
bc8e947f3c Library: remould compiler to active iteration
...turns out the ''pipeline design'' is not a good fit for the
Action compilation, since the compiler needs to refer to previous Actions;
better to let the compiler ''build'' the `ActionSeq`
2024-03-24 14:21:44 +01:00
b835d6a012 Library: get the template compiler basically operative
...implementation of bracketed constructs and cross references still omitted

...define a fairly elaborate test example for parsing
2024-03-24 00:48:04 +01:00
a9cbe7eb90 Library: define skeleton of TextTemplate compilation
...implemented as »custom processing layer« within a
demand-driven parsing pipeline, with the ability to
inject additional Action-tokens to represent the intermittent
constant text between tags; special handling to expose one
constant postfix after the last active tag.
2024-03-23 19:38:53 +01:00
5b53b53c4c Library: solution for ''trailing prefix'' in parser-context
* use a string-view embedded into the context-λ
 * on each match clip off some starting prefix from this string-view
2024-03-23 02:55:28 +01:00
c2df391f48 Library: draft how a pipelined-parser could work 2024-03-23 02:55:28 +01:00
2a60f77bdf Library: improve formulation of the parsing regexp
- allow additional leading and trailing whitespace within token
- more precise on the sequence of keywords
- clearer build-up of the regexp syntax
2024-03-23 02:55:28 +01:00
10bda3a400 Library: develop a token-parsing regular expression
oh my!
2024-03-23 02:55:28 +01:00
a2749adbc9 Library: also cover the smart-ptr usage variant
The way I've written this helper template, as a byproduct
it is also possible to maintain the back-refrence to the container
through a smart-ptr. In this case, the iterator-handle also manages
the ownership automatically.
2024-03-21 19:57:34 +01:00
f716fb0bee Library: build a helper to encapsulate container access by index
...mostly we want the usual convenient handling pattern for iterators,
but with the proviso actually to perform an access by subscript,
and the ability to re-set to another current index
2024-03-21 19:57:34 +01:00
76bd9ba6ce Library: establish evaluation and iteration on application 2024-03-21 19:57:34 +01:00
7893cc99c3 Library: further work out the framework for TextTemplate instantiation 2024-03-21 19:57:34 +01:00
d2dcf6c163 Library: draft the interpretation of a compiled TextTemplate
will use an iteration-pipeline, based on the »State Core« concept
2024-03-21 19:57:34 +01:00
5881b014fe Library: work out a treatment for text template substitution (see: #1359)
* establish the feature set to provide
 * choose scheme for runtime representation
 * break down analysis to individual parsing and execution steps
 * conclude which actions to conduct and the necessary data
 * derive the abstract binding API required
2024-03-21 19:57:34 +01:00
af1f549190 Library: Assessment and plan for a text templating engine
Conducted an extended investigation regarding text templating
and the library solutions available and still maintained today.

The conclusion is
 * there are some mature and widely used solutions available for C++
 * all of these are considered a mismatch for the task at hand,
   which is to generate Gnuplot scripts for test data visualisation

Points of contention
 * all solutions offer a massive feature set, oriented towards web content generation
 * all solutions provide their own structured data type or custom property-tree framework

**Decision** 🠲  better to write a minimalistic templating engine from scratch rather
2024-03-21 19:57:34 +01:00
d3fda114f8 Library: Research -- Gnuplot
Read the documentation and find out how to generate the kind of diagram
necessary for visualisation of Scheduler-Stress-Test observations.

I used to have basic Gnuplot knowledge, and thus had to find out about
- reading CSV
- supported diagram types
- layering and styling

Conclusion: will use Gnuplot and generate a script from Test code
2024-03-21 19:57:34 +01:00
aa93bf9285 Library: cover statistic functions and linear regression 2024-03-16 03:05:49 +01:00
599407deea Library: complete coverage of CSV data table including storage
also encompasses some coverage for the simplistic CSV format
implemented as storage backend for this data table
2024-03-15 02:45:45 +01:00
3b3600379a Library: introduce formating variants for decimal10
showDecimal -> decimal10 (maximal precision to survive round-trip through decimal representation=

showComplete -> max_decimal10 (enough decimal places to capture each possible distinct floating-point value)


Use these new functions to rewrite the format4csv() helper
2024-03-14 17:32:22 +01:00
4a8364e422 Library: extend the DataFile to allow using it without storage
...seems obvious and does not compromise the simplistic design...
...we do check the file path anyway, just need to add saveAs()...
2024-03-13 18:57:48 +01:00
1c2cbd4d47 Library: coverage for some filesystem convenience helpers
...created as a byproduct of the TempDir feature,
which in turn is required to do ''any'' meaningful unit-test
of filesystem related functionality.
2024-03-13 03:52:35 +01:00
a6aad5261c Library: complete and verify temp-dir helper
verify also that clean-up happens in case of exceptions thrown;
as an aside, add Macro to check for ''any'' exception and match
on something in the message (as opposed to just a Lumiera Exception)
2024-03-13 02:50:13 +01:00
18b1d37a3d Library: also create unique temporary files
...using the same method for sake of uniformity

Also move the permissions helpers to the file.hpp support functions
and setup a separate unit test for these
2024-03-12 22:54:05 +01:00
a1832b1cb9 Library: base implementation of temp-dir creation
Inspired by https://stackoverflow.com/a/58454949

Verified behaviour of fs::create_directory
 --> it returns true only if it ''indeed could create'' a new directory
 --> it returns false if the directory exists already
 --> it throws when some other obstacle shows up

As an aside: the Header include/limits.h could be cleaned up,
and it is used solely from C++ code, thus could be typed, namespaced etc.
2024-03-12 20:14:29 +01:00
b426ea4921 Library: simple default implementation for random sequences
Since this is a much more complicated topic,
for now I decided to establish two instances through global variables:
 * a sequence seeded with a fixed starting value
 * another sequence seeded from a true entropy source

What we actually need however is some kind of execution framework
to define points of random-seeding and to capture seed values for
reproducible tests.
2024-03-12 02:34:19 +01:00
7a3e4098c8 Library: some first thoughts regarding random number generation
Relying on random numbers for verification and measurements is known to be problematic.
At some point we are bound to control the seed values -- and in the actual
application usage we want to record sequence seeding in the event log.

Some initial thoughts regarding this intricate topic.
 * a low-ceremony drop-in replacement for rand() is required
 * we want the ability to pick-up and control each and every usage eventually
 * however, some usages explicitly require true randomness
 * the ability to use separate streams of random-number generation is desirable
2024-03-12 00:48:11 +01:00
6e8c07ccd6 Library: draft tests to document the new features
Yesterday I decided to include some facilities I have written in 2022
for the Yoshimi-Testsuite. The intention is to use these as-is, and just
to adapt them stylistically to the Lumiera code base.

However — at least some basic documentation in the form of
very basic unit-tests can be considered »acceptance criteria«
2024-03-11 17:44:19 +01:00
0e88dec28a Library: integrate into the Lumiera code base
- reformat in Lumieara-GNU style
- use the Lumiera exceptions
- use Lumiera format-string frontend
- use lib/util

NOTE: I am the original author of the code introduced here,
and thus I can re-license it under GPL 2+
2024-03-11 17:38:30 +01:00
a983a506b0 Scheduler-test: simplify graph generation yet more
Initially the model was that of a single graph starting
with one seed node and joining all chains into a single exit node.

This however is not well suited to simulate realistic calculations,
and thus the ability for injecting additional seeds and to randomly
sever some chains was added -- which overthrows the assumption of
a single exit node at the end, where the final hash can be retrieved.

The topology generation used to pick up all open ends, in order to
join them explicitly into a reserved last node; in the light of the
above changes, this seems like an superfluous complexity, and adds
a lot of redundant checks to the code, since the main body of the
algorithm, in its current form, already does all the necessary
bound checks. It suffices thus to just terminate the processing
when the complete node space is visited and wired.

Unfortunately this requires to fix basically all node hashes
and a lot of the statistics values of the test; yet overall
the generated graphs are much more logical; so this change
is deemed worth the effort.
2024-03-10 02:47:32 +01:00
d8eb334b17 Scheduler-test: preconfigured graph with unconnected nodes
Allow easily to generate a Chain-Load with all nodes unconnected,
yet each node on a separate level.

Fix a deficiency in the graph generation, which caused spurious
connections to be added at the last node, since the prune rule
was not checked
2024-03-09 18:06:08 +01:00
ab5900c82e Scheduler-test: fix error with topology
...the previous setup produced a single linear chain
instead of a set of unconnected nodes.

With this, the behaviour is more like expected,
but concurrency is still too low
2024-03-08 18:16:18 +01:00
605d747b8d Scheduler-test: attempt to find a viable Scheduler setup for this measurement
- better use a Test-Chain-Load without any dependencies
- schedule all at once
- employ instrumentation
- use the inner »overall time« as dependent result variable

The timing results now show an almost perfect linear dependency.
Also the inner overall time seems to omit the setup and tear-down time.
But other observed values (notably the avgConcurrency) do not line up
2024-03-08 01:30:12 +01:00
2556151304 Scheduler-test: simple implementation of range coverage
- fill the range randomly with probe points
- use the node count as independent parameter
- measurement method *works as intended*
- results indeed show a linear relationship

Results are ''interesting'' however, since the (par,time) points
seem to be arranged into two lines, implying that about half
of the runs were somehow ''degraded'' and performed way slower.
2024-02-24 04:17:05 +01:00
a117e6e8c5 Scheduler-test: consider using a complementary measurement method
With the latest improvements, the »breaking point search« works as expected
and yields meaningful data; however — it seems to be well suited rather
for specific setups, which involve an extended graph with massive dependencies,
because only such a setup produces a clearly defined ''breaking point.''

Thus I'm considering to complement this research by another measurement setup
to establish a linear regression model of the Scheduler expense.

To allow integration of this different setup into the existing stress-test-rig,
some rearrangements of the builder notation are necessary; especially we need
to pass the type name of the actual tool, and it seems indicated to
reorder the source code to provide the config base class `StressRig`
at the top, followed by a long (and very technical) implementation
namespace.
2024-02-23 17:29:50 +01:00
93729e5667 Scheduler-test: more precise accounting for expected concurrency
It turns out to be not correct using all the divergence in concurrency
as a form factor, since it is quite common that not all cores can be active
at every level, given the structural constraints as dictated by the load graph.

On the other hand, if the empirical work (non wait-time) concurrency
systematically differs from the simple model used for establishing the schedule,
then this should indeed be considered a form factor and deduced from
the effective stress factor, since it is not a reserve available for speed-up

The solution entertained here is to derive an effective compounded sum
of weights from the calculation used to build the schedule. This compounded
weight sum is typically lower than the plain sum of all node weights, which
is precisely due to the theoretical amount of expense reduction assumed
in the schedule generation. So this gives us a handle at the theoretically
expected expense and through the plain weight sum, we may draw conclusion
about the effective concurrency expected in this schedule.

Taking only this part as base for the empirical deviations yields search results
very close to stressFactor ~1 -- implying that the test setup now
observes what was intended to observe...
2024-02-23 02:02:20 +01:00
2d1bd2b765 Scheduler-test: fix deficiencies in search control mechanism
In binary search, in order to establish the invariant initially,
a loop is necessary, since a single step might not be sufficient.

Moreover, the ongoing adjustments jeopardise detection of the
statistical breaking point condition, by causing a negative delta
due to gradually approaching the point of convergence -- leading
to an ongoing search in a region beyond the actual breaking point.
2024-02-19 17:38:04 +01:00
ff39aed7ea Scheduler-test: fix feedback adjustments for breaking point search
Various misconceptions identified in the feedback path of the test algorithm.
- statistics are cumulative, which must be incorporated by norming on time base
- average concurrency includes idle times, which is besides the point within this
  test setup, since additional wait-phases are injected when reducing stress
2024-02-19 17:38:04 +01:00
96df8b20f9 Scheduler-test: introduce a form-factor to account for empiric adaptation
Relying on the new instrumentation facility, the actually effective
concurrency and cumulative run time of the test jobs can be established.
These can now be cast into a form-factor to represent actual excess expenses
in relation to the theoretical model.

By allowing to adjust the adapted schedule by this form factor,
it can be made to reflect more closely the actual empiric load,
hopefully leading to a more realistic effect of the stress-factor
and thus results better suited to conclude on generic behaviour.
2024-02-18 18:01:21 +01:00
7efaf5f0cc Scheduler-test: document new instrumentation facility with simple test
...turns out rather challenging to come up with any test case,
that is both meaningful, simple to setup and understand, yet still
produces somewhat stable values. `IncidenceCount` seems most valuable
for investigation and direct inspection of results
2024-02-17 21:55:21 +01:00
0e7bdcc5b5 Scheduler-test: experiment with extended load and run time
Various experiments to watch Scheduler behaviour under extended load.
Notably the example committed here makes the Scheduler run for 1.2 sec
and process 800 jobs with 10ms each, thereby putting the system into
100% load on all CPUs
2024-02-16 03:45:27 +01:00
27b34c4ed6 Scheduler-test: complements and fixes for the instrumentation
- supplement the pre-dimensioning for data capture; without that,
  sporadic memory corruption indeed happens (as expected, since
  concurrent re-allocation of the vector with an entry for each
  thread is not threadsafe, and this test shows much contention)

- add a top-level logging for better diagnostics of errors
  emanating from the test run
2024-02-15 20:33:28 +01:00
3e1239bd71 Scheduler-test: integrate instrumentation as optional feature
...can be activated on the Test-Chain-Load
...add a test case to validate its operation
2024-02-15 02:43:44 +01:00
580c1f1f68 Scheduler-test: complete instrumentation helper
Verify proper operation under pressure
using a multithreaded stress test
2024-02-15 00:52:59 +01:00
d0c1017580 Scheduler-test: resolve inconsistency in time accounting for instrumentation
Basically users are free to place the measurement calls to their liking.
This implies that bracketed measurement intervals can be defined overlapping
even within a single thread, thereby accounting the overlapping time interval
several times. However, for the time spent per thread, only actual thread
activity should be counted, disregarding overlaps. Thus introduce a
new aggregate, ''active time'', which is the sum of all thread times.

As an aside, do not need explicit randomness for the simple two-thread
test case — timings are random anyway...

+ bugfix for out-of-bounds access
2024-02-14 19:59:14 +01:00
9f0878f885 Scheduler-test: implement accounting for concurrency for instrumentation
...since we've established already an integration over the event timeline,
it is just one simple further step to determine the concurrency level
on each individual segment of the timeline. Based on this attribution

- the averaged concurrenty within the observation range can be computed as weighted mean
- moreover we can account for the precise cumulated time spent at each concurrency level
2024-02-14 04:18:43 +01:00
a1abed68f4 Scheduler-test: implement differentiated statistics counting for instrumentation
...break down the integration of the activation count over time
   into individual accounting
   - for each caseID
   - for each thread
2024-02-13 02:25:52 +01:00
08847ae283 Scheduler-test: implement the simplest case for the instrumentation
...which is to account for the cumulative time spent in code
marked by bracketed measurement calls ("enter" ... "leave")
2024-02-12 21:43:57 +01:00
754b3a2ea6 Scheduler-test: define storage for instrumentation helper
...using a simplistic allocation of next-slot based on initialisation
of a thread_local storage. This implies that this helper can not be
reset or reused, and that there can not be multiple or long-lived instances.

Keep-it-simple for now...
2024-02-12 20:26:38 +01:00
a68adb0364 Scheduler-test: need some instrumentation helper
...to sort out the interpretation of measurement results,
the actual duration and concurrency of ComputationLoad invocations
should be recorded, allowing to draw conclusions regarding the
Scheduler's performance as opposed to further system and thread
management effects due to concurrent operation under pressure.
2024-02-12 18:01:43 +01:00
54a91bcd5a Scheduler-test: investigation...
...and reflection about goals, methods of measurement and possible interpretation
2024-02-11 17:38:20 +01:00
602b7dbe3a Scheduler-test: continue investigation - combine base expense with stress factor
After an extended break due to "real life issues"....
Pick up the investigation, with the goal to ascertain a valid definition
and understanding of all test parameters. A first step is to establish
a baseline ''without using a computational load''; this might be some kind
of base overhead of the scheduler.

However -- the way the test scaffolding was built, it is difficult to
create a feedback loop for the statistical test setup with binary search,
since it is not really clear how the single control parameter of the test algorithm,
the so called "stress factor", shall be interpreted and how it can be
combined with a base load.

An extended series of tests, while watching the observed value patterns qualitatively,
seems to corroborate the former results, indicating that the base expense
in my test setup (using a debug build) is at ~200µs / Node / core.

Yet the difficulty to interpret this result and arrive at a logical and generic model
prevents me from translating this into a measurement scheme, which can
be executed independently from a specific test setup and hardware
2024-02-11 03:53:42 +01:00
0aa1edf07c Scheduler-test: investigate behaviour of a load for stress testing
The goal is to devise a load more akin to the expected real-world processing patterns,
and then to increase the density to establish a breaking point.

Preliminary investigations focus on establishing the properties of this load
and to ensure the actual computation load behaves as expected.

Using the third Graph pattern prepared thus far, which produces
short chains of length=2, yet immediately spread out to maximum concurrency.
This leads to 5.8 Nodes / Level on average.
2024-02-10 18:58:41 +01:00
6a08c97543 Scheduler-test: fix Segfault in test setup
...as it turned out, this segfault was caused by flaws in the ScheduleCtx
used for generate the test-schedule; especially when all node-spreads are set
to zero and thus all jobs are scheduled immediately at t=0, there was a loophole
in the logic to set the dependencies for the final »wake-up« job.

When running such a schedule in the Stress-Test-Bench, the next measurement run
could be started due to a premature wake-up job, thereby overrunning the previous
test-run, which could be still in the middle of computations.

So this was not a bug in the Scheduler itself, yet something to take care of
later when programming the actual Job-Planning and schedule generation.
2024-01-11 23:11:21 +01:00
81d4b5d323 Scheduler-test: setup in Stress-Test-Rig
...use the scheme established thus far
2024-01-10 20:39:20 +01:00
3674d82bdf Scheduler-test: next goal -- massively parallel work jobs
Search processing pattern for massive parallel test.
The goal is to get all cores into active processing most of the time,
thus we need a graph with low dependency management overhead, which is
also consistently wide horizontally to have several jobs in working state
all of the time. The investigation aims at finding out about systematic
overheads in such a setup.
2024-01-10 20:34:09 +01:00