debug

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package debug provides opt-in profiling helpers for the .lsc profile` subcommand. It is deliberately narrow — anything that flips a global runtime knob (GC percent, memory limit, traceback level) lives at the caller's risk and is not exported here.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MemoryStats

type MemoryStats struct {
	HeapAlloc     uint64
	HeapSys       uint64
	HeapIdle      uint64
	HeapInuse     uint64
	StackInuse    uint64
	StackSys      uint64
	MSpanInuse    uint64
	MCacheInuse   uint64
	GCCPUFraction float64
	NumGC         uint32
	LastGC        time.Time
	PauseNs       []time.Duration
	NumGoroutines int
}

MemoryStats is a snapshot of process memory state at one moment in time.

func CollectMemoryStats

func CollectMemoryStats() MemoryStats

CollectMemoryStats gathers the current heap/GC/goroutine snapshot. Intended for one-shot reporting at the end of a profiling run.

type Profile

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

Profile bundles the open files / pprof state for a profiling session. Returned by Start and passed to Stop. A zero Profile is safe to Stop (it's a no-op), which keeps the deferred-stop pattern clean even when Start failed partway.

func Start

func Start(cpuPath, memPath string) (*Profile, error)

Start opens cpuPath (if non-empty) and begins CPU profiling. If memPath is non-empty, the path is remembered and the heap profile is written on Stop. Returns the Profile handle even on partial failure so the caller can still defer Stop and clean up whichever side opened successfully.

func (*Profile) Stop

func (p *Profile) Stop() error

Stop ends CPU profiling and writes the heap profile (if requested at Start). Safe to call on a nil/zero Profile.

Jump to

Keyboard shortcuts

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