diff --git a/src/steam/engine/diagnostic-buffer-provider.cpp b/src/steam/engine/diagnostic-buffer-provider.cpp index 791442347..b735f2d19 100644 --- a/src/steam/engine/diagnostic-buffer-provider.cpp +++ b/src/steam/engine/diagnostic-buffer-provider.cpp @@ -51,25 +51,18 @@ namespace engine { /* ====== Accounting API ====== */ - Block::Block (BuffDescr typeDescriptor, Key stateKey, Buff* mem) - : handle{typeDescriptor, mem} + Block::Block (Key key, Buff* mem) + : typeKey{mem? key.parentKey(): HashVal(key)} + , stateKey{mem? key : Key::INVALID} + , buffSize{key.storageSize()} , storage{mem} { } - - Block::Block (BuffDescr const& descr) - : handle{descr} - { } - void - StateReg::record (PBlock blockRef) - { - reg_.emplace_back (move (blockRef)); - } void StateReg::record (Block block) { - record (std::make_shared (block)); + reg_.emplace_back (move (block)); } size_t @@ -82,7 +75,7 @@ namespace engine { StateReg::operator[] (size_t seqNr) const { if (seqNr < cnt()) - return * reg_[seqNr]; + return reg_[seqNr]; else return error::Invalid(_Fmt{"no Buffer with seq-nr %d (%d known entries)"} % seqNr % cnt() @@ -92,10 +85,10 @@ namespace engine { StateReg::Result StateReg::byHandle (HashVal handle) const { - if (auto pos = find_if (reg_, [&](auto& entry){ return handle == HashVal(*entry); }) + if (auto pos = find_if (reg_, [&](auto& entry){ return handle == HashVal(entry); }) ;pos != reg_.end() ) - return **pos; + return *pos; else return error::Invalid("requested Buffer never encountered" , LERR_(BOTTOM_VALUE)); @@ -120,10 +113,22 @@ namespace engine { StateReg released; void - record_locked (BuffDescr typeDescriptor, Key stateKey, Buff* mem) + record_locked (Key stateKey, Buff* mem) { - REQUIRE (not created.contains (typeDescriptor)); - created.record (Block{typeDescriptor, stateKey, mem}); + REQUIRE (not created.contains (stateKey)); + created.record (Block{stateKey, mem}); + } + + void + record_emitted (HashVal id) + { + emitted.record (created.byHandle (id)); + } + + void + record_released (HashVal id) + { + released.record (created.byHandle (id)); } }; @@ -163,20 +168,24 @@ namespace engine { mark_locked (ID typeKey, Buff* storage, LocalTag implMark) override { ID stateKey = stage_->mark_locked (typeKey, storage, implMark); - tracker_.record_locked (provider_.buildDescriptor(stateKey), stateKey, storage); + tracker_.record_locked (stateKey, storage); return stateKey; } ID - mark_emitted (HashVal stateKey) override + mark_emitted (HashVal id) override { - return stage_->mark_emitted (stateKey); + ID stateKey = stage_->mark_emitted (id); + tracker_.record_emitted (stateKey); + return stateKey; } ID - mark_released (HashVal stateKey) override + mark_released (HashVal id) override { - return stage_->mark_released (stateKey); + ID stateKey = stage_->mark_released (id); + tracker_.record_released (stateKey); + return stateKey; } ID diff --git a/src/steam/engine/diagnostic-buffer-provider.hpp b/src/steam/engine/diagnostic-buffer-provider.hpp index c8cf39b66..e48432574 100644 --- a/src/steam/engine/diagnostic-buffer-provider.hpp +++ b/src/steam/engine/diagnostic-buffer-provider.hpp @@ -47,21 +47,21 @@ namespace engine { /** represent the status of one allocation */ struct Block { - BuffHandle handle; + HashVal typeKey{0}; + HashVal stateKey{0}; + size_t buffSize{0}; Buff* storage{nullptr}; Buff* accessMemory() const { return storage; } - Block (BuffDescr, metadata::Key, Buff* mem); - Block (BuffDescr const&); - operator HashVal() const { return handle; } + Block (metadata::Key, Buff* mem); + operator HashVal() const { return storage? stateKey:typeKey; } }; class StateReg : util::NonCopyable { - using PBlock = std::shared_ptr; - using Registry = std::vector; + using Registry = std::vector; Registry reg_; public: @@ -74,17 +74,24 @@ namespace engine { /* ========= Accounting API ========= */ void record (Block); - void record (PBlock); }; }//(End)diagnostic descriptors. - /****************************************************************//** - * Helper for unit tests: Buffer provider reference implementation. + /********************************************************************//** + * Helper for unit tests: Buffer provider that tracks state transitions. + * This is a variant of the _naive_ heap based BufferProvider implementation, + * with additional tracking hooks to record the IDs and further information + * of all allocations encountered at a state transition. * - * @todo write type comment + * Test code should keep track of the BufferProvider instance used, and may + * attach through a special [diagnostics access](\ref watch(BufferProvider&)), + * to extract the recorded information while or after the allocated buffers + * are used. Since the underlying "naive" implementation does not actually + * discard any allocated memory block, it is possible to look into memory + * contents after invoking the test subject. */ class DiagnosticBufferProvider : public NaiveBufferSetup diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 4ff31d47b..c395ae8a6 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -111956,6 +111956,9 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) + + + @@ -112044,8 +112047,9 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) - + + @@ -112107,23 +112111,23 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) - + - + - + - + - + @@ -112149,6 +112153,10 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) + + + + @@ -112193,8 +112201,9 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) - + + @@ -112287,22 +112296,33 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) - + + - +

- sonst werden Konsistenz-Fragen schnell zum Albtraum + ....sonst werden Konsistenz-Fragen schnell zum Albtraum; +

+

+ Und in der Tat: das war der Fehler an diesem ganzen Design...

+ + + + + + +
@@ -112684,8 +112704,8 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) - - + + @@ -112697,20 +112717,20 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) - + - + - + - - - - + + + + @@ -112736,13 +112756,13 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) - + - + @@ -112759,7 +112779,7 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) - + @@ -112770,7 +112790,7 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) - + @@ -112837,15 +112857,26 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) - - + + - - + + + + + + + + + + + + + @@ -112855,11 +112886,9 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) - + - - - +

...und zwar, weil wir ein BuffHandle speichern wollen, das einen BufferProvider einschließt. Dazu brauchen wir die Rückreferenz auf den Provider. Und das darf eigentlich nur BufferProvider selber... @@ -112867,14 +112896,67 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) + + - + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ weil wir hierfür einen »snapshot« der Daten aufzeichnen und aktualisieren sollten, und keinen Zugrff über irgendwelche lookup-Funktionen in die Metadaten bieten +

+ +
+ + +
+
+ + + + + + + + + + + + +
+ + + +
@@ -113092,7 +113174,7 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension)
- +