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
Add pprof-to-md integration for LLM-friendly markdown analysis (#58)
Integrates pprof-to-md to generate markdown analysis files alongside existing
HTML flamegraphs and pb files, making profile data more accessible to LLMs and
automated analysis tools.
Changes:
- Added pprof-to-md dependency and bumped Node.js requirement to >=22.6.0
- Implemented generateMarkdown() function in lib/index.js
- Extended preload.js to generate markdown files automatically
- Added --md-format CLI flag supporting summary/detailed/adaptive modes
- Added comprehensive test coverage (8 new tests across unit/integration)
- Updated documentation with markdown generation examples and usage
The markdown format provides structured, readable profile analysis that can be
easily consumed by LLMs, while maintaining full backward compatibility with
existing HTML and pb output formats.
1.**Auto-Start Mode (Default)**: Both CPU and heap profiling begin immediately when `flame run` starts your script
112
-
2.**Auto-Generation on Exit**: Profile (.pb) files and interactive HTML flamegraphs are automatically created for both CPU and heap profiles when the process exits
121
+
2.**Auto-Generation on Exit**: Profile (.pb) files, interactive HTML flamegraphs, and markdown analysis files are automatically created for both CPU and heap profiles when the process exits
113
122
3.**Manual Mode**: Use `--manual` flag to require `SIGUSR2` signals for start/stop control (no auto-HTML generation)
114
123
4.**Interactive Visualization**: The `@platformatic/react-pprof` library generates interactive WebGL-based HTML flamegraphs for both profile types
124
+
5.**Markdown Analysis**: The `pprof-to-md` library generates LLM-friendly markdown reports with hotspot tables for AI-assisted debugging
115
125
116
126
## Sourcemap Support
117
127
@@ -167,11 +177,23 @@ flame run server.js
167
177
168
178
Profile files are saved with timestamps in the format:
169
179
```
170
-
cpu-profile-2024-01-01T12-00-00-000Z.pb
180
+
cpu-profile-2024-01-01T12-00-00-000Z.pb # Binary pprof data
Both CPU and heap profiles share the same timestamp for easy correlation. The files are compressed Protocol Buffer format compatible with the pprof ecosystem.
188
+
Both CPU and heap profiles share the same timestamp for easy correlation. The `.pb` files are compressed Protocol Buffer format compatible with the pprof ecosystem. The `.md` files contain hotspot analysis tables suitable for AI/LLM-assisted performance debugging.
189
+
190
+
### Markdown Formats
191
+
192
+
The `--md-format` option controls the markdown output:
193
+
194
+
-**summary** (default): Compact hotspots table, ideal for AI triage and quick overview
195
+
-**detailed**: Comprehensive analysis with full stack traces and detailed statistics
196
+
-**adaptive**: Automatically chooses format based on profile complexity
175
197
176
198
## Integration with Existing Apps
177
199
@@ -200,14 +222,15 @@ curl http://localhost:3000
200
222
curl http://localhost:3000
201
223
curl http://localhost:3000
202
224
203
-
# Stop the server (Ctrl-C) to automatically save profiles and generate HTML flamegraphs
225
+
# Stop the server (Ctrl-C) to automatically save profiles and generate flamegraphs
204
226
# You'll see the exact file paths and browser URLs in the output:
205
227
# 🔥 CPU profile written to: cpu-profile-2025-08-27T15-30-45-123Z.pb
206
228
# 🔥 Heap profile written to: heap-profile-2025-08-27T15-30-45-123Z.pb
207
229
# 🔥 CPU flamegraph generated: cpu-profile-2025-08-27T15-30-45-123Z.html
230
+
# 🔥 CPU markdown generated: cpu-profile-2025-08-27T15-30-45-123Z.md
0 commit comments