Class FileCacheSink
ICacheChunkSink implementation backed by a TraceFileCacheWriter. Produces a complete
.typhon-trace-cache sidecar file when WriteTrailer(IReadOnlyList<TickSummary>, in GlobalMetricsFixed, IReadOnlyList<SystemAggregateDuration>, IReadOnlyList<ChunkManifestEntry>, IReadOnlyDictionary<int, string>, ReadOnlySpan<byte>, in CacheHeader, IReadOnlyList<SystemTickSummary>, IReadOnlyList<QueueTickSummary>, IReadOnlyList<PostTickSummary>, IReadOnlyDictionary<ushort, string>, IReadOnlyList<SystemArchetypeTouchSummary>) is called.
public sealed class FileCacheSink : ICacheChunkSink, IDisposable
- Inheritance
-
FileCacheSink
- Implements
- Inherited Members
Remarks
The sink owns the underlying TraceFileCacheWriter (and therefore the file stream). Disposing it disposes the writer.
Constructors
FileCacheSink(TraceFileCacheWriter)
Wrap a TraceFileCacheWriter. The sink takes ownership: disposing it disposes the writer and its stream.
public FileCacheSink(TraceFileCacheWriter writer)
Parameters
writerTraceFileCacheWriterCache writer to append chunks and trailer sections to.
Exceptions
- ArgumentNullException
writerisnull.
Properties
SupportsTrailer
True if this sink writes a trailer (TickSummaries / GlobalMetrics / ChunkManifest / SpanNameTable + cache header).
public bool SupportsTrailer { get; }
Property Value
Remarks
Always true — this replay sink writes a full trailer and sealed cache header.
Methods
AppendChunk(ReadOnlySpan<byte>)
LZ4-compress and append a chunk's records to the sink's underlying storage. Returns the byte offset and lengths needed to populate the matching ChunkManifestEntry.
public (long CacheOffset, uint CompressedLength, uint UncompressedLength) AppendChunk(ReadOnlySpan<byte> uncompressedRecords)
Parameters
uncompressedRecordsReadOnlySpan<byte>
Returns
Remarks
Opens the FoldedChunkData section on the first call.
Create(string)
Open a sink at the given path, creating/overwriting the file. The sink owns the stream.
public static FileCacheSink Create(string cachePath)
Parameters
cachePathstring
Returns
Dispose()
Disposes the owned TraceFileCacheWriter (and its underlying stream). Idempotent.
public void Dispose()
WriteTrailer(IReadOnlyList<TickSummary>, in GlobalMetricsFixed, IReadOnlyList<SystemAggregateDuration>, IReadOnlyList<ChunkManifestEntry>, IReadOnlyDictionary<int, string>, ReadOnlySpan<byte>, in CacheHeader, IReadOnlyList<SystemTickSummary>, IReadOnlyList<QueueTickSummary>, IReadOnlyList<PostTickSummary>, IReadOnlyDictionary<ushort, string>, IReadOnlyList<SystemArchetypeTouchSummary>)
public void WriteTrailer(IReadOnlyList<TickSummary> tickSummaries, in GlobalMetricsFixed globalMetrics, IReadOnlyList<SystemAggregateDuration> systemAggregates, IReadOnlyList<ChunkManifestEntry> chunkManifest, IReadOnlyDictionary<int, string> spanNames, ReadOnlySpan<byte> sourceMetadataBytes, in CacheHeader headerTemplate, IReadOnlyList<SystemTickSummary> systemTickSummaries, IReadOnlyList<QueueTickSummary> queueTickSummaries, IReadOnlyList<PostTickSummary> postTickSummaries, IReadOnlyDictionary<ushort, string> queueIdToName, IReadOnlyList<SystemArchetypeTouchSummary> systemArchetypeTouches)
Parameters
tickSummariesIReadOnlyList<TickSummary>globalMetricsGlobalMetricsFixedsystemAggregatesIReadOnlyList<SystemAggregateDuration>chunkManifestIReadOnlyList<ChunkManifestEntry>spanNamesIReadOnlyDictionary<int, string>sourceMetadataBytesReadOnlySpan<byte>headerTemplateCacheHeadersystemTickSummariesIReadOnlyList<SystemTickSummary>queueTickSummariesIReadOnlyList<QueueTickSummary>postTickSummariesIReadOnlyList<PostTickSummary>queueIdToNameIReadOnlyDictionary<ushort, string>systemArchetypeTouchesIReadOnlyList<SystemArchetypeTouchSummary>
Exceptions
- InvalidOperationException
The trailer has already been written.