fix(driver-twincat): resolve Medium code-review finding (Driver.TwinCAT-012)
GetMemoryFootprint now returns tagsByName * 256 + nativeSubs * 512 bytes instead of a hard-coded 0; document that the stream-and-discard symbol browse leaves no flushable cache so FlushOptionalCachesAsync is a deliberate no-op. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -325,7 +325,7 @@ re-discovery re-downloads the whole symbol table each time, itself a performance
|
||||
stream-and-discard design is intentional, report the real footprint of `_nativeSubs` /
|
||||
`_tagsByName` and document that the driver holds no flushable cache.
|
||||
|
||||
**Resolution:** _(open)_
|
||||
**Resolution:** Resolved 2026-05-22 — `GetMemoryFootprint()` now returns `(_tagsByName.Count * 256L) + (_nativeSubs.Count * 512L)`; documented that the driver has no flushable symbol cache (stream-and-discard design) so `FlushOptionalCachesAsync` remains a documented no-op.
|
||||
|
||||
### Driver.TwinCAT-013
|
||||
|
||||
|
||||
@@ -134,7 +134,22 @@ public sealed class TwinCATDriver : IDriver, IReadable, IWritable, ITagDiscovery
|
||||
}
|
||||
|
||||
public DriverHealth GetHealth() => _health;
|
||||
public long GetMemoryFootprint() => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Estimated bytes attributable to this driver instance (Driver.TwinCAT-012).
|
||||
/// This driver holds no flushable symbol cache — <c>BrowseSymbolsAsync</c> streams and
|
||||
/// discards; the footprint reflects live allocations only:
|
||||
/// ~256 bytes per pre-declared tag (tag-definition record + dictionary overhead) and
|
||||
/// ~512 bytes per active native subscription.
|
||||
/// </summary>
|
||||
public long GetMemoryFootprint() =>
|
||||
(_tagsByName.Count * 256L) + (_nativeSubs.Count * 512L);
|
||||
|
||||
/// <summary>
|
||||
/// No flushable cache exists in this driver — the symbol table is streamed fresh on
|
||||
/// every <see cref="DiscoverAsync"/> call. This is a no-op but is deliberately present
|
||||
/// so Core's cache-budget enforcement sees a compliant Tier-A driver.
|
||||
/// </summary>
|
||||
public Task FlushOptionalCachesAsync(CancellationToken cancellationToken) => Task.CompletedTask;
|
||||
|
||||
internal int DeviceCount => _devices.Count;
|
||||
|
||||
Reference in New Issue
Block a user