On this page
Start term-llm with profiling enabled
term-llm chat --pprof
term-llm chat --pprof=6060
TERM_LLM_PPROF=1 term-llm chat
Then, from another terminal:
term-llm pprof cpu
term-llm pprof heap
term-llm pprof goroutine
term-llm pprof block
term-llm pprof mutex
term-llm pprof web
Commands
pprof cpu [PORT]capture a CPU profilepprof heap [PORT]capture a heap profilepprof goroutine [PORT]dump goroutine stackspprof block [PORT]capture a blocking profilepprof mutex [PORT]capture a mutex contention profilepprof web [PORT]open the pprof index in a browser
If you omit the port, term-llm tries to auto-discover it from the pprof registry.
CPU duration
term-llm pprof cpu --duration 10
Default CPU capture duration is 30 seconds.
When to use it
Use pprof when you are debugging:
- CPU hotspots
- memory growth
- goroutine leaks
- contention and blocking behavior