Skip to content

Add profiling report file support#471

Merged
bertysentry merged 6 commits intomainfrom
443-add-profiling-option
May 7, 2026
Merged

Add profiling report file support#471
bertysentry merged 6 commits intomainfrom
443-add-profiling-option

Conversation

@bertysentry
Copy link
Copy Markdown
Contributor

Summary

  • Allow --profile to write the profiling report to stderr by default or to a file via --profile=<filename>
  • Keep profiling wired through the dedicated AVM subclasses and report writer
  • Add CLI coverage for stderr output, file output, and empty filename rejection

Testing

  • mvn test
  • mvn verify
  • mvn site

@bertysentry bertysentry linked an issue May 6, 2026 that may be closed by this pull request
@bertysentry bertysentry requested a review from Copilot May 6, 2026 18:46
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/main/java/io/jawk/backend/ProfilingAVM.java Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) and ProfilingReport, and wire them through new ProfilingAwk engine variants.
  • Extend AVM with 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.

Comment thread src/main/java/io/jawk/backend/AVM.java
Comment thread src/main/java/io/jawk/backend/AVM.java
Comment thread src/main/java/io/jawk/ProfilingAwk.java Outdated
Comment thread src/main/java/io/jawk/backend/ProfilingAVM.java Outdated
Comment thread src/main/java/io/jawk/backend/ProfilingReport.java Outdated
Comment thread src/main/java/io/jawk/backend/ProfilingSandboxedAVM.java Outdated
Comment thread src/main/java/io/jawk/Cli.java
@bertysentry
Copy link
Copy Markdown
Contributor Author

@codex Please review

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Comment thread src/main/java/io/jawk/backend/AVM.java
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Comment thread src/main/java/io/jawk/backend/AVM.java
Comment thread src/main/java/io/jawk/Cli.java
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Comment thread src/main/java/io/jawk/Cli.java
Comment thread src/test/java/io/jawk/CliOptionTest.java Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Comment thread src/main/java/io/jawk/Cli.java
Comment thread src/main/java/io/jawk/Cli.java Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Comment on lines 514 to +522
} finally {
sink.flush();
if (memoryFile != null) {
savePersistentMemory(avm, memoryFile);
}
if (profiling) {
printProfilingReport(avm);
}
}
Comment on lines +2848 to +2857
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;
@bertysentry bertysentry merged commit 80206b7 into main May 7, 2026
9 checks passed
@bertysentry bertysentry deleted the 443-add-profiling-option branch May 7, 2026 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add profiling option

2 participants