diff --git a/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java b/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java index 6c7d1398012c..8bc6902caf19 100644 --- a/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java +++ b/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java @@ -87,7 +87,8 @@ import org.jetbrains.jps.cmdline.ClasspathBootstrap; import org.jetbrains.jps.incremental.Utils; import org.jetbrains.jps.model.java.compiler.JavaCompilers; -import javax.tools.*; +import javax.tools.JavaCompiler; +import javax.tools.ToolProvider; import java.awt.*; import java.io.File; import java.io.IOException; @@ -321,7 +322,7 @@ public class BuildManager implements Disposable { EditorFactory.getInstance().getEventMulticaster().addDocumentListener(new DocumentListener() { @Override public void documentChanged(@NotNull DocumentEvent e) { - if (Registry.is("compiler.document.save.enabled", true)) { + if (Registry.is("compiler.document.save.enabled", false)) { final Document document = e.getDocument(); if (FileDocumentManager.getInstance().isDocumentUnsaved(document)) { final VirtualFile file = FileDocumentManager.getInstance().getFile(document); @@ -536,7 +537,7 @@ public class BuildManager implements Disposable { final List scopes = CmdlineProtoUtil.createAllModulesScopes(false); final AutoMakeMessageHandler handler = new AutoMakeMessageHandler(project); final TaskFuture future = scheduleBuild( - project, false, true, false, scopes, Collections.emptyList(), Collections.emptyMap(), handler + project, false, true, false, scopes, Collections.emptyList(), Collections.singletonMap(BuildParametersKeys.IS_AUTOMAKE, "true"), handler ); if (future != null) { myAutomakeFutures.put(future, project); @@ -1061,8 +1062,6 @@ public class BuildManager implements Disposable { final CompilerWorkspaceConfiguration config = CompilerWorkspaceConfiguration.getInstance(project); final GeneralCommandLine cmdLine = new GeneralCommandLine(); cmdLine.setExePath(vmExecutablePath); - //cmdLine.addParameter("-XX:MaxPermSize=150m"); - //cmdLine.addParameter("-XX:ReservedCodeCacheSize=64m"); boolean isProfilingMode = false; String userDefinedHeapSize = null; @@ -1125,6 +1124,12 @@ public class BuildManager implements Disposable { cmdLine.addParameter("-D"+ GlobalOptions.GENERATE_CLASSPATH_INDEX_OPTION +"=" + shouldGenerateIndex); } cmdLine.addParameter("-D" + GlobalOptions.COMPILE_PARALLEL_OPTION + "=" + config.PARALLEL_COMPILATION); + if (config.PARALLEL_COMPILATION) { + final boolean allowParallelAutomake = Registry.is("compiler.automake.allow.parallel", true); + if (!allowParallelAutomake) { + cmdLine.addParameter("-D" + GlobalOptions.ALLOW_PARALLEL_AUTOMAKE_OPTION + "=false"); + } + } cmdLine.addParameter("-D" + GlobalOptions.REBUILD_ON_DEPENDENCY_CHANGE_OPTION + "=" + config.REBUILD_ON_DEPENDENCY_CHANGE); if (Registry.is("compiler.build.report.statistics")) { @@ -1163,10 +1168,6 @@ public class BuildManager implements Disposable { } } - if (!Registry.is("compiler.process.use.memory.temp.cache")) { - cmdLine.addParameter("-D"+ GlobalOptions.USE_MEMORY_TEMP_CACHE_OPTION + "=false"); - } - // javac's VM should use the same default locale that IDEA uses in order for javac to print messages in 'correct' language cmdLine.setCharset(mySystemCharset); cmdLine.addParameter("-D" + CharsetToolkit.FILE_ENCODING_PROPERTY + "=" + mySystemCharset.name()); diff --git a/jps/jps-builders/src/org/jetbrains/jps/api/BuildParametersKeys.java b/jps/jps-builders/src/org/jetbrains/jps/api/BuildParametersKeys.java index de6f1496bd3b..534fe1cf5359 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/api/BuildParametersKeys.java +++ b/jps/jps-builders/src/org/jetbrains/jps/api/BuildParametersKeys.java @@ -6,4 +6,5 @@ package org.jetbrains.jps.api; public interface BuildParametersKeys { String FORCE_MODEL_LOADING = "_force_model_loading"; String LOAD_UNLOADED_MODULES = "load_unloaded_modules"; + String IS_AUTOMAKE = "is_automake"; } diff --git a/jps/jps-builders/src/org/jetbrains/jps/api/GlobalOptions.java b/jps/jps-builders/src/org/jetbrains/jps/api/GlobalOptions.java index 72cd9f085cc9..d1b8998f9d30 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/api/GlobalOptions.java +++ b/jps/jps-builders/src/org/jetbrains/jps/api/GlobalOptions.java @@ -19,9 +19,12 @@ package org.jetbrains.jps.api; * @author Eugene Zhuravlev */ public interface GlobalOptions { + @Deprecated String USE_MEMORY_TEMP_CACHE_OPTION = "use.memory.temp.cache"; + String GENERATE_CLASSPATH_INDEX_OPTION = "generate.classpath.index"; String COMPILE_PARALLEL_OPTION = "compile.parallel"; + String ALLOW_PARALLEL_AUTOMAKE_OPTION = "allow.parallel.automake"; String COMPILE_PARALLEL_MAX_THREADS_OPTION = "compile.parallel.max.threads"; String REBUILD_ON_DEPENDENCY_CHANGE_OPTION = "rebuild.on.dependency.change"; String LOG_DIR_OPTION = "jps.log.dir"; diff --git a/jps/jps-builders/src/org/jetbrains/jps/cmdline/BuildRunner.java b/jps/jps-builders/src/org/jetbrains/jps/cmdline/BuildRunner.java index 7ae33dd1d8e5..2d59dd11ebf6 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/cmdline/BuildRunner.java +++ b/jps/jps-builders/src/org/jetbrains/jps/cmdline/BuildRunner.java @@ -57,7 +57,8 @@ import static org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage public class BuildRunner { private static final Logger LOG = Logger.getInstance("#org.jetbrains.jps.cmdline.BuildRunner"); public static final boolean PARALLEL_BUILD_ENABLED = Boolean.parseBoolean(System.getProperty(GlobalOptions.COMPILE_PARALLEL_OPTION, "false")); - private static final boolean STORE_TEMP_CACHES_IN_MEMORY = PARALLEL_BUILD_ENABLED || Boolean.valueOf(System.getProperty(GlobalOptions.USE_MEMORY_TEMP_CACHE_OPTION, "true")); + public static final boolean PARALLEL_BUILD_AUTOMAKE_ENABLED = PARALLEL_BUILD_ENABLED && Boolean.parseBoolean(System.getProperty(GlobalOptions.ALLOW_PARALLEL_AUTOMAKE_OPTION, "true")); + private static final boolean STORE_TEMP_CACHES_IN_MEMORY = true; private final JpsModelLoader myModelLoader; private List myFilePaths = Collections.emptyList(); private Map myBuilderParams = Collections.emptyMap(); diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/IncProjectBuilder.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/IncProjectBuilder.java index e2935aeed27f..9f359de91780 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/incremental/IncProjectBuilder.java +++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/IncProjectBuilder.java @@ -21,6 +21,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jps.ModuleChunk; import org.jetbrains.jps.TimingLog; +import org.jetbrains.jps.api.BuildParametersKeys; import org.jetbrains.jps.api.CanceledStatus; import org.jetbrains.jps.api.GlobalOptions; import org.jetbrains.jps.builders.*; @@ -323,6 +324,11 @@ public class IncProjectBuilder { } } + private static boolean isParallelBuild(CompileContext context) { + return Boolean.parseBoolean(context.getBuilderParameter(BuildParametersKeys.IS_AUTOMAKE)) ? + BuildRunner.PARALLEL_BUILD_AUTOMAKE_ENABLED : BuildRunner.PARALLEL_BUILD_ENABLED; + } + private void runBuild(final CompileContextImpl context, boolean forceCleanCaches) throws ProjectBuildException { context.setDone(0.0f); @@ -331,7 +337,7 @@ public class IncProjectBuilder { "; isMake:" + context.isMake() + " parallel compilation:" + - BuildRunner.PARALLEL_BUILD_ENABLED); + isParallelBuild(context)); context.addBuildListener(new ChainedTargetsBuildListener(context)); @@ -786,7 +792,7 @@ public class IncProjectBuilder { private void buildChunks(final CompileContextImpl context, BuildProgress buildProgress) throws ProjectBuildException { try { - boolean compileInParallel = BuildRunner.PARALLEL_BUILD_ENABLED; + boolean compileInParallel = isParallelBuild(context); if (compileInParallel && MAX_BUILDER_THREADS <= 1) { LOG.info("Switched off parallel compilation because maximum number of builder threads is less than 2. Set '" + GlobalOptions.COMPILE_PARALLEL_MAX_THREADS_OPTION + "' system property to a value greater than 1 to really enable parallel compilation."); diff --git a/platform/util/resources/misc/registry.properties b/platform/util/resources/misc/registry.properties index c5457c9cb6a3..2e47e825f5df 100644 --- a/platform/util/resources/misc/registry.properties +++ b/platform/util/resources/misc/registry.properties @@ -448,23 +448,12 @@ analyze.exceptions.on.the.fly=false analyze.exceptions.on.the.fly.description=Automatically analyze clipboard on frame activation,\ and if there is a stacktrace calls Analyze Stacktrace. -compiler.perform.outputs.refresh.on.start=false -compiler.perform.outputs.refresh.on.start.description=Whether to perform initial FS refresh before compilation starts.\ - Need this to detect external changes to output dirs. -compiler.max.static.constants.searches=3000 -compiler.max.static.constants.searches.description=If the number of changed compile time constants exceeds this value,\ - make will start full-project rebuild - compiler.process.jdk= compiler.process.jdk.description=Path to a JDK home. Force build process to be run using the JDK specified. It is assumed that the jdk is at least of version 1.6. compiler.process.32bit.vm.on.mac=true compiler.process.32bit.vm.on.mac.description=Force -d32 VM option on Mac (recommended for faster startup and lower memory footprint). -compiler.process.use.memory.temp.cache=true -compiler.process.use.memory.temp.cache.description=Store temporary data in memory for faster compilation;\ - requires larger heap size for the build process. If parallel build is enabled, the option is ignored and temp data is always stored in memory. - compiler.process.preload=true compiler.process.preload.description=After build finishes, the IDE will pre-load and leave waiting in memory the build process for the next compilation. This will save time for process start and project model loading (may be noticeable for big projects).\ @@ -493,6 +482,10 @@ compiler.build.data.unused.threshold.description=If project is not opened for th compiler.build.report.statistics=false compiler.build.report.statistics.description=Turn on to display builder execution times as 'Information' messages in compiler toolwindow. +compiler.automake.allow.parallel=true +compiler.automake.allow.parallel.description=The option allows to force automatically started builds to run in single-threaded mode even if 'Compile independent modules in parallel' is on\n\ + This might help to save CPU resources for the foreground processes. + vcs.annotations.preload=false vcs.showConsole=true vcs.log.bek.sort.disabled=false