Table of Contents

Class FileCacheSink

Namespace
Typhon.Profiler
Assembly
Typhon.Profiler.dll
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

writer TraceFileCacheWriter

Cache writer to append chunks and trailer sections to.

Exceptions

ArgumentNullException

writer is null.

Properties

SupportsTrailer

True if this sink writes a trailer (TickSummaries / GlobalMetrics / ChunkManifest / SpanNameTable + cache header).

public bool SupportsTrailer { get; }

Property Value

bool

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

uncompressedRecords ReadOnlySpan<byte>

Returns

(long CacheOffset, uint CompressedLength, uint UncompressedLength)

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

cachePath string

Returns

FileCacheSink

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

tickSummaries IReadOnlyList<TickSummary>
globalMetrics GlobalMetricsFixed
systemAggregates IReadOnlyList<SystemAggregateDuration>
chunkManifest IReadOnlyList<ChunkManifestEntry>
spanNames IReadOnlyDictionary<int, string>
sourceMetadataBytes ReadOnlySpan<byte>
headerTemplate CacheHeader
systemTickSummaries IReadOnlyList<SystemTickSummary>
queueTickSummaries IReadOnlyList<QueueTickSummary>
postTickSummaries IReadOnlyList<PostTickSummary>
queueIdToName IReadOnlyDictionary<ushort, string>
systemArchetypeTouches IReadOnlyList<SystemArchetypeTouchSummary>

Exceptions

InvalidOperationException

The trailer has already been written.