Add profiling report file support#471
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b16098057f
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Pull request overview
This PR adds runtime profiling report support to the Jawk CLI, allowing --profile to emit tuple/function timing stats to stderr by default or to a specified file via --profile=<filename>. It implements profiling through dedicated AVM/Awk variants and extends the core AVM execution loop with before/after tuple hooks, plus adds CLI tests and documentation updates.
Changes:
- Add
--profile/--profile=<filename>CLI support, including empty-filename rejection and report writing to stderr or file. - Introduce
ProfilingAVM(+ sandboxed variant) andProfilingReport, and wire them through newProfilingAwkengine variants. - Extend
AVMwith tuple execution hooks to enable runtime profiling, plus add CLI coverage and docs.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/main/java/io/jawk/Cli.java | Parses --profile options, selects profiling-capable Awk/AVM, and writes the profiling report to stderr or a file. |
| src/main/java/io/jawk/backend/AVM.java | Adds before/after tuple execution hooks and invokes them from the tuple execution loop. |
| src/main/java/io/jawk/backend/ProfilingAVM.java | Implements tuple/function timing collection via the new AVM hooks. |
| src/main/java/io/jawk/backend/ProfilingReport.java | Defines the report snapshot and printing/sorting logic for collected stats. |
| src/main/java/io/jawk/backend/ProfilingSandboxedAVM.java | Profiling-capable sandboxed AVM variant (sandboxed JRT) mirroring SandboxedAVM. |
| src/main/java/io/jawk/ProfilingAwk.java | Awk variants that create profiling AVMs (including sandboxed profiling). |
| src/test/java/io/jawk/AwkTestSupport.java | Enhances CLI test harness to capture stderr alongside stdout. |
| src/test/java/io/jawk/CliOptionTest.java | Adds tests for stderr report output, file output, and empty filename rejection. |
| src/site/markdown/cli-reference.md | Documents the new --profile behaviors and execution notes. |
| src/main/java/io/jawk/jrt/ListAssocArray.java | Normalizes copyright header format. |
| src/it/java/io/jawk/site/CompatibilitySummaryGenerator.java | Normalizes copyright header format. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@codex Please review |
| } finally { | ||
| sink.flush(); | ||
| if (memoryFile != null) { | ||
| savePersistentMemory(avm, memoryFile); | ||
| } | ||
| if (profiling) { | ||
| printProfilingReport(avm); | ||
| } | ||
| } |
| if (profiling) { | ||
| afterProfiledTuple(opcode, tupleStartNanos); | ||
| } | ||
| } | ||
|
|
||
| } catch (ExitException ee) { | ||
| if (profiling && (opcode == Opcode.EXIT_WITH_CODE || opcode == Opcode.EXIT_WITHOUT_CODE)) { | ||
| afterProfiledTuple(opcode, tupleStartNanos); | ||
| } | ||
| throw ee; |
Summary
--profileto write the profiling report to stderr by default or to a file via--profile=<filename>Testing
mvn testmvn verifymvn site