Block-Flow: investigate proper working of on-demand allocation

Library: add "obvious" utility to the IterExplorer, allowing to
         materialise all contents of the Pipeline into a container

...use this to take a snapshot of all currently active Extent addresses
This commit is contained in:
Fischlurch 2023-07-12 19:19:41 +02:00
parent f5813a1f29
commit 824a626c2e
7 changed files with 183 additions and 24 deletions

View file

@ -155,7 +155,7 @@ namespace diff{
/**
* Convenience builder for consuming an brace enclosed initializer_list
* @note initialiser elements will be _copied_ into a _heap alloacated_
* @note initialiser elements will be _copied_ into a _heap allocated_
* snapshot (vector), which is then managed by `shared_ptr`
*/
MutationMessage(std::initializer_list<DiffStep> const&& ili)

View file

@ -242,7 +242,7 @@ namespace lib {
if (i_.isValid())
currPtr_ = & (*i_);
else
currPtr_ = 0;
currPtr_ = nullptr;
}

View file

@ -118,6 +118,12 @@
#include <utility>
//Forward declaration to allow a default result container for IterExplorer::effuse
namespace std {
template<typename T, class A> class vector;
}
namespace lib {
using std::move;
@ -1695,6 +1701,38 @@ namespace lib {
{
return SRC {move(*this)};
}
/** _terminal builder_ to pour and materialise all results from this Pipeline.
* @tparam CON a STL compliant container to store generated values (defaults to `vector`)
* @return new instance of the target container, filled with all values
* pulled from this Pipeline until exhaustion.
*/
template<template<typename> class CON =std::vector>
auto
effuse()
{
CON<value_type> con{};
this->effuse (con);
return con;
}
template<class CON>
auto
effuse (CON&& sink) -> CON
{
CON con{move(sink)};
this->effuse (con);
return con;
}
/** _terminal builder to fill an existing container with all results from this Pipeline */
template<class CON>
void
effuse (CON& con)
{
for (auto& val : *this)
con.push_back (val);
}
};

View file

@ -45,7 +45,6 @@
#include "vault/common.hpp"
//#include "lib/symbol.hpp"
#include "lib/iter-adapter.hpp"
#include "lib/nocopy.hpp"
#include "lib/util.hpp"
@ -70,6 +69,10 @@ namespace mem {
/**
* Memory manager to provide a sequence of Extents for cyclic usage.
* Storage extents, once allocated, will be re-used without invoking any
* ctors or dtors on the objects nominally located in »slots« within the Extent.
* @tparam T payload type living in the Extent's »slots«
* @tparam siz number of »slots« per Extent
* @todo WIP-WIP 7/2023
* @see ExtentFamily_test
*/
@ -77,12 +80,13 @@ namespace mem {
class ExtentFamily
: util::NonCopyable
{
/** number of excess new extents
* to add whenever new storage is required
*/
/** number of excess new extents to add
* whenever new storage is required */
static const size_t EXCESS_ALLOC{5};
public:
/** logical structure of a memory Extent */
struct Extent
: std::array<T,siz>
{
@ -90,7 +94,9 @@ namespace mem {
using SIZ = std::integral_constant<size_t,siz>;
};
private:
/** Entry in the Extents management datastructure */
struct Storage
: std::unique_ptr<char[]>
{
@ -168,7 +174,7 @@ namespace mem {
void
reserve (size_t expectedMaxExtents)
{
{ // pertaining management data only
extents_.reserve (expectedMaxExtents);
}
@ -183,7 +189,7 @@ namespace mem {
openNew (size_t cnt =1)
{
if (not canAccomodate (cnt))
{//insufficient reserve -> allocate
{//insufficient reserve => allocate
size_t oldSiz = extents_.size();
size_t addSiz = cnt - freeSlotCnt()
+ EXCESS_ALLOC;
@ -211,7 +217,7 @@ namespace mem {
{
REQUIRE (cnt <= activeSlotCnt());
incWrap (start_, cnt);
} ////////////////////////////////////////////////////////////////////////////TICKET #1316 : should reduce excess allocation (with apropriate damping to avoid oscillations)
} ////////////////////////////////////////////////////////////////////////////TICKET #1316 : should reduce excess allocation (with appropriate damping to avoid oscillations)
/** allow transparent iteration of Extents,
@ -223,12 +229,15 @@ namespace mem {
void expandAlloc(){ this->stateCore().exFam->openNew();}
};
/** iterate over all the currently active Extents */
iterator begin() { return iterator{IdxLink{this, start_}}; }
iterator end() { return iterator{IdxLink{this, after_}}; }
friend iterator begin (ExtentFamily& exFam) { return exFam.begin(); }
friend iterator end (ExtentFamily& exFam) { return exFam.end(); }
private:
private: /* ====== storage management implementation ====== */
bool
isWrapped() const
{
@ -249,7 +258,7 @@ namespace mem {
size_t
freeSlotCnt() const
{ // always keep one in reserve...
{ // always keep one in reserve...
REQUIRE (activeSlotCnt() < extents_.size());
return extents_.size() - activeSlotCnt();
@ -258,8 +267,9 @@ namespace mem {
bool
canAccomodate (size_t addCnt) const
{
return addCnt < freeSlotCnt(); // keep one in reserve
}
return addCnt < freeSlotCnt();
} // keep one in reserve to allow for
// unambiguous iteration end in wrapped state
/** increment index, but wrap at array end.
* @remark using the array cyclically

View file

@ -115,6 +115,13 @@ namespace test{
if (not checkPoint()) return;
--p;
}
bool
operator== (CountDown const& o) const
{
return e == o.e
and p == o.p;
}
};
@ -279,6 +286,7 @@ namespace test{
verify_FilterChanges();
verify_asIterSource();
verify_IterSource();
verify_effuse();
verify_depthFirstExploration();
demonstrate_LayeredEvaluation();
@ -1061,6 +1069,24 @@ namespace test{
/** @test verify _terminal operation_ to append all results into a container.
*/
void
verify_effuse()
{
auto solidified = explore(CountDown{20})
.filter ([](uint i){ return i % 2; })
.transform([](uint i){ return 0.5*i; })
.effuse();
using Res = decltype(solidified);
CHECK (lib::test::showType<Res>() == "vector<double>"_expect);
CHECK (util::join(solidified, "|") == "9.5|8.5|7.5|6.5|5.5|4.5|3.5|2.5|1.5|0.5"_expect);
}
/** @test package the resulting Iterator as automatically managed,
* polymorphic opaque entity implementing the IterSource interface.
* The builder operations on IterExplorer each generate a distinct, implementation

View file

@ -29,7 +29,8 @@
#include "vault/mem/extent-family.hpp"
//#include "lib/time/timevalue.hpp"
//#include "lib/format-cout.hpp"////////////////////TODO
#include "lib/test/diagnostic-output.hpp"
#include "lib/test/diagnostic-output.hpp"////////////////////TODO
#include "lib/iter-explorer.hpp"
//#include "lib/util.hpp"
#include <utility>
@ -38,6 +39,7 @@ using test::Test;
//using std::move;
using util::isnil;
using util::isSameObject;
using lib::explore;
namespace vault{
@ -99,7 +101,7 @@ namespace test {
void
use_and_drop()
{
ExtentFamily<int, 10> extents{5};
Extents extents{5};
CHECK ( 0 == watch(extents).first());
CHECK ( 0 == watch(extents).last());
CHECK ( 0 == watch(extents).active());
@ -180,7 +182,7 @@ namespace test {
~Probe() { val = 0; }
};
using SpecialExtents = ExtentFamily<Probe, 100>;
using SpecialExtents = ExtentFamily<Probe, 1000>;
SpecialExtents spex{3};
spex.openNew(2);
@ -245,6 +247,39 @@ namespace test {
void
wrapAround()
{
Extents extents{5};
CHECK ( 0 == watch(extents).first());
CHECK ( 0 == watch(extents).last());
CHECK ( 0 == watch(extents).active());
CHECK ( 5 == watch(extents).size());
extents.openNew(4);
CHECK ( 0 == watch(extents).first());
CHECK ( 4 == watch(extents).last());
CHECK ( 4 == watch(extents).active());
CHECK ( 5 == watch(extents).size());
auto takeAdr = [](auto& x){ return &*x; };
auto snapshot = explore(extents).transform(takeAdr).effuse();
SHOW_EXPR(snapshot.size())
SHOW_EXPR(snapshot[0])
SHOW_EXPR(snapshot[3])
extents.openNew();
SHOW_EXPR(watch(extents).first())
SHOW_EXPR(watch(extents).last())
SHOW_EXPR(watch(extents).active())
SHOW_EXPR(watch(extents).size())
CHECK ( 0 == watch(extents).first());
CHECK ( 5 == watch(extents).last());
CHECK ( 5 == watch(extents).active());
CHECK (10 == watch(extents).size()); // Note: heuristics to over-allocate to some degree
auto it = extents.begin();
for (auto oldAddr : snapshot)
{
CHECK (isSameObject(*oldAddr, *it));
++it;
}
}
};

View file

@ -78083,6 +78083,30 @@ Date:&#160;&#160;&#160;Thu Apr 20 18:53:17 2023 +0200<br/>
<node CREATED="1688998737324" ID="ID_1359190642" MODIFIED="1688998829651" TEXT="GATE">
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1688998831183" ID="ID_158897194" MODIFIED="1688998848054" TEXT="Inhibitor-Mechanismus mu&#xdf; zu fr&#xfc;he Freigabe verhindern">
<icon BUILTIN="flag-yellow"/>
<node BACKGROUND_COLOR="#fdfdcf" COLOR="#ff0000" CREATED="1689169379528" ID="ID_130475381" MODIFIED="1689169406964" TEXT="stellt sich die Frage nach Regel und Ausnahme">
<icon BUILTIN="yes"/>
</node>
<node CREATED="1689169457943" ID="ID_1317092933" MODIFIED="1689169572378" TEXT="man k&#xf6;nnte ein NOTIFY explizit disponieren">
<richcontent TYPE="NOTE"><html>
<head></head>
<body>
<p>
dieses w&#252;rde auch auf das GATE aufgeschaltet, welches dadurch mit einem h&#246;heren Latch startet; erst nachdem das NOTIFY eigens aktiviert wurde, k&#246;nnte das GATE grunds&#228;tzlich freigeben
</p>
</body>
</html></richcontent>
<icon BUILTIN="idea"/>
</node>
<node CREATED="1689169614354" ID="ID_969910286" MODIFIED="1689169702944" TEXT="man k&#xf6;nnte aber auch genau den gleichen Mechanismus direkt in GATE einbauen">
<richcontent TYPE="NOTE"><html>
<head></head>
<body>
<p>
dazu allerdings m&#252;&#223;te dieses unterscheiden k&#246;nnen, ob es vom Scheduler explizit aktiviert wird, oder ob es durch eine Notification freigeschaltet wurde
</p>
</body>
</html></richcontent>
</node>
</node>
<node CREATED="1688998857100" ID="ID_875955760" MODIFIED="1688998863575" TEXT="Deadline aus POST-Deadline"/>
<node CREATED="1688998870698" ID="ID_40546286" MODIFIED="1688998883188" TEXT="Latch zun&#xe4;chst nicht gesperrt"/>
@ -78414,6 +78438,10 @@ Date:&#160;&#160;&#160;Thu Apr 20 18:53:17 2023 +0200<br/>
<icon BUILTIN="flag-yellow"/>
</node>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1689170049231" ID="ID_1688483414" MODIFIED="1689171254550" TEXT="Threadpool">
<arrowlink COLOR="#694db0" DESTINATION="ID_196314311" ENDARROW="Default" ENDINCLINATION="-56;-43;" ID="Arrow_ID_814147501" STARTARROW="None" STARTINCLINATION="-394;72;"/>
<icon BUILTIN="flag-yellow"/>
</node>
</node>
</node>
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1687737433506" ID="ID_1608121280" MODIFIED="1687737442698" TEXT="einfacher Activity-Transport">
@ -78528,6 +78556,14 @@ Date:&#160;&#160;&#160;Thu Apr 20 18:53:17 2023 +0200<br/>
</node>
</node>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1689170064181" HGAP="5" ID="ID_987966047" MODIFIED="1689170075605" TEXT="WorkForce zur Ausf&#xfc;hrung" VSHIFT="7">
<icon BUILTIN="flag-yellow"/>
<node BACKGROUND_COLOR="#fdfdcf" COLOR="#ff0000" CREATED="1689170081403" ID="ID_196314311" MODIFIED="1689171233757" TEXT="Technologie-Entscheidung">
<linktarget COLOR="#694db0" DESTINATION="ID_196314311" ENDARROW="Default" ENDINCLINATION="-56;-43;" ID="Arrow_ID_814147501" SOURCE="ID_1688483414" STARTARROW="None" STARTINCLINATION="-394;72;"/>
<linktarget COLOR="#b22e63" DESTINATION="ID_196314311" ENDARROW="Default" ENDINCLINATION="-1383;-51;" ID="Arrow_ID_134934445" SOURCE="ID_14638704" STARTARROW="None" STARTINCLINATION="-753;40;"/>
<icon BUILTIN="bell"/>
</node>
</node>
</node>
<node CREATED="1680565476652" ID="ID_1218283238" MODIFIED="1684973201854" TEXT="Dependency-Notification">
<linktarget COLOR="#fec499" DESTINATION="ID_1218283238" ENDARROW="Default" ENDINCLINATION="-664;74;" ID="Arrow_ID_443600884" SOURCE="ID_695181807" STARTARROW="None" STARTINCLINATION="-240;29;"/>
@ -78818,8 +78854,11 @@ Date:&#160;&#160;&#160;Thu Apr 20 18:53:17 2023 +0200<br/>
<icon BUILTIN="button_ok"/>
</node>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1688863046274" ID="ID_121256425" MODIFIED="1688863054657" TEXT="iteration mit wrap-around">
<icon BUILTIN="flag-yellow"/>
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1688863046274" ID="ID_121256425" MODIFIED="1689182097866" TEXT="iteration mit wrap-around">
<icon BUILTIN="pencil"/>
<node COLOR="#338800" CREATED="1689182063013" ID="ID_750255233" MODIFIED="1689182092157" TEXT="Diagnose: Iterator-Stellung und allozierte Addressen pr&#xfc;fen">
<icon BUILTIN="button_ok"/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1688863075348" ID="ID_619946525" MODIFIED="1688863105883" TEXT="Iteration in Normal-Stellung alloziert am Ende">
<icon BUILTIN="flag-yellow"/>
</node>
@ -86677,7 +86716,9 @@ class Something
</node>
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1679783177087" HGAP="29" ID="ID_1020455743" MODIFIED="1679783192799" TEXT="vorantreiben" VSHIFT="3">
<icon BUILTIN="pencil"/>
<node CREATED="1679783641511" ID="ID_212214057" MODIFIED="1679783643195" TEXT="Tickets">
<node BACKGROUND_COLOR="#e0ceaa" COLOR="#690f14" CREATED="1679783641511" ID="ID_212214057" MODIFIED="1689171338665" TEXT="Tickets">
<font BOLD="true" NAME="SansSerif" SIZE="12"/>
<icon BUILTIN="list"/>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1680141126520" ID="ID_1147697662" LINK="https://issues.lumiera.org/ticket/1273" MODIFIED="1680141154614" TEXT="#1273 Viewer-Connection Concept">
<icon BUILTIN="flag-yellow"/>
<node BACKGROUND_COLOR="#fdfdcf" COLOR="#ff0000" CREATED="1680141166647" ID="ID_1634794257" MODIFIED="1680141390579" TEXT="Das Wiring-Konzept von 2015 ist in dieser Hinsicht noch nicht fertig">
@ -86758,6 +86799,7 @@ class Something
<icon BUILTIN="flag-yellow"/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1680380228657" ID="ID_14638704" LINK="https://issues.lumiera.org/ticket/1279" MODIFIED="1680382013522" TEXT="#1279 provide technology for worker threads">
<arrowlink COLOR="#b22e63" DESTINATION="ID_196314311" ENDARROW="Default" ENDINCLINATION="-1383;-51;" ID="Arrow_ID_134934445" STARTARROW="None" STARTINCLINATION="-753;40;"/>
<icon BUILTIN="flag-yellow"/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1680381903590" ID="ID_833824994" LINK="https://issues.lumiera.org/ticket/1280" MODIFIED="1680382032313" TEXT="#1280 build Scheduler implementation">
@ -86815,6 +86857,14 @@ class Something
<icon BUILTIN="flag-yellow"/>
</node>
</node>
<node CREATED="1689171353019" ID="ID_1923378280" MODIFIED="1689171356858" TEXT="Architektur">
<node BACKGROUND_COLOR="#e0ceaa" COLOR="#690f14" CREATED="1689171357870" ID="ID_427389282" MODIFIED="1689171374221" TEXT="Scheduler ist ein Service">
<icon BUILTIN="yes"/>
</node>
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1689171388218" ID="ID_222695872" MODIFIED="1689171407366" TEXT="Extent/Epoc-based memory allocation">
<icon BUILTIN="yes"/>
</node>
</node>
</node>
<node CREATED="1679783675979" ID="ID_312162112" MODIFIED="1679783688045" TEXT="neu bauen">
<node BACKGROUND_COLOR="#d2beaf" COLOR="#5c4d6e" CREATED="1680561793925" ID="ID_961883511" MODIFIED="1680567189685" TEXT="Video-Widget">
@ -86835,13 +86885,13 @@ class Something
</node>
<node BACKGROUND_COLOR="#d2beaf" COLOR="#5c4d6e" CREATED="1680561888985" ID="ID_1736473881" MODIFIED="1680563326133" TEXT="Scheduler">
<icon BUILTIN="hourglass"/>
<node BACKGROUND_COLOR="#d2beaf" COLOR="#5c4d6e" CREATED="1680561892270" ID="ID_12567096" MODIFIED="1680566937368" TEXT="Layer-1 : PriQueue">
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1680561892270" ID="ID_12567096" MODIFIED="1689170140108" TEXT="Layer-1 : PriQueue">
<arrowlink COLOR="#fec499" DESTINATION="ID_250843894" ENDARROW="Default" ENDINCLINATION="-644;84;" ID="Arrow_ID_1702721830" STARTARROW="None" STARTINCLINATION="-233;30;"/>
<icon BUILTIN="hourglass"/>
<icon BUILTIN="pencil"/>
</node>
<node BACKGROUND_COLOR="#d2beaf" COLOR="#5c4d6e" CREATED="1680561901447" ID="ID_695181807" MODIFIED="1680566934008" TEXT="Layer-2 : Notification">
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1680561901447" ID="ID_695181807" MODIFIED="1689170140108" TEXT="Layer-2 : Notification">
<arrowlink COLOR="#fec499" DESTINATION="ID_1218283238" ENDARROW="Default" ENDINCLINATION="-664;74;" ID="Arrow_ID_443600884" STARTARROW="None" STARTINCLINATION="-240;29;"/>
<icon BUILTIN="hourglass"/>
<icon BUILTIN="pencil"/>
</node>
</node>
</node>