diff --git a/java/compiler/impl/src/com/intellij/compiler/cache/CompilerCacheConfigurator.java b/java/compiler/impl/src/com/intellij/compiler/cache/CompilerCacheConfigurator.java index f317a64aef0e..7f3e54a687a5 100644 --- a/java/compiler/impl/src/com/intellij/compiler/cache/CompilerCacheConfigurator.java +++ b/java/compiler/impl/src/com/intellij/compiler/cache/CompilerCacheConfigurator.java @@ -6,7 +6,6 @@ import com.intellij.compiler.cache.client.CompilerCacheServerAuthUtil; import com.intellij.compiler.cache.client.CompilerCachesServerClient; import com.intellij.compiler.cache.git.GitCommitsIterator; import com.intellij.compiler.cache.git.GitRepositoryUtil; -import com.intellij.compiler.cache.statistic.CompilerCacheLoadingStats; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Pair; @@ -39,8 +38,11 @@ public class CompilerCacheConfigurator { builder.setDownloadCommit(commit.first); builder.setCommitsCountLatestBuild(commit.second); builder.putAllAuthHeaders(authHeaders); - builder.setDecompressionSpeed(CompilerCacheLoadingStats.getApproximateDecompressionSpeed()); - builder.setDeletionSpeed(CompilerCacheLoadingStats.getApproximateDeletionSpeed()); + builder.setDecompressionSpeed(CompilerCacheLoadingSettings.getApproximateDecompressionSpeed()); + builder.setDeletionSpeed(CompilerCacheLoadingSettings.getApproximateDeletionSpeed()); + builder.setForceDownload(CompilerCacheLoadingSettings.getForceUpdateValue()); + builder.setDisableDownload(CompilerCacheLoadingSettings.getDisableUpdateValue()); + builder.setMaxDownloadDuration(CompilerCacheLoadingSettings.getMaxDownloadDuration()); return builder.build(); } diff --git a/java/compiler/impl/src/com/intellij/compiler/cache/CompilerCacheLoadingSettings.java b/java/compiler/impl/src/com/intellij/compiler/cache/CompilerCacheLoadingSettings.java new file mode 100644 index 000000000000..019fd18dfaf1 --- /dev/null +++ b/java/compiler/impl/src/com/intellij/compiler/cache/CompilerCacheLoadingSettings.java @@ -0,0 +1,78 @@ +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +package com.intellij.compiler.cache; + +import com.intellij.ide.util.PropertiesComponent; +import com.intellij.openapi.diagnostic.Logger; + +public class CompilerCacheLoadingSettings { + private static final Logger LOG = Logger.getInstance(CompilerCacheLoadingSettings.class); + + private static final String FORCE_UPDATE = "JpsOutputLoaderManager.forceUpdate"; + private static final String DISABLE_UPDATE = "JpsOutputLoaderManager.disableUpdate"; + private static final String MAX_DOWNLOAD_DURATION = "JpsOutputLoaderManager.maxDownloadDuration"; + private static final String APPROXIMATE_DELETION_SPEED = "JpsOutputLoaderManager.deletionBytesPerSec"; + private static final String APPROXIMATE_DECOMPRESSION_SPEED = "JpsOutputLoaderManager.decompressionBytesPerSec"; + + public static void saveForceUpdateValue(boolean forceUpdate) { + PropertiesComponent.getInstance().setValue(FORCE_UPDATE, forceUpdate); + LOG.info("Saving force update value: " + forceUpdate); + } + + public static boolean getForceUpdateValue() { + boolean forceUpdate = PropertiesComponent.getInstance().getBoolean(FORCE_UPDATE, false); + LOG.info("Getting force update value: " + forceUpdate); + return forceUpdate; + } + + public static void saveDisableUpdateValue(boolean disableUpdate) { + PropertiesComponent.getInstance().setValue(DISABLE_UPDATE, disableUpdate); + LOG.info("Saving disable update value: " + disableUpdate); + } + + public static boolean getDisableUpdateValue() { + boolean disableUpdate = PropertiesComponent.getInstance().getBoolean(DISABLE_UPDATE, false); + LOG.info("Getting disable update value: " + disableUpdate); + return disableUpdate; + } + + public static void saveMaxDownloadDuration(int maxDownloadDuration) { + PropertiesComponent.getInstance().setValue(MAX_DOWNLOAD_DURATION, String.valueOf(maxDownloadDuration)); + LOG.info("Saving max download duration: " + maxDownloadDuration); + } + + public static int getMaxDownloadDuration() { + int maxDownloadDuration = PropertiesComponent.getInstance().getInt(MAX_DOWNLOAD_DURATION, 10); + LOG.info("Getting max download duration: " + maxDownloadDuration); + return maxDownloadDuration; + } + + public static void saveApproximateDeletionSpeed(long deletionSpeed) { + if (deletionSpeed == 0) { + LOG.info("Deletion speed has default value and will be skipped"); + return; + } + PropertiesComponent.getInstance().setValue(APPROXIMATE_DELETION_SPEED, String.valueOf(deletionSpeed)); + LOG.info("Saving approximate deletion speed: " + deletionSpeed); + } + + public static long getApproximateDeletionSpeed() { + long deletionSpeed = PropertiesComponent.getInstance().getLong(APPROXIMATE_DELETION_SPEED, 0); + LOG.info("Getting approximate deletion speed: " + deletionSpeed); + return deletionSpeed; + } + + public static void saveApproximateDecompressionSpeed(long decompressionSpeed) { + if (decompressionSpeed == 0) { + LOG.info("Decompression speed has default value and will be skipped"); + return; + } + PropertiesComponent.getInstance().setValue(APPROXIMATE_DECOMPRESSION_SPEED, String.valueOf(decompressionSpeed)); + LOG.info("Saving approximate decompression speed: " + decompressionSpeed); + } + + public static long getApproximateDecompressionSpeed() { + long decompressionSpeed = PropertiesComponent.getInstance().getLong(APPROXIMATE_DECOMPRESSION_SPEED, 0); + LOG.info("Getting approximate decompression speed: " + decompressionSpeed); + return decompressionSpeed; + } +} diff --git a/java/compiler/impl/src/com/intellij/compiler/cache/statistic/CompilerCacheLoadingStats.java b/java/compiler/impl/src/com/intellij/compiler/cache/statistic/CompilerCacheLoadingStats.java deleted file mode 100644 index 0c65ab1b4ae3..000000000000 --- a/java/compiler/impl/src/com/intellij/compiler/cache/statistic/CompilerCacheLoadingStats.java +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -package com.intellij.compiler.cache.statistic; - -import com.intellij.ide.util.PropertiesComponent; -import com.intellij.openapi.diagnostic.Logger; - -public class CompilerCacheLoadingStats { - private static final Logger LOG = Logger.getInstance(CompilerCacheLoadingStats.class); - private static final String APPROXIMATE_DELETION_SPEED = "JpsOutputLoaderManager.deletionBytesPerSec"; - private static final String APPROXIMATE_DECOMPRESSION_SPEED = "JpsOutputLoaderManager.decompressionBytesPerSec"; - - public static void saveApproximateDeletionSpeed(long deletionSpeed) { - if (deletionSpeed == 0) { - LOG.info("Deletion speed has default value and will be skipped"); - return; - } - PropertiesComponent.getInstance().setValue(APPROXIMATE_DELETION_SPEED, String.valueOf(deletionSpeed)); - LOG.info("Saving approximate deletion speed: " + deletionSpeed); - } - - public static long getApproximateDeletionSpeed() { - long deletionSpeed = PropertiesComponent.getInstance().getLong(APPROXIMATE_DELETION_SPEED, 0); - LOG.info("Getting approximate deletion speed: " + deletionSpeed); - return deletionSpeed; - } - - public static void saveApproximateDecompressionSpeed(long decompressionSpeed) { - if (decompressionSpeed == 0) { - LOG.info("Decompression speed has default value and will be skipped"); - return; - } - PropertiesComponent.getInstance().setValue(APPROXIMATE_DECOMPRESSION_SPEED, String.valueOf(decompressionSpeed)); - LOG.info("Saving approximate decompression speed: " + decompressionSpeed); - } - - public static long getApproximateDecompressionSpeed() { - long decompressionSpeed = PropertiesComponent.getInstance().getLong(APPROXIMATE_DECOMPRESSION_SPEED, 0); - LOG.info("Getting approximate decompression speed: " + decompressionSpeed); - return decompressionSpeed; - } -} diff --git a/java/compiler/impl/src/com/intellij/compiler/cache/ui/CompilerCacheConfigurable.java b/java/compiler/impl/src/com/intellij/compiler/cache/ui/CompilerCacheConfigurable.java new file mode 100644 index 000000000000..2074495a7584 --- /dev/null +++ b/java/compiler/impl/src/com/intellij/compiler/cache/ui/CompilerCacheConfigurable.java @@ -0,0 +1,77 @@ +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +package com.intellij.compiler.cache.ui; + +import com.intellij.compiler.cache.CompilerCacheLoadingSettings; +import com.intellij.compiler.options.ComparingUtils; +import com.intellij.compiler.server.BuildManager; +import com.intellij.openapi.compiler.JavaCompilerBundle; +import com.intellij.openapi.options.Configurable; +import com.intellij.openapi.options.ConfigurationException; +import com.intellij.openapi.options.SearchableConfigurable; +import com.intellij.openapi.project.Project; +import com.intellij.ui.components.JBCheckBox; +import com.intellij.ui.components.JBLabel; +import org.jetbrains.annotations.NotNull; + +import javax.swing.*; + +public class CompilerCacheConfigurable implements SearchableConfigurable, Configurable.NoScroll { + private JPanel myPanel; + private final Project myProject; + private JBLabel myForceUpdateDescription; + private JBCheckBox myCbForceUpdateCaches; + private JBCheckBox myCbDisableCacheDownload; + private JTextField myMaxDownloadDurationField; + private JBLabel myMaxDownloadDurationDescription; + + public CompilerCacheConfigurable(final Project project) { + myProject = project; + myForceUpdateDescription.setText("Turn off the heuristic that determines when it's faster to download cache or build locally and force downloads the nearest cache at each build"); //NON-NLS + myMaxDownloadDurationDescription.setText("Set maximum applicable time of caches download. If the approximate time of work will be higher local build will be executed."); //NON-NLS + } + + @Override + public String getDisplayName() { + return JavaCompilerBundle.message("compiler.cache.description"); + } + + @Override + @NotNull + public String getId() { + return "reference.projectsettings.compiler.compilercache"; + } + + @Override + public JComponent createComponent() { + return myPanel; + } + + @Override + public boolean isModified() { + boolean isModified = ComparingUtils.isModified(myCbForceUpdateCaches, CompilerCacheLoadingSettings.getForceUpdateValue()); + isModified |= ComparingUtils.isModified(myCbDisableCacheDownload, CompilerCacheLoadingSettings.getDisableUpdateValue()); + isModified |= ComparingUtils.isModified(myMaxDownloadDurationField, String.valueOf(CompilerCacheLoadingSettings.getMaxDownloadDuration())); + return isModified; + } + + @Override + public void apply() throws ConfigurationException { + try { + CompilerCacheLoadingSettings.saveForceUpdateValue(myCbForceUpdateCaches.isSelected()); + CompilerCacheLoadingSettings.saveDisableUpdateValue(myCbDisableCacheDownload.isSelected()); + CompilerCacheLoadingSettings.saveMaxDownloadDuration(Integer.parseInt(myMaxDownloadDurationField.getText())); + } + finally { + if (!myProject.isDefault()) { + BuildManager.getInstance().clearState(myProject); + } + } + } + + @Override + public void reset() { + myCbForceUpdateCaches.setSelected(CompilerCacheLoadingSettings.getForceUpdateValue()); + myCbDisableCacheDownload.setSelected(CompilerCacheLoadingSettings.getDisableUpdateValue()); + myMaxDownloadDurationField.setText(String.valueOf(CompilerCacheLoadingSettings.getMaxDownloadDuration())); + } +} diff --git a/java/compiler/impl/src/com/intellij/compiler/cache/ui/CompilerCacheConfigurableProvider.java b/java/compiler/impl/src/com/intellij/compiler/cache/ui/CompilerCacheConfigurableProvider.java new file mode 100644 index 000000000000..c0beac0119a6 --- /dev/null +++ b/java/compiler/impl/src/com/intellij/compiler/cache/ui/CompilerCacheConfigurableProvider.java @@ -0,0 +1,28 @@ +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +package com.intellij.compiler.cache.ui; + +import com.intellij.openapi.options.Configurable; +import com.intellij.openapi.options.ConfigurableProvider; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.registry.Registry; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class CompilerCacheConfigurableProvider extends ConfigurableProvider { + @NotNull + private final Project myProject; + + public CompilerCacheConfigurableProvider(@NotNull Project project) { + myProject = project; + } + + @Override + public @Nullable Configurable createConfigurable() { + return new CompilerCacheConfigurable(myProject); + } + + @Override + public boolean canCreateConfigurable() { + return Registry.is("compiler.process.use.portable.caches"); + } +} diff --git a/java/compiler/impl/src/com/intellij/compiler/cache/ui/CompilerCacheOptionsPanel.form b/java/compiler/impl/src/com/intellij/compiler/cache/ui/CompilerCacheOptionsPanel.form new file mode 100644 index 000000000000..ab13e4a8e9b9 --- /dev/null +++ b/java/compiler/impl/src/com/intellij/compiler/cache/ui/CompilerCacheOptionsPanel.form @@ -0,0 +1,109 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/java/compiler/impl/src/com/intellij/compiler/server/DefaultMessageHandler.java b/java/compiler/impl/src/com/intellij/compiler/server/DefaultMessageHandler.java index f38182ea86be..262b37b68a16 100644 --- a/java/compiler/impl/src/com/intellij/compiler/server/DefaultMessageHandler.java +++ b/java/compiler/impl/src/com/intellij/compiler/server/DefaultMessageHandler.java @@ -1,19 +1,15 @@ // Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.compiler.server; -import com.intellij.compiler.cache.client.CompilerCacheServerAuthUtil; import com.intellij.compiler.cache.git.GitRepositoryUtil; -import com.intellij.compiler.cache.statistic.CompilerCacheLoadingStats; +import com.intellij.compiler.cache.CompilerCacheLoadingSettings; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.project.Project; import io.netty.channel.Channel; import org.jetbrains.annotations.NotNull; -import org.jetbrains.jps.api.CmdlineProtoUtil; import org.jetbrains.jps.api.CmdlineRemoteProto; -import java.util.List; -import java.util.Map; import java.util.UUID; public abstract class DefaultMessageHandler implements BuilderMessageHandler { @@ -63,8 +59,8 @@ public abstract class DefaultMessageHandler implements BuilderMessageHandler { case SAVE_LATEST_DOWNLOAD_STATISTIC_MESSAGE: CmdlineRemoteProto.Message.BuilderMessage.CommitAndDownloadStatistics downloadStatisticsMessage = msg.getCommitAndDownloadStatistics(); GitRepositoryUtil.saveLatestDownloadedCommit(downloadStatisticsMessage.getCommit()); - CompilerCacheLoadingStats.saveApproximateDecompressionSpeed(downloadStatisticsMessage.getDecompressionSpeed()); - CompilerCacheLoadingStats.saveApproximateDeletionSpeed(downloadStatisticsMessage.getDeletionSpeed()); + CompilerCacheLoadingSettings.saveApproximateDecompressionSpeed(downloadStatisticsMessage.getDecompressionSpeed()); + CompilerCacheLoadingSettings.saveApproximateDeletionSpeed(downloadStatisticsMessage.getDeletionSpeed()); break; case SAVE_LATEST_BUILT_COMMIT_MESSAGE: GitRepositoryUtil.saveLatestBuiltMasterCommit(myProject); diff --git a/java/compiler/openapi/resources/messages/JavaCompilerBundle.properties b/java/compiler/openapi/resources/messages/JavaCompilerBundle.properties index 8d1093e4804f..e0d4c4c7e35f 100644 --- a/java/compiler/openapi/resources/messages/JavaCompilerBundle.properties +++ b/java/compiler/openapi/resources/messages/JavaCompilerBundle.properties @@ -330,6 +330,11 @@ progress.preparing.wsl.build.environment=Preparing WSL build environment... plugins.advertiser.feature.artifact=artifact notification.group.compiler=Build finished +compiler.cache.description=Compiler Cache +compiler.cache.option.force.update=Force update caches +compiler.cache.option.disable.update=Disable cache download +compiler.cache.option.max.download.time=Maximum duration of caches download: +compiler.cache.option.max.download.time.units= mins notification.title.jps.caches.downloader=Jps caches downloader notification.content.internal.authentication.plugin.required.for.correct.work=JetBrains Internal Authentication is required for the correct work of JPS Caches internal.authentication.plugin.missing.token=Unexpected state: jetbrains.team token is missing. Please report this exception and perform actions 'Logout from JetBrains.team' and 'Login to JetBrains.team' as a workaround diff --git a/java/java-impl/src/META-INF/JavaPlugin.xml b/java/java-impl/src/META-INF/JavaPlugin.xml index 282897c1347e..f107afb124df 100644 --- a/java/java-impl/src/META-INF/JavaPlugin.xml +++ b/java/java-impl/src/META-INF/JavaPlugin.xml @@ -533,6 +533,9 @@ key="rmi.compiler.description" bundle="messages.JavaCompilerBundle"/> + + diff --git a/jps/jps-builders/gen/org/jetbrains/jps/api/CmdlineRemoteProto.java b/jps/jps-builders/gen/org/jetbrains/jps/api/CmdlineRemoteProto.java index c67776bf891f..9a00b61af5d4 100644 --- a/jps/jps-builders/gen/org/jetbrains/jps/api/CmdlineRemoteProto.java +++ b/jps/jps-builders/gen/org/jetbrains/jps/api/CmdlineRemoteProto.java @@ -5544,6 +5544,39 @@ public final class CmdlineRemoteProto { * @return The deletionSpeed. */ long getDeletionSpeed(); + + /** + * required bool force_download = 7; + * @return Whether the forceDownload field is set. + */ + boolean hasForceDownload(); + /** + * required bool force_download = 7; + * @return The forceDownload. + */ + boolean getForceDownload(); + + /** + * required bool disable_download = 8; + * @return Whether the disableDownload field is set. + */ + boolean hasDisableDownload(); + /** + * required bool disable_download = 8; + * @return The disableDownload. + */ + boolean getDisableDownload(); + + /** + * required int32 max_download_duration = 9; + * @return Whether the maxDownloadDuration field is set. + */ + boolean hasMaxDownloadDuration(); + /** + * required int32 max_download_duration = 9; + * @return The maxDownloadDuration. + */ + int getMaxDownloadDuration(); } /** * Protobuf type {@code org.jetbrains.jpsservice.Message.ControllerMessage.CacheDownloadSettings} @@ -5861,6 +5894,108 @@ public final class CmdlineRemoteProto { deletionSpeed_ = 0L; } + public static final int FORCE_DOWNLOAD_FIELD_NUMBER = 7; + private boolean forceDownload_; + /** + * required bool force_download = 7; + * @return Whether the forceDownload field is set. + */ + @java.lang.Override + public boolean hasForceDownload() { + return ((bitField0_ & 0x00000020) != 0); + } + /** + * required bool force_download = 7; + * @return The forceDownload. + */ + @java.lang.Override + public boolean getForceDownload() { + return forceDownload_; + } + /** + * required bool force_download = 7; + * @param value The forceDownload to set. + */ + private void setForceDownload(boolean value) { + bitField0_ |= 0x00000020; + forceDownload_ = value; + } + /** + * required bool force_download = 7; + */ + private void clearForceDownload() { + bitField0_ = (bitField0_ & ~0x00000020); + forceDownload_ = false; + } + + public static final int DISABLE_DOWNLOAD_FIELD_NUMBER = 8; + private boolean disableDownload_; + /** + * required bool disable_download = 8; + * @return Whether the disableDownload field is set. + */ + @java.lang.Override + public boolean hasDisableDownload() { + return ((bitField0_ & 0x00000040) != 0); + } + /** + * required bool disable_download = 8; + * @return The disableDownload. + */ + @java.lang.Override + public boolean getDisableDownload() { + return disableDownload_; + } + /** + * required bool disable_download = 8; + * @param value The disableDownload to set. + */ + private void setDisableDownload(boolean value) { + bitField0_ |= 0x00000040; + disableDownload_ = value; + } + /** + * required bool disable_download = 8; + */ + private void clearDisableDownload() { + bitField0_ = (bitField0_ & ~0x00000040); + disableDownload_ = false; + } + + public static final int MAX_DOWNLOAD_DURATION_FIELD_NUMBER = 9; + private int maxDownloadDuration_; + /** + * required int32 max_download_duration = 9; + * @return Whether the maxDownloadDuration field is set. + */ + @java.lang.Override + public boolean hasMaxDownloadDuration() { + return ((bitField0_ & 0x00000080) != 0); + } + /** + * required int32 max_download_duration = 9; + * @return The maxDownloadDuration. + */ + @java.lang.Override + public int getMaxDownloadDuration() { + return maxDownloadDuration_; + } + /** + * required int32 max_download_duration = 9; + * @param value The maxDownloadDuration to set. + */ + private void setMaxDownloadDuration(int value) { + bitField0_ |= 0x00000080; + maxDownloadDuration_ = value; + } + /** + * required int32 max_download_duration = 9; + */ + private void clearMaxDownloadDuration() { + bitField0_ = (bitField0_ & ~0x00000080); + maxDownloadDuration_ = 0; + } + public static org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.CacheDownloadSettings parseFrom( java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { @@ -6276,6 +6411,114 @@ public final class CmdlineRemoteProto { return this; } + /** + * required bool force_download = 7; + * @return Whether the forceDownload field is set. + */ + @java.lang.Override + public boolean hasForceDownload() { + return instance.hasForceDownload(); + } + /** + * required bool force_download = 7; + * @return The forceDownload. + */ + @java.lang.Override + public boolean getForceDownload() { + return instance.getForceDownload(); + } + /** + * required bool force_download = 7; + * @param value The forceDownload to set. + * @return This builder for chaining. + */ + public Builder setForceDownload(boolean value) { + copyOnWrite(); + instance.setForceDownload(value); + return this; + } + /** + * required bool force_download = 7; + * @return This builder for chaining. + */ + public Builder clearForceDownload() { + copyOnWrite(); + instance.clearForceDownload(); + return this; + } + + /** + * required bool disable_download = 8; + * @return Whether the disableDownload field is set. + */ + @java.lang.Override + public boolean hasDisableDownload() { + return instance.hasDisableDownload(); + } + /** + * required bool disable_download = 8; + * @return The disableDownload. + */ + @java.lang.Override + public boolean getDisableDownload() { + return instance.getDisableDownload(); + } + /** + * required bool disable_download = 8; + * @param value The disableDownload to set. + * @return This builder for chaining. + */ + public Builder setDisableDownload(boolean value) { + copyOnWrite(); + instance.setDisableDownload(value); + return this; + } + /** + * required bool disable_download = 8; + * @return This builder for chaining. + */ + public Builder clearDisableDownload() { + copyOnWrite(); + instance.clearDisableDownload(); + return this; + } + + /** + * required int32 max_download_duration = 9; + * @return Whether the maxDownloadDuration field is set. + */ + @java.lang.Override + public boolean hasMaxDownloadDuration() { + return instance.hasMaxDownloadDuration(); + } + /** + * required int32 max_download_duration = 9; + * @return The maxDownloadDuration. + */ + @java.lang.Override + public int getMaxDownloadDuration() { + return instance.getMaxDownloadDuration(); + } + /** + * required int32 max_download_duration = 9; + * @param value The maxDownloadDuration to set. + * @return This builder for chaining. + */ + public Builder setMaxDownloadDuration(int value) { + copyOnWrite(); + instance.setMaxDownloadDuration(value); + return this; + } + /** + * required int32 max_download_duration = 9; + * @return This builder for chaining. + */ + public Builder clearMaxDownloadDuration() { + copyOnWrite(); + instance.clearMaxDownloadDuration(); + return this; + } + // @@protoc_insertion_point(builder_scope:org.jetbrains.jpsservice.Message.ControllerMessage.CacheDownloadSettings) } private byte memoizedIsInitialized = 2; @@ -6301,10 +6544,14 @@ public final class CmdlineRemoteProto { "serverUrl_", "decompressionSpeed_", "deletionSpeed_", + "forceDownload_", + "disableDownload_", + "maxDownloadDuration_", }; java.lang.String info = - "\u0001\u0006\u0000\u0001\u0001\u0006\u0006\u0001\u0000\u0005\u00012\u0002\u1508\u0000" + - "\u0003\u1504\u0001\u0004\u1508\u0002\u0005\u1502\u0003\u0006\u1502\u0004"; + "\u0001\t\u0000\u0001\u0001\t\t\u0001\u0000\b\u00012\u0002\u1508\u0000\u0003\u1504" + + "\u0001\u0004\u1508\u0002\u0005\u1502\u0003\u0006\u1502\u0004\u0007\u1507\u0005\b" + + "\u1507\u0006\t\u1504\u0007"; return newMessageInfo(DEFAULT_INSTANCE, info, objects); } // fall through diff --git a/jps/jps-builders/proto/cmdline_remote_proto.proto b/jps/jps-builders/proto/cmdline_remote_proto.proto index e7a10f39ce79..f7ff0f11b27d 100644 --- a/jps/jps-builders/proto/cmdline_remote_proto.proto +++ b/jps/jps-builders/proto/cmdline_remote_proto.proto @@ -83,6 +83,9 @@ message Message { required string server_url = 4; required int64 decompression_speed = 5; required int64 deletion_speed = 6; + required bool force_download = 7; + required bool disable_download = 8; + required int32 max_download_duration = 9; } required Type type = 1; diff --git a/jps/jps-builders/src/org/jetbrains/jps/cache/loader/JpsOutputLoaderManager.java b/jps/jps-builders/src/org/jetbrains/jps/cache/loader/JpsOutputLoaderManager.java index 635b822a8529..c212cbeea4be 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/cache/loader/JpsOutputLoaderManager.java +++ b/jps/jps-builders/src/org/jetbrains/jps/cache/loader/JpsOutputLoaderManager.java @@ -41,13 +41,11 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.atomic.AtomicBoolean; import static com.intellij.execution.process.ProcessIOExecutorService.INSTANCE; -import static org.jetbrains.jps.incremental.storage.ProjectStamps.FORCE_DOWNLOAD_PORTABLE_CACHES; public class JpsOutputLoaderManager { private static final Logger LOG = Logger.getInstance(JpsOutputLoaderManager.class); private static final String FS_STATE_FILE = "fs_state.dat"; // Downloading caches applicable only for the good internet connection - private static final int MAX_DOWNLOAD_DURATION = 600; private static final int PROJECT_MODULE_DOWNLOAD_SIZE_BYTES = 512_000; private static final int AVERAGE_CACHE_SIZE_BYTES = 512_000 * 1024; private static final int PROJECT_MODULE_SIZE_DISK_BYTES = 921_600; @@ -59,9 +57,11 @@ public class JpsOutputLoaderManager { private final CanceledStatus myCanceledStatus; private final JpsServerClient myServerClient; private boolean isCacheDownloaded; + private final boolean isForceCachesDownload; private final String myBuildOutDir; private final String myProjectPath; private final String myCommitHash; + private final int myMaxDownloadDuration; private final int myCommitsCountBetweenCompilation; private final JpsNettyClient myNettyClient; @@ -80,6 +80,8 @@ public class JpsOutputLoaderManager { myMetadataLoader = new JpsMetadataLoader(projectPath, myServerClient); myCommitHash = cacheDownloadSettings.getDownloadCommit(); myCommitsCountBetweenCompilation = cacheDownloadSettings.getCommitsCountLatestBuild(); + myMaxDownloadDuration = cacheDownloadSettings.getMaxDownloadDuration() * 60; + isForceCachesDownload = cacheDownloadSettings.getForceDownload(); JpsServerAuthUtil.setRequestHeaders(cacheDownloadSettings.getAuthHeadersMap()); JpsCacheLoadingSystemStats.setDeletionSpeed(cacheDownloadSettings.getDeletionSpeed()); JpsCacheLoadingSystemStats.setDecompressionSpeed(cacheDownloadSettings.getDecompressionSpeed()); @@ -88,7 +90,7 @@ public class JpsOutputLoaderManager { public void load(@NotNull BuildRunner buildRunner, boolean isForceUpdate, @NotNull List scopes) { if (!canRunNewLoading()) return; - if (FORCE_DOWNLOAD_PORTABLE_CACHES || isDownloadQuickerThanLocalBuild(buildRunner, myCommitsCountBetweenCompilation, scopes)) { + if (isForceCachesDownload || isDownloadQuickerThanLocalBuild(buildRunner, myCommitsCountBetweenCompilation, scopes)) { // Drop JPS metadata to force plugin for downloading all compilation outputs myNettyClient.sendDescriptionStatusMessage(JpsBuildBundle.message("progress.text.fetching.cache.for.commit", myCommitHash)); if (isForceUpdate) { @@ -110,6 +112,7 @@ public class JpsOutputLoaderManager { } public void updateBuildStatistic(@NotNull ProjectDescriptor projectDescriptor) { + if (isForceCachesDownload) return; if (!hasRunningTask.get() && isCacheDownloaded) { BuildTargetsState targetsState = projectDescriptor.getTargetsState(); myOriginalBuildStatistic.getBuildTargetTypeStatistic().forEach((buildTargetType, originalBuildTime) -> { @@ -119,7 +122,6 @@ public class JpsOutputLoaderManager { Long originalBuildStatisticProjectRebuildTime = myOriginalBuildStatistic.getProjectRebuildTime(); targetsState.setLastSuccessfulRebuildDuration(originalBuildStatisticProjectRebuildTime); LOG.info("Saving old project rebuild time " + originalBuildStatisticProjectRebuildTime); - } } @@ -165,7 +167,7 @@ public class JpsOutputLoaderManager { return approximateDownloadTime < approximateBuildTime; } - private static long calculateApproximateDownloadTimeMs(SystemOpsStatistic systemOpsStatistic, int projectModulesCount) { + private long calculateApproximateDownloadTimeMs(SystemOpsStatistic systemOpsStatistic, int projectModulesCount) { double magicCoefficient = 1.3; long decompressionSpeed; if (JpsCacheLoadingSystemStats.getDecompressionSpeedBytesPesSec() > 0) { @@ -192,7 +194,7 @@ public class JpsOutputLoaderManager { "Expected decompression time: " + expectedDecompressionTimeSec + "sec. " + "Expected size to delete: " + StringUtil.formatFileSize(approximateDownloadSize) + ". Expected delete time: " + expectedDeleteTimeSec + "sec. " + "Total time of work: " + StringUtil.formatDuration(expectedTimeOfWorkMs)); - if (expectedDownloadTimeSec >= MAX_DOWNLOAD_DURATION) { + if (expectedDownloadTimeSec >= myMaxDownloadDuration) { LOG.info("Downloading can consume more than 10 mins, connection speed is too small for caches usages"); return 0; } diff --git a/jps/jps-builders/src/org/jetbrains/jps/cmdline/BuildSession.java b/jps/jps-builders/src/org/jetbrains/jps/cmdline/BuildSession.java index b480ebf2a8bb..f1a805538bb2 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/cmdline/BuildSession.java +++ b/jps/jps-builders/src/org/jetbrains/jps/cmdline/BuildSession.java @@ -44,7 +44,6 @@ import java.util.*; import java.util.concurrent.Executor; import static org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ParametersMessage.TargetTypeBuildScope; -import static org.jetbrains.jps.incremental.storage.ProjectStamps.FORCE_DOWNLOAD_PORTABLE_CACHES; /** * @author Eugene Zhuravlev @@ -170,10 +169,15 @@ final class BuildSession implements Runnable, CanceledStatus { myCacheLoadManager = null; if (ProjectStamps.PORTABLE_CACHES && myCacheDownloadSettings != null) { - LOG.info("Trying to download JPS caches before build"); - myCacheLoadManager = new JpsOutputLoaderManager(myBuildRunner.loadModelAndGetJpsProject(), this, myProjectPath, myChannel, - mySessionId, myCacheDownloadSettings); - myCacheLoadManager.load(myBuildRunner, true, myScopes); + LOG.info("Cache download settings: disableDownload=" + myCacheDownloadSettings.getDisableDownload() + "; forceUpdate=" + myCacheDownloadSettings.getForceDownload()); + if (myCacheDownloadSettings.getDisableDownload()) { + LOG.info("Cache download is disabled"); + } else { + LOG.info("Trying to download JPS caches before build"); + myCacheLoadManager = new JpsOutputLoaderManager(myBuildRunner.loadModelAndGetJpsProject(), this, myProjectPath, myChannel, + mySessionId, myCacheDownloadSettings); + myCacheLoadManager.load(myBuildRunner, true, myScopes); + } } runBuild(new MessageHandler() { @@ -345,7 +349,7 @@ final class BuildSession implements Runnable, CanceledStatus { } } myProjectDescriptor = pd; - if (myCacheLoadManager != null && !FORCE_DOWNLOAD_PORTABLE_CACHES) myCacheLoadManager.updateBuildStatistic(myProjectDescriptor); + if (myCacheLoadManager != null) myCacheLoadManager.updateBuildStatistic(myProjectDescriptor); myLastEventOrdinal = myInitialFSDelta != null? myInitialFSDelta.getOrdinal() : 0L; diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/storage/ProjectStamps.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/storage/ProjectStamps.java index ad4fc12e9794..3c0a7e230ea2 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/incremental/storage/ProjectStamps.java +++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/storage/ProjectStamps.java @@ -14,7 +14,6 @@ import java.io.IOException; public final class ProjectStamps { public static final String PORTABLE_CACHES_PROPERTY = "org.jetbrains.jps.portable.caches"; public static final boolean PORTABLE_CACHES = Boolean.getBoolean(PORTABLE_CACHES_PROPERTY); - public static final boolean FORCE_DOWNLOAD_PORTABLE_CACHES = Boolean.getBoolean("org.jetbrains.jps.portable.caches.force.download"); private static final Logger LOG = Logger.getInstance(ProjectStamps.class); diff --git a/platform/util/resources/misc/registry.properties b/platform/util/resources/misc/registry.properties index 429fd2eb88e1..ff5be71e9067 100644 --- a/platform/util/resources/misc/registry.properties +++ b/platform/util/resources/misc/registry.properties @@ -671,6 +671,7 @@ compiler.natural.int.multimap.impl=false compiler.natural.int.multimap.impl.description=Experimental implementation for class-to-class dependency multimap in JPS caches.\nIf turned off after being turned on, project rebuild is required. compiler.process.use.portable.caches=false +compiler.process.use.portable.caches.restartRequired=true compiler.process.use.portable.caches.description=Warning: for Intellij project only! \nTurn on to download compilation caches for reducing build time. vcs.showConsole=true