You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# [pprof](https://github.com/google/pprof) context provider for OpenCtx
2
2
3
-
This is a context provider for [OpenCtx](https://openctx.org) that annotates functions with the CPU time and memory allocations attributed to them.
3
+
[OpenCtx](https://openctx.org) provider that annotates Go functions with their associated CPU time and memory allocations based on the CPU/memory profiles.
4
+
5
+
As profiling reports are usually not stored in a centralized remote location (like, e.g. docs or logs) and only exist on your machine, this provider only supports local VSCode client. It also does not provide annotations for test files.
6
+
7
+
When enabled, pprof provider will:
8
+
9
+
1. Search the workspace to find a profiling report and, optionally, a Go binary that produced it.
10
+
1. Get `pprof -top` nodes for the current package.
11
+
1. Create an annotation for each function/method in the current file denoting its resourse consumption.
12
+
1. Pass a detailed `pprof -list` breakdown to `annotation.item.ai` to be consumed by Cody.
4
13
5
14
## Usage
6
15
7
-
Add the following to your settings in any OpenCtx client:
16
+
Add the following to your `settings.json`:
8
17
9
18
```json
10
19
"openctx.providers": {
@@ -13,12 +22,48 @@ Add the following to your settings in any OpenCtx client:
13
22
},
14
23
```
15
24
25
+
Pprof provider has reasonable defaults, so no additional configuration in necessary if you follow the standard naming conventions for pprof reports and Go binaries, e.g. that a cpu profile report has `.pprof` extension.
26
+
27
+
Most of the time, however, you'll want to adjust the config to suit your preferences.
28
+
16
29
## Configuration
17
30
18
-
> TODO
31
+
The default configuration looks like this:
32
+
33
+
```json
34
+
{
35
+
"reportGlob": "**/*.pprof",
36
+
"binaryGlob": undefined, // By default, looks for a binary whose name matches the name of its parent directory
37
+
"rootDirectoryMarkers": ["go.mod", ".git"],
38
+
"top": { // Options to control `pprof -top` output
39
+
"excludeInline": true, // Add `-noinlines`
40
+
"nodeCount": undefined, // Add `-nodecount=x`, not set by default
41
+
"sort": "cum"// Set `-cum` or `-flat`
42
+
}
43
+
}
44
+
```
45
+
46
+
## Limitations
47
+
48
+
`pprof` can collect stack traces for a number of [different profiles](https://pkg.go.dev/runtime/pprof#Profile):
49
+
50
+
```
51
+
goroutine - stack traces of all current goroutines
52
+
heap - a sampling of memory allocations of live objects
53
+
allocs - a sampling of all past memory allocations
54
+
threadcreate - stack traces that led to the creation of new OS threads
55
+
block - stack traces that led to blocking on synchronization primitives
56
+
mutex - stack traces of holders of contended mutexes
57
+
```
58
+
59
+
This provider only supports `heap` and CPU profile[^1].
0 commit comments