Skip to content

Improve native-image agent ZIP resource tracing - #14204

Open
rotilho wants to merge 1 commit into
oracle:masterfrom
rotilho:fix/native-image-agent-zip-resource-performance
Open

Improve native-image agent ZIP resource tracing#14204
rotilho wants to merge 1 commit into
oracle:masterfrom
rotilho:fix/native-image-agent-zip-resource-performance

Conversation

@rotilho

@rotilho rotilho commented Aug 8, 2026

Copy link
Copy Markdown

Place the ZipFile.getEntry breakpoint at its private getZipEntry invocation so it runs only after a successful lookup. This avoids JVMTI events for failed lookups and for stream or enumeration paths while preserving direct resource metadata and caller origins.

Add real-agent coverage for successful, missing, and streamed ZIP entries.

Summary

The Native Image tracing agent currently places a breakpoint at the entry of ZipFile.getEntry(String). Consequently, every lookup crosses a JVMTI breakpoint, including unsuccessful probes that do not produce resource metadata. Framework workloads can perform many thousands of such probes.

This change dynamically locates the getZipEntry(String, int) invocation inside public ZipFile.getEntry(String) and installs the breakpoint at that bytecode location. The JDK reaches this invocation only after finding the requested entry.

This means:

  • successful direct ZipFile.getEntry(String) calls retain the existing resource trace operation, metadata, caller attribution, and origin stack;
  • failed lookups do not cross the breakpoint;
  • ZipFile.stream(), JarFile.stream(), and enumeration paths do not cross the breakpoint or produce incidental resource metadata;
  • the bytecode location is resolved through JVMTI bytecode and constant-pool data rather than hardcoding a JDK-specific BCI.

Related Issues

Testing

The following checks passed:

  • Built SVM_AGENT and com.oracle.svm.configure.test.
  • Built SVM_TESTS.
  • mx gate --tags condconfig
  • mx checkstyle
  • git diff --check
  • Real-agent tests covering:
    • a successful direct classpath ZIP lookup is recorded;
    • a missing ZIP entry is not recorded;
    • streamed ZIP entries are not recorded.

Performance validation with 25,000 operations:

  • Failed lookups, default configuration: 805.86 ms → 4.75 ms.
  • Failed lookups, configuration with origins: 856.88 ms → 5.57 ms.
  • Streaming, default configuration: 2.84 ms → 2.75 ms.
  • Streaming, configuration with origins: 2.85 ms → 2.85 ms.

An end-to-end Spring Petclinic tracing-agent comparison improved from 324.82 seconds to 122.47 seconds, a 62.3% reduction. Generated resource metadata remained exactly equal at 840 entries in both runs.

A focused origins test confirmed that successful direct lookup metadata remains attributed to the application caller through public ZipFile.getEntry, without exposing the private helper frame.

Documentation

No documentation updates are needed. This changes an internal tracing-agent interception point while preserving the existing resource tracing protocol and user-visible configuration.

Contributor Checklist

  • I have read the contribution guide.
  • I have the right to contribute the submitted material under the project terms.
  • I have updated tests and documentation where appropriate.
  • If I used a coding assistant, I remain responsible for the entire contribution and have reviewed it accordingly.

Place the ZipFile.getEntry breakpoint at its private getZipEntry invocation so it runs only after a successful lookup. This avoids JVMTI events for failed lookups and for stream or enumeration paths while preserving direct resource metadata and caller origins.

Add real-agent coverage for successful, missing, and streamed ZIP entries.
@oracle-contributor-agreement

Copy link
Copy Markdown

Thank you for your pull request and welcome to our community! To contribute, please sign the Oracle Contributor Agreement (OCA).
The following contributors of this PR have not signed the OCA:

To sign the OCA, please create an Oracle account and sign the OCA in Oracle's Contributor Agreement Application.

When signing the OCA, please provide your GitHub username. After signing the OCA and getting an OCA approval from Oracle, this PR will be automatically updated.

If you are an Oracle employee, please make sure that you are a member of the main Oracle GitHub organization, and your membership in this organization is public.

@oracle-contributor-agreement oracle-contributor-agreement Bot added the OCA Required At least one contributor does not have an approved Oracle Contributor Agreement. label Aug 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OCA Required At least one contributor does not have an approved Oracle Contributor Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Significant execution time degradation with agent used during tests

1 participant