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 dev-mode setting for forcing the use of C2 #43988

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ public B preventnoverify(boolean preventnoverify) {
return (B) this;
}

@SuppressWarnings("unchecked")
public B forceC2(boolean force) {
forceC2 = force;
return (B) this;
}

@SuppressWarnings("unchecked")
public B jvmArgs(String jvmArgs) {
args.add(jvmArgs);
Expand Down Expand Up @@ -316,6 +322,7 @@ public R build() throws Exception {
private String targetJavaVersion;
private Set<Path> buildFiles = new HashSet<>(0);
private boolean deleteDevJar = true;
private boolean forceC2 = false;
private String baseName;
private Consumer<DevModeContext> entryPointCustomizer;
private String applicationArgs;
Expand All @@ -335,7 +342,7 @@ protected QuarkusDevModeLauncher() {
protected void prepare() throws Exception {
JBossVersion.disableVersionLogging();

if (!JavaVersionUtil.isGraalvmJdk()) {
if (!JavaVersionUtil.isGraalvmJdk() && !forceC2) {
// prevent C2 compiler for kicking in - makes startup a little faster
// it only makes sense in dev-mode but it is not available when GraalVM is used as the JDK
args.add("-XX:TieredStopAtLevel=1");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public abstract class QuarkusDev extends QuarkusTask {
private final MapProperty<String, String> environmentVariables;

private final Property<Boolean> preventNoVerify;
private final Property<Boolean> forceC2;
private final Property<Boolean> shouldPropagateJavaCompilerArgs;
private final ListProperty<String> args;
private final ListProperty<String> jvmArgs;
Expand Down Expand Up @@ -128,6 +129,9 @@ public QuarkusDev(
preventNoVerify = objectFactory.property(Boolean.class);
preventNoVerify.convention(false);

forceC2 = objectFactory.property(Boolean.class);
forceC2.convention(false);

shouldPropagateJavaCompilerArgs = objectFactory.property(Boolean.class);
shouldPropagateJavaCompilerArgs.convention(true);

Expand Down Expand Up @@ -222,6 +226,11 @@ public boolean isPreventnoverify() {
return getPreventNoVerify().get();
}

@Input
public Property<Boolean> getForceC2() {
return forceC2;
}

/**
* @deprecated see {@link #getPreventNoVerify()}
*/
Expand Down Expand Up @@ -414,6 +423,7 @@ private QuarkusDevModeLauncher newLauncher(final AnalyticsService analyticsServi
}
GradleDevModeLauncher.Builder builder = GradleDevModeLauncher.builder(getLogger(), java)
.preventnoverify(getPreventNoVerify().getOrElse(false))
.forceC2(getForceC2().getOrElse(false))
.projectDir(projectDir)
.buildDir(buildDir)
.outputDir(buildDir)
Expand Down
10 changes: 10 additions & 0 deletions devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,15 @@ public class DevMojo extends AbstractMojo {
@Parameter(defaultValue = "${preventnoverify}")
private boolean preventnoverify = false;

/**
* This value is intended to be set to true when we want to require C2 compilation instead of preventing it from
* ever kicking in.
* Setting this will likely have a small negative effect on startup time and should only be done when it absolutely
* makes sense.
*/
@Parameter(defaultValue = "${forceC2}")
private boolean forceC2 = false;

/**
* Whether changes in the projects that appear to be dependencies of the project containing the application to be launched
* should trigger hot-reload. By default, they do.
Expand Down Expand Up @@ -1247,6 +1256,7 @@ private QuarkusDevModeLauncher newLauncher(String actualDebugPort, String bootst

final MavenDevModeLauncher.Builder builder = MavenDevModeLauncher.builder(java, getLog())
.preventnoverify(preventnoverify)
.forceC2(forceC2)
.buildDir(buildDir)
.outputDir(outputDirectory)
.suspend(suspend)
Expand Down
Loading