Scheduler-test: fix bug in WorkForce scaling logic

this bug was there since the first draft, yet was covered
by another bug with the start-up logic.
And this latter one was fixed recently...

fa8622805

As a result, even when the COMPUTATION_CAPACITY is set to 0
still a single worker boots up (which should not be the case)

Solution: we do not need to "safeguard" against rounding errors,
since this is an internal implementation function, it is assumed
that the caller knows about its limitations...
This commit is contained in:
Fischlurch 2023-12-12 01:20:02 +01:00
parent 69faaef8cd
commit b0bde3f0b2
2 changed files with 85 additions and 3 deletions

View file

@ -79,6 +79,10 @@ namespace gear {
using std::this_thread::sleep_for;
namespace {
const double MAX_OVERPROVISIONING = 3.0; ///< safety guard to prevent catastrophic overprovisioning
}
namespace work { ///< Details of WorkForce (worker pool) implementation
using SIG_WorkFun = activity::Proc(void); ///< config should define a callable with this signature to perform work
@ -227,8 +231,7 @@ namespace gear {
activate (double degree =1.0)
{
size_t scale{setup_.COMPUTATION_CAPACITY};
scale *= degree;
scale = util::max (scale, 1u);
scale = size_t(util::limited (0.0, degree*scale, scale*MAX_OVERPROVISIONING));
for (uint i = workers_.size(); i < scale; ++i)
workers_.emplace_back (setup_);
}

View file

@ -93345,9 +93345,82 @@ Date:&#160;&#160;&#160;Thu Apr 20 18:53:17 2023 +0200<br/>
<node CREATED="1702234306657" ID="ID_1728259651" MODIFIED="1702234310206" TEXT="nur ein Peak"/>
<node CREATED="1702234311390" ID="ID_95265558" MODIFIED="1702234322625" TEXT="worker contention"/>
</node>
<node BACKGROUND_COLOR="#fafe99" COLOR="#fa002a" CREATED="1702234301008" ID="ID_132335253" MODIFIED="1702234303095" TEXT="scheduleRenderJob">
<node COLOR="#435e98" CREATED="1702234301008" FOLDED="true" ID="ID_132335253" MODIFIED="1702347285923" TEXT="scheduleRenderJob">
<icon BUILTIN="broken-line"/>
<node CREATED="1702234374318" ID="ID_1831453840" MODIFIED="1702234384625" TEXT="soeben eingestellte Activity nicht in der Queue"/>
<node CREATED="1702344257654" ID="ID_686900739" MODIFIED="1702347271976" TEXT="tritt nur sporadisch auf...">
<icon BUILTIN="idea"/>
<node CREATED="1702347274895" ID="ID_1782602321" MODIFIED="1702347282455" TEXT="someone ate my input..."/>
</node>
<node COLOR="#435e98" CREATED="1702344521356" FOLDED="true" ID="ID_904731331" MODIFIED="1702347268452" TEXT="Beobachtungen">
<icon BUILTIN="forward"/>
<node CREATED="1702344526046" ID="ID_1806596915" MODIFIED="1702344533262" TEXT="mit Trace: workForce = 1">
<node CREATED="1702344545240" ID="ID_1752776564" MODIFIED="1702344553736" TEXT="sollte aber ganz deaktiviert sein"/>
<node CREATED="1702345305947" ID="ID_1151751464" MODIFIED="1702345324131" TEXT="verifiziert: COMPUTATION_CAPCITY == 0 f&#xfc;r diesen Test"/>
</node>
<node CREATED="1702345348585" ID="ID_109233665" MODIFIED="1702345352872" TEXT="Code lesen....">
<node CREATED="1702345362481" ID="ID_1800588084" MODIFIED="1702345375972" TEXT="ignite() -&gt; workForce_.activate()"/>
<node BACKGROUND_COLOR="#e0ceaa" COLOR="#690f14" CREATED="1702345376866" ID="ID_629547664" MODIFIED="1702347261596" TEXT="in letzterem ist ein Guard der size &gt; 0 erzwingt">
<icon BUILTIN="messagebox_warning"/>
<node CREATED="1702345407740" ID="ID_1279580563" MODIFIED="1702345416573" TEXT="der war aber im September auch schon da"/>
<node CREATED="1702345417123" ID="ID_1109053724" MODIFIED="1702345439756" TEXT="nur hatte ich den Logik-Fehler, der bisher ignite() oft leer durchallen lie&#xdf;"/>
<node BACKGROUND_COLOR="#e0ceaa" COLOR="#690f14" CREATED="1702345440560" ID="ID_28011033" MODIFIED="1702345475541" TEXT="Bug behoben &#x27f9; anderer Bug aufgedeckt">
<icon BUILTIN="clanbomber"/>
</node>
</node>
</node>
<node COLOR="#338800" CREATED="1702345502727" ID="ID_1257094428" MODIFIED="1702347221841" TEXT="Fix: Schutzbedingung anpassen">
<icon BUILTIN="button_ok"/>
<node COLOR="#435e98" CREATED="1702345520877" ID="ID_1132821345" MODIFIED="1702347220065" TEXT="was sollte die bewirken?">
<icon BUILTIN="help"/>
<node CREATED="1702345592854" ID="ID_1087381356" MODIFIED="1702345637011" TEXT="b8e52d008c15d">
<richcontent TYPE="NOTE"><html>
<head>
</head>
<body>
<p>
2023-09-07 17:15:25
</p>
<p>
Workforce: configuration and initialisation of workers
</p>
</body>
</html>
</richcontent>
</node>
<node CREATED="1702345675963" ID="ID_569519663" MODIFIED="1702346301584" TEXT="lt.Changeset: versehentliches Abrunden auf Gr&#xf6;&#xdf;e 0"/>
<node CREATED="1702346302288" ID="ID_1943758650" MODIFIED="1702346400530" TEXT="das erscheint mir nun etwas &#xfc;bervorsichtig">
<richcontent TYPE="NOTE"><html>
<head>
</head>
<body>
<p>
es pa&#223;t nicht zum Stil im gesamten Kontext; wir sind hier in Implementierungs-Code, der grunds&#228;tzlich davon ausgeht, nur sinnvoll aufgerufen zu werden &#8212; es geht nicht darum, einen User &#8222;an die Hand zu nehmen&#8220;
</p>
</body>
</html>
</richcontent>
</node>
</node>
<node CREATED="1702345822891" ID="ID_1283033928" MODIFIED="1702345841078" TEXT="Achtung: overprovisioning ist hier explizit erw&#xfc;nscht">
<icon BUILTIN="messagebox_warning"/>
</node>
<node COLOR="#338800" CREATED="1702346271019" ID="ID_45212470" MODIFIED="1702347215799" TEXT="Limit auf 0 absenken">
<icon BUILTIN="yes"/>
<node CREATED="1702346428582" ID="ID_1447148274" MODIFIED="1702346442804" TEXT="da sind noch diverse weitere signed/unsigned-Bugs begraben">
<icon BUILTIN="broken-line"/>
</node>
<node CREATED="1702347189829" ID="ID_1516910597" MODIFIED="1702347210096" TEXT="und eine Sicherheitsbarriere gegen katastrophales Overprovisioning fehlt auch">
<icon BUILTIN="yes"/>
</node>
</node>
</node>
</node>
<node COLOR="#338800" CREATED="1702347230739" ID="ID_1671987053" MODIFIED="1702347244201" TEXT="damit l&#xe4;uft der Testfall und die WorkForce bleibt so tot wie sie sein soll">
<icon BUILTIN="button_ok"/>
</node>
</node>
</node>
</node>
@ -95970,6 +96043,12 @@ Date:&#160;&#160;&#160;Thu Apr 20 18:53:17 2023 +0200<br/>
<icon BUILTIN="flag-yellow"/>
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1701906105012" ID="ID_729619994" LINK="#ID_1544079509" MODIFIED="1701980947285" TEXT="TestChainLoad entwickeln">
<icon BUILTIN="pencil"/>
<node COLOR="#338800" CREATED="1702343802187" ID="ID_1802324742" MODIFIED="1702343815748" TEXT="Technologie entwickelt und getestet">
<icon BUILTIN="button_ok"/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1702343816764" ID="ID_98413203" MODIFIED="1702343848111" TEXT="Muster zur Integration aufbauen">
<icon BUILTIN="flag-yellow"/>
</node>
</node>
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1701906154358" ID="ID_439708583" MODIFIED="1701906163997" TEXT="einfacher Funktionstest">
<icon BUILTIN="pencil"/>