From e761447a252356c23de67acca1f78f69dc0f9921 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Wed, 6 Dec 2023 02:17:02 +0100 Subject: [PATCH] Chain-Load: setup simple integration test - use a chain-load with 64 steps - use a simple topology - trigger test run with default stepping TODO: Test hangs -> Timeout --- src/lib/uninitialised-storage.hpp | 2 +- src/vault/gear/scheduler.hpp | 26 ++++++----- tests/vault/gear/test-chain-load-test.cpp | 24 ++++++++-- tests/vault/gear/test-chain-load.hpp | 45 ++++++++++++------- wiki/thinkPad.ichthyo.mm | 55 ++++++++++++++++++----- 5 files changed, 112 insertions(+), 40 deletions(-) diff --git a/src/lib/uninitialised-storage.hpp b/src/lib/uninitialised-storage.hpp index 3e6970d2e..3f28f0d11 100644 --- a/src/lib/uninitialised-storage.hpp +++ b/src/lib/uninitialised-storage.hpp @@ -146,7 +146,7 @@ namespace lib { { if (buff_) discard(); size_ = cnt; - buff_ = cnt? std::aligned_alloc (std::alignment_of(), cnt * sizeof(T)) + buff_ = cnt? static_cast (std::aligned_alloc (std::alignment_of(), cnt * sizeof(T))) : nullptr; return buff_; } diff --git a/src/vault/gear/scheduler.hpp b/src/vault/gear/scheduler.hpp index da61a4b2b..7ed957a9e 100644 --- a/src/vault/gear/scheduler.hpp +++ b/src/vault/gear/scheduler.hpp @@ -157,13 +157,13 @@ namespace gear { ManifestationID manID_{}; bool isCompulsory_{false}; - Scheduler& theScheduler_; + Scheduler* theScheduler_; std::optional term_; public: ScheduleSpec (Scheduler& sched, Job job) : job_{job} - , theScheduler_{sched} + , theScheduler_{&sched} , term_{std::nullopt} { } @@ -174,6 +174,13 @@ namespace gear { return move(*this); } + ScheduleSpec + startTime (Time fixedTime) + { + start_ = fixedTime; + return move(*this); + } + ScheduleSpec lifeWindow (microseconds afterStart) { @@ -565,15 +572,14 @@ namespace gear { ScheduleSpec::post() { term_ = move( - theScheduler_ - .activityLang_ - .buildCalculationJob (job_, start_,death_)); + theScheduler_->activityLang_ + .buildCalculationJob (job_, start_,death_)); //set up new schedule by retrieving the Activity-chain... - theScheduler_.postChain ({term_->post(), start_ - , death_ - , manID_ - , isCompulsory_}); - theScheduler_.ensureDroppedGroomingToken(); + theScheduler_->postChain ({term_->post(), start_ + , death_ + , manID_ + , isCompulsory_}); + theScheduler_->ensureDroppedGroomingToken(); return move(*this); } diff --git a/tests/vault/gear/test-chain-load-test.cpp b/tests/vault/gear/test-chain-load-test.cpp index 5601a596d..e0c04834d 100644 --- a/tests/vault/gear/test-chain-load-test.cpp +++ b/tests/vault/gear/test-chain-load-test.cpp @@ -76,7 +76,7 @@ namespace test { virtual void run (Arg) { - simpleUsage(); + usageExample(); verify_Node(); verify_Topology(); showcase_Expansion(); @@ -93,9 +93,27 @@ namespace test { * @todo WIP 11/23 🔁 define ⟶ 🔁 implement */ void - simpleUsage() + usageExample() { - TestChainLoad testLoad; + auto anchor = RealClock::now(); + auto offset = [&](Time when =RealClock::now()){ return _raw(when) - _raw(anchor); }; + + auto testLoad = + TestChainLoad{64} + .configureShape_simple_short_segments() + .buildToplolgy(); +SHOW_EXPR(offset()) + + BlockFlowAlloc bFlow; + EngineObserver watch; + Scheduler scheduler{bFlow, watch}; + +SHOW_EXPR(testLoad.getHash()) +SHOW_EXPR(offset()) + testLoad.setupSchedule(scheduler) + .launch_and_wait(); +SHOW_EXPR(offset()) +SHOW_EXPR(testLoad.getHash()) } diff --git a/tests/vault/gear/test-chain-load.hpp b/tests/vault/gear/test-chain-load.hpp index 1d7051b80..2171a7887 100644 --- a/tests/vault/gear/test-chain-load.hpp +++ b/tests/vault/gear/test-chain-load.hpp @@ -309,7 +309,7 @@ namespace test { } - size_t size() const { return afterNode() - frontNode(); } + size_t size() const { return numNodes_; } size_t topLevel() const { return unConst(this)->backNode()->level; } size_t getSeed() const { return unConst(this)->frontNode()->hash; } size_t getHash() const { return unConst(this)->backNode()->hash; } /////////////////////TODO combine hash of all exit nodes @@ -407,6 +407,17 @@ namespace test { : Rule().probability(p2).maxVal(v); }); } + + + /** preconfigured topology: simple interwoven 3-step graph segments */ + TestChainLoad&& + configureShape_simple_short_segments() + { + seedingRule(rule().probability(0.8).maxVal(1)); + reductionRule(rule().probability(0.75).maxVal(3)); + pruningRule(rule_atJoin(1)); + return move(*this); + } @@ -1229,8 +1240,8 @@ namespace test { std::promise signalDone_{}; - RandomChainCalcFunctor calcFunctor_; - RandomChainPlanFunctor planFunctor_; + std::unique_ptr> calcFunctor_; + std::unique_ptr> planFunctor_; /* ==== Callbacks from job planning ==== */ @@ -1286,12 +1297,12 @@ namespace test { ScheduleCtx (TestChainLoad& mother, Scheduler& scheduler) : chainLoad_{mother} , scheduler_{scheduler} - , calcFunctor_{chainLoad_.nodes_[0]} - , planFunctor_{chainLoad_.nodes_[0], chainLoad_.numNodes_ - ,[this](size_t i, size_t l){ disposeStep(i,l); } - ,[this](auto* p, auto* s) { setDependency(p,s);} - ,[this](size_t l, bool w) { continuation(l,w); } - } + , calcFunctor_{new RandomChainCalcFunctor{chainLoad_.nodes_[0]}} + , planFunctor_{new RandomChainPlanFunctor{chainLoad_.nodes_[0], chainLoad_.numNodes_ + ,[this](size_t i, size_t l){ disposeStep(i,l); } + ,[this](auto* p, auto* s) { setDependency(p,s);} + ,[this](size_t l, bool w) { continuation(l,w); } + }} { } ScheduleCtx @@ -1324,18 +1335,18 @@ namespace test { Job calcJob (size_t idx, size_t level) { - return Job{calcFunctor_ - ,calcFunctor_.encodeNodeID(idx) - ,calcFunctor_.encodeLevel(level) + return Job{*calcFunctor_ + , calcFunctor_->encodeNodeID(idx) + , calcFunctor_->encodeLevel(level) }; } Job planningJob (size_t level) { - return Job{planFunctor_ - ,InvocationInstanceID() - ,planFunctor_.encodeLevel(level) + return Job{*planFunctor_ + , InvocationInstanceID() + , planFunctor_->encodeLevel(level) }; } @@ -1360,7 +1371,7 @@ namespace test { Time calcStartTime(size_t level) { - return startTime_ + level / levelSpeed_; + return startTime_ + Time{level / levelSpeed_}; } Time @@ -1380,11 +1391,13 @@ namespace test { /** * establish and configure the context used for scheduling computations. + * @note clears hashes and re-propagates seed in the node graph beforehand. */ template typename TestChainLoad::ScheduleCtx TestChainLoad::setupSchedule(Scheduler& scheduler) { + clearNodeHashes(); return ScheduleCtx{*this, scheduler}; } diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index b42eb6929..1f5e346a3 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -96528,9 +96528,9 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- - - + + + @@ -96540,6 +96540,16 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
+ + + + + + + + + +
@@ -100621,11 +100631,11 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- - + + - + @@ -100634,8 +100644,8 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- - + + @@ -100701,7 +100711,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + @@ -101035,7 +101045,23 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + + + + + + + + +

+ ...und das ist gut so +

+ + +
+
+
+ @@ -101095,6 +101121,15 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
+ + + + + + + + +