Skip to content

StreamingFSTTrace

class StreamingFSTTrace : public Trace

Streaming FST (Fast Signal Trace) file format reader

Uses 4-layer architecture for terabyte-scale trace processing:

Layer 1: Streaming I/O - StreamingChunkReader: C++20 coroutines, 100 MB chunks

Layer 2: Indexing & Caching - SparseIndex: Timestamp → file offset mapping - SignalValueCache: LRU cache with adaptive sizing

Layer 3: Format-Specific Reader - StreamingFSTTrace: Lazy FST parsing - Hierarchical scope support - Format validation - Multi-tier signal resolution

Layer 4: Public API - Trace base class interface - Transparent streaming to users

Memory Model: - Fixed: StreamingChunkReader (100 MB) - Bounded: SparseIndex (~1 MB for 1B timestamps) - Bounded: SignalValueCache (~15 MB typical) - Total: ~130 MB for 1 TB file

Performance: - Query latency: <50 ms (disk) or <1 ms (cached) - Cache hit rate: 95%+ after warming - Memory independent of file size

Functions

Name Description
StreamingFSTTrace Constructor for streaming FST trace tid : Trace identifier filename : Path to FST file container : Reference trace container chunk_size : Size of I/O chunks (default: 100 MB) cache_entries : Entries per signal in cache (default: 1000)
load Load and parse FST file header Initializes streaming components
signal_value Get signal value with lazy loading
signal_width Get signal width in bits
contains_signal Check if signal exists
get_all_signals Get all signal names
step Step through time (move to next/previous timestamp) steps : Number of steps (positive=forward, negative=backward) Return : true if step was successful, false if at boundary
get_index Get current time index
warm_cache Pre-warm cache for frequently accessed signals
get_cache_statistics Get cache statistics
parse_fst_header Parse FST header section
parse_fst_hierarchy Parse FST hierarchy (scopes and variables)
read_signal_value Parse value changes for a signal at given timestamp
lookup_or_load Cache lookup with LRU eviction
evict_lru Evict least recently used entries from cache
decompress_fst_section Decompress FST data section
bits_to_value Convert bit string to Value
infer_width Infer signal width from value

Function Details

StreamingFSTTrace

StreamingFSTTrace(const std::string& tid, const std::string& filename, std::shared_ptr<TraceContainer> container, size_t chunk_size = 100 * 1024 * 1024, size_t cache_entries = 1000)

Constructor for streaming FST trace

tid
Trace identifier
filename
Path to FST file
container
Reference trace container
chunk_size
Size of I/O chunks (default: 100 MB)
cache_entries
Entries per signal in cache (default: 1000)

bits_to_value

static Value bits_to_value(const std::string& bits)

Convert bit string to Value

contains_signal

bool contains_signal(const std::string& name) const override

Check if signal exists

decompress_fst_section

static std::vector<uint8_t> decompress_fst_section(const std::vector<uint8_t>& compressed)

Decompress FST data section

evict_lru

void evict_lru(SignalCache& cache)

Evict least recently used entries from cache

get_all_signals

std::vector<std::string> get_all_signals() const override

Get all signal names

get_cache_statistics

std::string get_cache_statistics() const

Get cache statistics

get_index

int get_index() const

Get current time index

infer_width

static int infer_width(int64_t max_value)

Infer signal width from value

load

void load()

Load and parse FST file header Initializes streaming components

lookup_or_load

Value lookup_or_load(const std::string& name, int64_t timestamp)

Cache lookup with LRU eviction

parse_fst_header

void parse_fst_header()

Parse FST header section

parse_fst_hierarchy

void parse_fst_hierarchy()

Parse FST hierarchy (scopes and variables)

read_signal_value

Value read_signal_value(const std::string& name, int64_t timestamp)

Parse value changes for a signal at given timestamp

signal_value

Value signal_value(const std::string& name, int offset = 0, const std::string& scope = "") override

Get signal value with lazy loading

signal_width

int signal_width(const std::string& name) override

Get signal width in bits

step

bool step(int steps = 1) override

Step through time (move to next/previous timestamp)

steps
Number of steps (positive=forward, negative=backward)
Return
true if step was successful, false if at boundary

warm_cache

void warm_cache(const std::vector<std::string>& signal_names)

Pre-warm cache for frequently accessed signals