Skip to content

Commit

Permalink
Add dev-mode setting for forcing the use of C2
Browse files Browse the repository at this point in the history
  • Loading branch information
geoand committed Oct 21, 2024
1 parent 744bc75 commit 19e1a7b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
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

0 comments on commit 19e1a7b

Please sign in to comment.