Skip to main content

group_contiguous_block_chains

Function group_contiguous_block_chains 

Source
pub fn group_contiguous_block_chains(
    blocks: &[Arc<PartitionSourceBlock>],
) -> Vec<Vec<BlockMetadata>>
Expand description

Splits an event-time-ordered block list into maximal chains whose tick coverage is unbroken, so each chain can be decoded into one cross-block tree (a call tree for thread_spans, a net span tree for net_spans).

A chain breaks only on a gap – begin_ticks strictly after the running end_ticks, meaning blocks are missing in between and a tree built across the seam would be nonsense. An overlap (begin_ticks at or before the running end) still means unbroken coverage and keeps the chain open. The chain rule stays tolerant of overlap (not just equality) deliberately: by design both micromegas_tracing::dispatch’s flush paths and the Unreal producer now stamp one shared timestamp per flush, so consecutive blocks from a healthy producer touch exactly (begin_ticks == running end_ticks) – but blocks from producer versions predating that fix (or any other producer stamping two separate timestamps) can still carry a real, small overlap, and those legacy blocks are exactly the ones this function must keep chaining correctly. An equality-only test would incorrectly break the chain on every such legacy seam.

The running end is a max, not just the previous block’s end_ticks: a chain must not be broken by a short block fully contained in an earlier, longer one.