traceview

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package traceview renders rt traces for humans: an annotated timeline of the scheduler's decisions, per-goroutine stats, and a keep/drop diff showing exactly which decisions a minimized trace kept. Plain text out, ANSI color optional.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Diff

func Diff(w io.Writer, orig, min rt.Trace, opt Options) error

Diff renders a minimized trace against the original it came from: every original decision marked as kept or dropped, so you can see the skeleton the minimizer decided was actually load-bearing. A minimized trace should be a subsequence of the original; if replay leniency made it drift, that's reported instead of rendered.

func Header(tr rt.Trace) string

Header renders the one-line summary every subcommand shares.

func Stats

func Stats(w io.Writer, tr rt.Trace, opt Options) error

Stats writes per-goroutine pick counts, what each one blocked on, and the largest virtual-time gaps in the run.

func View

func View(w io.Writer, tr rt.Trace, opt Options) error

View writes the annotated decision timeline: one line per pick, with the virtual time it ran at, the goroutine by name, and what that goroutine did when its turn ended. Traces recorded before steps existed fall back to bare goroutine ids.

Example

A trace from a run where a producer and consumer deadlocked, rendered as an annotated timeline.

package main

import (
	"fmt"
	"os"

	"github.com/arshnah/detsim/rt"
	"github.com/arshnah/detsim/traceview"
)

func main() {
	tr := rt.Trace{
		Seed:      847291,
		Decisions: []uint64{0, 1, 0, 0, 1},
		Labels:    []string{"producer", "consumer"},
		Steps: []rt.Step{
			{At: 0, Goroutine: 0, After: "chan send"},
			{At: 0, Goroutine: 1, After: "chan recv"},
			{At: 0, Goroutine: 0, After: "chan send"},
			{At: 0, Goroutine: 0, After: "finished"},
			{At: 0, Goroutine: 1, After: "chan recv"},
		},
	}
	if err := traceview.View(os.Stdout, tr, traceview.Options{}); err != nil {
		fmt.Println("render failed:", err)
	}
}
Output:
seed 847291 · 5 decisions · 2 goroutines · no time advanced

  #1 producer blocked on chan send  at t=0s
  #2 consumer blocked on chan recv  at t=0s
  #3 producer blocked on chan send  at t=0s
  #4 producer ran to completion  at t=0s
  #5 consumer blocked on chan recv  at t=0s

Types

type Options

type Options struct {
	Color bool
	Limit int
}

Options control rendering. Color emits ANSI escapes; Limit caps how many decisions View prints (0 means all).

Jump to

Keyboard shortcuts

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