Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for PGO instrumentation #471

Merged
merged 13 commits into from Jul 27, 2023
Merged

Add support for PGO instrumentation #471

merged 13 commits into from Jul 27, 2023

Conversation

melix
Copy link
Collaborator

@melix melix commented Jul 21, 2023

This commit adds support for PGO instrumentation. This should be enabled by adding the --pgo-instrument option to the Gradle command line. When this is done, then the generated binary will be compiled with PGO instrumentation enabled, and the binary name will be suffixed with -instrumented.

It is possible to run the instrumented binary directly too, in which case the profile files will be written in the same directory as the binary.

@melix melix added the gradle-plugin Related to Gradle plugin label Jul 21, 2023
@melix melix self-assigned this Jul 21, 2023
@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Jul 21, 2023
This commit adds support for PGO instrumentation. This should be
enabled by adding the `--pgo-instrument` option to the Gradle
command line. When this is done, then the generated binary will
be compiled with PGO instrumentation enabled, and the binary
name will be suffixed with `-instrumented`.

It is possible to run the instrumented binary directly too,
in which case the profile files will be written in the same
directory as the binary.
By convention, the directory is set to `src/pgo-profiles/<binary>`.
For example, for the `main` binary, the directory where to put
PGO profiles would be `src/pgo-profiles/main`. If that directory
is present _and that we're not instrumenting_, then the profile
will be used when compiling with native image.

It is possible to provide multiple profiles in a single directory.
@melix melix marked this pull request as ready for review July 24, 2023 10:18
As we're not compatible. Test `org.graalvm.buildtools.gradle.OfficialMetadataRepoFunctionalTest`
throws an incomprehensible error message, in all versions of Gradle I've tested:

```
Configuration cache state could not be cached: field `spec` of `org.gradle.api.internal.tasks.execution.SelfDescribingSpec` bean found in task `:compileJava` of type `org.gradle.api.tasks.compile.JavaCompile`: error writing value of type 'org.gradle.api.internal.tasks.compile.CompilerForkUtils$$Lambda$1235/0x00000008015b1c38'
> Unable to make field private final java.lang.Object[] java.lang.invoke.SerializedLambda.capturedArgs accessible: module java.base does not "opens java.lang.invoke" to unnamed module @3cc98b0c
```

This PR also rewrote some code which fixed other configuration
cache issues which arose _before_ reaching this one.
@melix
Copy link
Collaborator Author

melix commented Jul 26, 2023

@alvarosanchez @fniephaus this is ready for review. The configuration cache problems are solved, we're compatible 🎉

@melix melix merged commit 421b6b6 into master Jul 27, 2023
17 checks passed
@melix melix deleted the cc/pgo-support branch July 27, 2023 13:47
languageVersion.set(JavaLanguageVersion.of(11))
vendor.set(JvmVendorSpec.matching("GraalVM"))
languageVersion.set(JavaLanguageVersion.of(17))
// vendor.set(JvmVendorSpec.matching("Oracle Corporation"))
Copy link
Member

Choose a reason for hiding this comment

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

Is this a leftover?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Intentionally left so that we figure out what to do with this : the build will fail if it's not an Oracle GraalVM, but there's no way to make it work properly if we set matching("Oracle Corporation") since it could select a different implementation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gradle-plugin Related to Gradle plugin OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants