performance

package
v0.16.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 7, 2026 License: LGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Batch

type Batch struct {
	Ticks []TickTimeline
}

Batch is a batch of completed tick timelines pushed to subscribers. Treat as read-only: subscribers must not mutate Ticks or its elements.

type Collector

type Collector struct {
	// contains filtered or unexported fields
}

Collector accumulates per-tick span data and broadcasts it in batches to streaming subscribers. It is designed for a single writer (the tick loop) with concurrent reader subscriptions (gRPC stream handlers).

func NewCollector

func NewCollector(batchSize int) *Collector

NewCollector creates a Collector that flushes every batchSize ticks.

func (*Collector) RecordSpan

func (c *Collector) RecordSpan(span TickSpan)

RecordSpan appends a span to the current tick.

func (*Collector) RecordTick

func (c *Collector) RecordTick(tickHeight uint64, tickStart time.Time)

RecordTick finalizes the current tick, appending a TickTimeline to the pending batch. When the batch reaches batchSize, it is flushed to all subscribers via non-blocking channel sends performed outside the lock.

func (*Collector) Reset

func (c *Collector) Reset()

Reset clears all buffered data. Use after a world reset or snapshot restore.

func (*Collector) StartTick

func (c *Collector) StartTick()

StartTick initializes span collection for a new tick. Call exactly once per tick before any RecordSpan calls.

func (*Collector) Subscribe

func (c *Collector) Subscribe() <-chan Batch

Subscribe returns a channel that receives Batch values whenever the collector flushes. The caller must eventually call Unsubscribe to avoid leaking the channel.

func (*Collector) Unsubscribe

func (c *Collector) Unsubscribe(ch <-chan Batch)

Unsubscribe removes the given channel from the subscriber list. The channel is intentionally not closed: closing would make receives return zero values instead of blocking, breaking select/default patterns. Callers should select on ctx.Done() to detect stream termination.

type TickSpan

type TickSpan struct {
	TickHeight uint64
	SystemHook uint8
	SystemName string
	StartTime  time.Time
	EndTime    time.Time
}

TickSpan represents a single system execution span within a tick.

type TickTimeline

type TickTimeline struct {
	TickHeight uint64
	TickStart  time.Time
	Spans      []TickSpan
}

TickTimeline groups spans that occurred within a single tick.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL