godeltaprof

package module
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2023 License: Apache-2.0 Imports: 5 Imported by: 2

README

godeltaprof

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockProfiler

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

BlockProfiler is a stateful profiler for goroutine blocking events and mutex contention in Go programs. Depending on the function used to create the BlockProfiler, it uses either runtime.BlockProfile or runtime.MutexProfile. The BlockProfiler provides similar functionality to pprof.Lookup("block").WriteTo and pprof.Lookup("mutex").WriteTo, but with some key differences.

The BlockProfiler tracks the delta of blocking events or mutex contention since the last profile was written, effectively providing a snapshot of the changes between two points in time. This is in contrast to the pprof.Lookup functions, which accumulate profiling data and result in profiles that represent the entire lifetime of the program.

The BlockProfiler is safe for concurrent use, as it serializes access to its internal state using a sync.Mutex. This ensures that multiple goroutines can call the Profile method without causing any data race issues.

func NewBlockProfiler

func NewBlockProfiler() *BlockProfiler

NewBlockProfiler creates a new BlockProfiler instance for profiling goroutine blocking events. The resulting BlockProfiler uses runtime.BlockProfile as its data source.

Usage:

bp := godeltaprof.NewBlockProfiler()
...
err := bp.Profile(someWriter)

func NewMutexProfiler

func NewMutexProfiler() *BlockProfiler

NewMutexProfiler creates a new BlockProfiler instance for profiling mutex contention. The resulting BlockProfiler uses runtime.MutexProfile as its data source.

Usage:

	mp := godeltaprof.NewMutexProfiler()
    ...
    err := mp.Profile(someWriter)

func (*BlockProfiler) Profile

func (d *BlockProfiler) Profile(w io.Writer) error

type HeapProfiler

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

HeapProfiler is a stateful profiler for heap allocations in Go programs. It is based on runtime.MemProfile and provides similar functionality to pprof.WriteHeapProfile, but with some key differences.

The HeapProfiler tracks the delta of heap allocations since the last profile was written, effectively providing a snapshot of the changes in heap usage between two points in time. This is in contrast to the pprof.WriteHeapProfile function, which accumulates profiling data and results in profiles that represent the entire lifetime of the program.

The HeapProfiler is safe for concurrent use, as it serializes access to its internal state using a sync.Mutex. This ensures that multiple goroutines can call the Profile method without causing any data race issues.

Usage:

hp := godeltaprof.NewHeapProfiler()
...
err := hp.Profile(someWriter)

func NewHeapProfiler

func NewHeapProfiler() *HeapProfiler

func (*HeapProfiler) Profile

func (d *HeapProfiler) Profile(w io.Writer) error

Directories

Path Synopsis
compat module
http
internal
otlp module

Jump to

Keyboard shortcuts

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