Add per-phase CPU/MEM profiling instrumentation behind a --profiling flag#195
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2980924755
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
2980924 to
9de0a28
Compare
|
🎯 Code Coverage (details) 🔗 Commit SHA: 9de0a28 | Docs | Datadog PR Page | Give us feedback! |
MikaYuoadas
left a comment
There was a problem hiding this comment.
LGTM 👍
Just a question, IIUC we store the heap size at each phase boundaries but this means we’ll miss the memory peak inside each phase. Isn’t that what we care the most about to properly size our memory limit on pods and avoid OOMs?
|
@MikaYuoadas thank you! You are right about miss memory peaks. The near term focus is IDE Integration with long-living HTTP server. We are gonna to use cache across runs. So we are interested in heap growth. But memory peak problem is worth solving with some periodic sampling to track the max seen. Could be tracked as follow-up when needed |
Motivation
Add KICS-aligned CPU and memory profiling support to help investigate scanner performance and memory footprint by scan phase.
JIRA Ticket K9CODESEC-2331
Changes
--profiling CPU|MEMsupport.go tool pprofinspection.go tool pprofexamples.Author Checklist
QA Instruction
Run a scan with profiling enabled:
Verify that phase totals are logged and that pprof files are written to the temp directory. For MEM, confirm logs say
Total MEM live heap after ...and inspect profiles withgo tool pprof.Blast Radius
Limited to Datadog IaC Scanner CLI profiling behavior and related documentation. Normal scans are unchanged unless
--profilingis enabled.Additional Notes
No new unit tests were added; this change is exercised through CLI profiling runs and produces runtime pprof artifacts/log output.
I submit this contribution under the Apache-2.0 license.