From 5033674b00cc9d25769f2e79acd88bf1703f73dc Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Thu, 23 Nov 2023 20:55:30 +0100 Subject: [PATCH] Chain-Load: define bindings to use the new RandomDraw component RandomDraw as a library component was extracted and (grossly) augmented to cut down the complexity exposed to the user of TestChainLoad. To control the generated topology, random-selected parameters must be configured, defining a probability profile; while this can be achieved with simple math, getting it correct turned out surprisingly difficult. --- tests/vault/gear/test-chain-load.hpp | 111 +++++++++++++++++++++++++++ wiki/thinkPad.ichthyo.mm | 86 ++++++++++++++++++++- 2 files changed, 194 insertions(+), 3 deletions(-) diff --git a/tests/vault/gear/test-chain-load.hpp b/tests/vault/gear/test-chain-load.hpp index a5191fbb8..64748df3f 100644 --- a/tests/vault/gear/test-chain-load.hpp +++ b/tests/vault/gear/test-chain-load.hpp @@ -87,6 +87,7 @@ //#include "lib/wrapper.hpp" #include "lib/iter-explorer.hpp" #include "lib/format-cout.hpp" +#include "lib/random-draw.hpp" #include "lib/dot-gen.hpp" #include "lib/util.hpp" @@ -117,6 +118,8 @@ namespace test { using util::unConst; using util::toString; using util::showHashLSB; + using lib::meta::_FunRet; + // using std::forward; // using std::string; using std::swap; @@ -170,6 +173,7 @@ namespace test { /** * A Generator for synthetic Render Jobs for Scheduler load testing. + * Allocates a fixed set of #numNodes and generates connecting toplology. * @tparam maxFan maximal fan-in/out from a node, also limits maximal parallel strands. * @see TestChainLoad_test */ @@ -179,6 +183,7 @@ namespace test { { public: + /** Graph Data structure */ struct Node : util::MoveOnly { @@ -263,6 +268,16 @@ namespace test { return hash; } }; + + + /** link Node.hash to random parameter generation */ + class NodeControlBinding; + + /** Parameter values limited [0 .. maxFan] */ + using Param = lib::Limited; + + /** Topology is governed by rules for random params */ + using Rule = lib::RandomDraw; private: using NodeTab = typename Node::Tab; @@ -478,5 +493,101 @@ namespace test { + /** + * Policy/Binding for generation of [random parameters](\ref TestChainLoad::Param) + * by [»drawing«](\ref random-draw.hpp) based on the [node-hash](\ref TestChainLoad::Node). + * Notably this policy template maps the ways to spell out [»Ctrl rules«](\ref TestChainLoad::Rule) + * to configure the probability profile of the topology parameters _seeding, expansion, reduction + * and pruning._ The RandomDraw component used to implement those rules provides a builder-DSL + * and accepts λ-bindings in various forms to influence mapping of Node hash into result parameters. + */ + template + class TestChainLoad::NodeControlBinding + : protected std::function + { + /** by default use Node-hash directly as source of randomness */ + static size_t + defaultSrc (Node* node) + { + return node? node->hash:0; + } + + static size_t + level (Node* node) + { + return node? node->level:0; + } + + static double + guessHeight (size_t level) + { // heuristic guess, typically too low + double expectedHeight = max (1u, numNodes/maxFan); + return level / expectedHeight; + } + + + + /** Adaptor to handle further mapping functions */ + template + struct Adaptor + { + static_assert (not sizeof(SIG), "Unable to adapt given functor."); + }; + + /** allow simple rules directly manipulating the hash value */ + template + struct Adaptor + { + template + static auto + build (FUN&& fun) + { + return [functor=std::forward(fun)] + (Node* node) -> _FunRet + { + return functor (defaultSrc (node)); + }; + } + }; + + /** allow rules additionally involving the height of the graph, + * which also represents time. 1.0 refers to (guessed) _full height. */ + template + struct Adaptor + { + + template + static auto + build (FUN&& fun) + { + return [functor=std::forward(fun)] + (Node* node) -> _FunRet + { + return functor (defaultSrc (node) + ,guessHeight(level(node))); + }; + } + }; + + /** rules may also build solely on the (guessed) height. */ + template + struct Adaptor + { + + template + static auto + build (FUN&& fun) + { + return [functor=std::forward(fun)] + (Node* node) -> _FunRet + { + return functor (guessHeight(level(node))); + }; + } + }; + }; + + + }}} // namespace vault::gear::test #endif /*VAULT_GEAR_TEST_TEST_CHAIN_LOAD_H*/ diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index a4c8f7f73..7511eb753 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -57641,6 +57641,33 @@ + + + + + + + +

+ RandomDraw: »ziehen« von zufälligen Parameterwerten +

+ +
+ + + + + + + + + + + + + + + @@ -95751,6 +95778,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
+ @@ -95769,6 +95797,18 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
+ + + + + + + + + + + + @@ -96244,6 +96284,8 @@ Date:   Thu Apr 20 18:53:17 2023 +0200

+ +
@@ -96266,10 +96308,14 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + + + - + + + @@ -96432,6 +96478,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
+ @@ -96695,7 +96742,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + @@ -96704,6 +96751,9 @@ Date:   Thu Apr 20 18:53:17 2023 +0200

+ + + @@ -97355,6 +97405,33 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
+ + + + +

+ das war ja gradezu der Keim, aus dem sich RandomDraw entwickelt hat +

+ +
+ +
+ + + + + + + +

+ TestChainLoad selber is parametrisiert auf die Maximalwerte der Topologie ⟹ alle Parameter haben typischerweise die Breiten-Limitierung als Obergrenze +

+ +
+
+ + +
@@ -97572,6 +97649,9 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
+ + +