You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor: move all destruction-side heap accounting into Tsavorite
Tsavorite now handles ALL heap-size decrements internally via logSizeTracker:
- OnDispose(Deleted): decrements value heap before ClearHeapFields
- EvictRecordsInRange: decrements key overflow for ALL records (including
tombstoned), decrements value heap for non-tombstoned records
- CopyUpdated: decrements value-object heap (already internalized earlier)
GarnetRecordTriggers.OnDispose and OnEvict are now no-ops for accounting.
CallOnEvict returns false. The trigger callbacks remain available for
app-level resource cleanup (e.g. IDisposable.Dispose on value objects
that hold external resources), but Garnet does not use them.
The heap-tracking contract is now cleanly split:
- Session functions: emit +value at creation sites (only the app knows
the heap size of a newly created value)
- Tsavorite: emit -key and -value at all destruction/eviction sites
(the record is in hand, Tsavorite can read the sizes directly)
EvictRecordsInRange is now called whenever logSizeTracker is set OR
CallOnEvict is true, ensuring internal accounting runs even when the
application opts out of the OnEvict trigger.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy file name to clipboardExpand all lines: libs/storage/Tsavorite/cs/src/core/Allocator/LogRecord.cs
+5-1Lines changed: 5 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1097,7 +1097,11 @@ public readonly bool TryCopyFrom<TSourceLogRecord>(in TSourceLogRecord srcLogRec
1097
1097
}
1098
1098
else
1099
1099
{
1100
-
// TODOobjDispose: make sure Object isn't disposed by the source, to avoid use-after-Dispose. Maybe this (and DiskLogRecord remapping to TransientOIDMap) needs Clone()
1100
+
// TODO: Clone the value object here so source and destination have independent
1101
+
// HeapMemorySize fields. Currently both records share the same IHeapObject instance,
1102
+
// which means mutations on the destination affect the source's reported heap size
1103
+
// at eviction time, causing accounting drift in logSizeTracker. A naive Clone()
1104
+
// here causes CanDoHashExpireLTM to crash — needs investigation in a follow-up.
1101
1105
Debug.Assert(srcLogRecord.ValueObjectis not null,"Expected srcLogRecord.ValueObject to be set (or deserialized) already");
0 commit comments