dotnet / dotnet/diagnostics

[API Proposal]: provide profiling api like pprof of Go

Open
#2,948 11 comments 21 reactions 0 assignees View on GitHub
dotnet-monitor enhancement
Dominant language
C++
Stars
1.3k
Forks
404
Avg merge
2d 3h
Merged PRs (30d)
38

Description

### Background and motivation

Go provides a neat api to expose profiling info [net/http/pprof](https://pkg.go.dev/net/http/pprof). When enabled, the package will expose an api `/debug/pprof` to list the following runtime profiling targets:

- allocs: A sampling of all past memory allocations
- block: Stack traces that led to blocking on synchronization primitives
- cmdline: The command line invocation of the current program
- goroutine: Stack traces of all current goroutines
- heap: A sampling of memory allocations of live objects. You can specify the gc GET parameter to run GC before taking the heap sample.
- mutex: Stack traces of holders of contended mutexes
- profile: CPU profile. You can specify the duration in the seconds GET parameter. After you get the profile file, use the go tool pprof command to investigate the profile.
- threadcreate: Stack traces that led to the creation of new OS threads
- trace: A trace of execution of the current program. You can specify the duration in the seconds GET parameter. After you get the trace file, use the go tool trace command to investigate the trace.

However, those features are still missing in the C#/.NET ecosystem.

### API Proposal

```
HTTP GET /debug/pprof
```

### API Usage

`pprof` could be a good example and guidance for this purpose.

https://github.com/google/pprof

### Alternative Designs

No alternative for real-time profiling.

### Risks

This API could live as a package, separate from the runtime implementation code.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.