BufferProvider: reduce synchronisation effort

The recursive synchronisation up the parent-chain can in most cases be skipped,
by relying on the fact that inconsistent data is never stored in the BufferMetadata
table. If thus an entry is locally present and matches the entry from the
other side, then it can be concluded that its parent must also be already in sync.
This commit is contained in:
Fischlurch 2026-04-19 15:14:31 +02:00
parent c05a73d68a
commit 1601838037
3 changed files with 25 additions and 5 deletions

View file

@ -789,8 +789,8 @@ namespace mem {
if (not srcReg.isKnown (key))
return;
Entry const& entry{srcReg.get(key)};
doSynchronise (entry);
import (entry.parentKey(), srcReg);
if (doSynchronise (entry))
import (entry.parentKey(), srcReg);
}
@ -892,15 +892,17 @@ namespace mem {
/** import data from another metadata entry,
* without violating sanity rules
* yet reject violating sanity rules.
* @remark usually this is used to import new type-keys;
* an active buffer entry can only be handled if it is new,
* or implies a valid state transition.
* @note if the buffer is not NULL, it must be the same address,
* otherwise the keys would differ, since they are generated
* with \ref Key::forEntry()
* @return `true` if new data was stored, which implies
* that synchronisation should proceed up to the parent
*/
void
bool
doSynchronise (Entry const& otherEntry)
{
Entry* entry = table_.fetch (otherEntry);
@ -917,6 +919,10 @@ namespace mem {
else
entry->mark(otherEntry.state());
}
else
return true;
// something to synchronise => continue up the path
return false;
}
};

View file

@ -160,7 +160,7 @@ namespace test {
CHECK (eDD.state() == FREE);
CHECK (meta2.get(eDD).state() == EMITTED);
// it is not allowed to mark de-allocated through synchronisation
// it is not allowed to mark as de-allocated through synchronisation
VERIFY_ERROR (LOGIC, meta2.import (eDD, meta1) );
VERIFY_ERROR (LIFECYCLE, meta2.release(HashVal(eDD)) );

View file

@ -144475,6 +144475,20 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension)
<node CREATED="1776557832463" ID="ID_727929224" MODIFIED="1776557843944" TEXT="wenn ich den Key habe &#x27f9; Abgleich mit Konsistenzcheck"/>
<node CREATED="1776557887075" ID="ID_294261855" MODIFIED="1776557938772" TEXT="rekursiv den Abgleich f&#xfc;r den parent-Hash ausl&#xf6;sen">
<arrowlink DESTINATION="ID_1185060059" ENDARROW="Default" ENDINCLINATION="102;0;" ID="Arrow_ID_680660049" STARTARROW="None" STARTINCLINATION="102;0;"/>
<node CREATED="1776604115107" HGAP="30" ID="ID_1186161854" MODIFIED="1776604293378" TEXT="aber nur wenn f&#xfc;r den aktuellen Eintrag was zu tun war" VSHIFT="11">
<richcontent TYPE="NOTE"><html>
<head>
</head>
<body>
<p>
...damit kann man in der Regel das rekursive Traversieren der Kette vorzeitig abbrechen; das beruht auf einem &#187;Invarianten-Argument&#171;: Daten in der Registry sind stets konsistent, was impliziert, da&#223; wir auch den Parent-Key bereits gespeichert haben, entweder durch regul&#228;res Anlegen, oder durch eine vorausgegangenen Synchronisation
</p>
</body>
</html>
</richcontent>
<icon BUILTIN="idea"/>
</node>
</node>
</node>
</node>