[jps caches] Add configuration settings for cache download

GitOrigin-RevId: a2abd62bd7e4afe5efa7c0a71df983fdd7c43617
This commit is contained in:
Mikhail Mazurkevich
2022-06-29 22:04:54 +00:00
committed by intellij-monorepo-bot
parent 63c4ffc2bc
commit 4966f7ef3c
15 changed files with 579 additions and 66 deletions
@@ -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();
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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("<html>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</html>"); //NON-NLS
myMaxDownloadDurationDescription.setText("<html>Set maximum applicable time of caches download. If the approximate time of work will be higher local build will be executed.</html>"); //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()));
}
}
@@ -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");
}
}
@@ -0,0 +1,109 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.compiler.cache.ui.CompilerCacheConfigurable">
<grid id="49284" binding="myPanel" layout-manager="GridLayoutManager" row-count="7" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="37" y="129" width="737" height="280"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="4d1d3" class="com.intellij.ui.components.JBCheckBox" binding="myCbForceUpdateCaches">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/JavaCompilerBundle" key="compiler.cache.option.force.update"/>
</properties>
</component>
<component id="b8f3d" class="com.intellij.ui.components.JBCheckBox" binding="myCbDisableCacheDownload">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/JavaCompilerBundle" key="compiler.cache.option.disable.update"/>
</properties>
</component>
<component id="ffd9f" class="com.intellij.ui.components.JBLabel">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="3" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<componentStyle value="SMALL"/>
<fontColor value="BRIGHTER"/>
<text value="Turn off the caches download for example when you have a limited internet connection." noi18n="true"/>
</properties>
</component>
<component id="f9bc" class="com.intellij.ui.components.JBLabel" binding="myMaxDownloadDurationDescription">
<constraints>
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<componentStyle value="SMALL"/>
<fontColor value="BRIGHTER"/>
<text value="" noi18n="true"/>
</properties>
</component>
<component id="534eb" class="com.intellij.ui.components.JBLabel" binding="myForceUpdateDescription">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<background color="-1907998"/>
<componentStyle value="SMALL"/>
<fontColor value="BRIGHTER"/>
<horizontalAlignment value="10"/>
<horizontalTextPosition value="11"/>
<text value="" noi18n="true"/>
<verticalAlignment value="0"/>
</properties>
</component>
<grid id="61cec" layout-manager="GridLayoutManager" row-count="1" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
<preferred-size width="883" height="34"/>
</grid>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="f8a80" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/JavaCompilerBundle" key="compiler.cache.option.max.download.time"/>
</properties>
</component>
<component id="2fc79" class="javax.swing.JTextField" binding="myMaxDownloadDurationField">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<columns value="5"/>
</properties>
</component>
<component id="f6206" class="com.intellij.ui.components.JBLabel">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/JavaCompilerBundle" key="compiler.cache.option.max.download.time.units"/>
</properties>
</component>
<hspacer id="81e4b">
<constraints>
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
</children>
</grid>
<vspacer id="e338e">
<constraints>
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
</children>
</grid>
</form>
@@ -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);
@@ -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=<a href="https://plugins.jetbrains.com/plugin/14567-jetbrains-internal-authentication">JetBrains Internal Authentication</a> 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
@@ -533,6 +533,9 @@
key="rmi.compiler.description" bundle="messages.JavaCompilerBundle"/>
</projectConfigurable>
<projectConfigurable provider="com.intellij.compiler.cache.ui.CompilerCacheConfigurableProvider" id="reference.projectsettings.compiler.compilercache"
key="compiler.cache.description" bundle="messages.JavaCompilerBundle" parentId="project.propCompiler"/>
<actionOnSaveInfoProvider id="BuildOnSaveInfoProvider"
implementation="com.intellij.compiler.options.BuildOnSaveInfo$BuildOnSaveInfoProvider"
order="after FormatOnSaveInfoProvider, after EsLintOnSaveInfoProvider, after PrettierOnSaveInfoProvider, after FileWatcherOnSaveInfoProvider, after UploadOnSaveInfoProvider"/>
@@ -5544,6 +5544,39 @@ public final class CmdlineRemoteProto {
* @return The deletionSpeed.
*/
long getDeletionSpeed();
/**
* <code>required bool force_download = 7;</code>
* @return Whether the forceDownload field is set.
*/
boolean hasForceDownload();
/**
* <code>required bool force_download = 7;</code>
* @return The forceDownload.
*/
boolean getForceDownload();
/**
* <code>required bool disable_download = 8;</code>
* @return Whether the disableDownload field is set.
*/
boolean hasDisableDownload();
/**
* <code>required bool disable_download = 8;</code>
* @return The disableDownload.
*/
boolean getDisableDownload();
/**
* <code>required int32 max_download_duration = 9;</code>
* @return Whether the maxDownloadDuration field is set.
*/
boolean hasMaxDownloadDuration();
/**
* <code>required int32 max_download_duration = 9;</code>
* @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_;
/**
* <code>required bool force_download = 7;</code>
* @return Whether the forceDownload field is set.
*/
@java.lang.Override
public boolean hasForceDownload() {
return ((bitField0_ & 0x00000020) != 0);
}
/**
* <code>required bool force_download = 7;</code>
* @return The forceDownload.
*/
@java.lang.Override
public boolean getForceDownload() {
return forceDownload_;
}
/**
* <code>required bool force_download = 7;</code>
* @param value The forceDownload to set.
*/
private void setForceDownload(boolean value) {
bitField0_ |= 0x00000020;
forceDownload_ = value;
}
/**
* <code>required bool force_download = 7;</code>
*/
private void clearForceDownload() {
bitField0_ = (bitField0_ & ~0x00000020);
forceDownload_ = false;
}
public static final int DISABLE_DOWNLOAD_FIELD_NUMBER = 8;
private boolean disableDownload_;
/**
* <code>required bool disable_download = 8;</code>
* @return Whether the disableDownload field is set.
*/
@java.lang.Override
public boolean hasDisableDownload() {
return ((bitField0_ & 0x00000040) != 0);
}
/**
* <code>required bool disable_download = 8;</code>
* @return The disableDownload.
*/
@java.lang.Override
public boolean getDisableDownload() {
return disableDownload_;
}
/**
* <code>required bool disable_download = 8;</code>
* @param value The disableDownload to set.
*/
private void setDisableDownload(boolean value) {
bitField0_ |= 0x00000040;
disableDownload_ = value;
}
/**
* <code>required bool disable_download = 8;</code>
*/
private void clearDisableDownload() {
bitField0_ = (bitField0_ & ~0x00000040);
disableDownload_ = false;
}
public static final int MAX_DOWNLOAD_DURATION_FIELD_NUMBER = 9;
private int maxDownloadDuration_;
/**
* <code>required int32 max_download_duration = 9;</code>
* @return Whether the maxDownloadDuration field is set.
*/
@java.lang.Override
public boolean hasMaxDownloadDuration() {
return ((bitField0_ & 0x00000080) != 0);
}
/**
* <code>required int32 max_download_duration = 9;</code>
* @return The maxDownloadDuration.
*/
@java.lang.Override
public int getMaxDownloadDuration() {
return maxDownloadDuration_;
}
/**
* <code>required int32 max_download_duration = 9;</code>
* @param value The maxDownloadDuration to set.
*/
private void setMaxDownloadDuration(int value) {
bitField0_ |= 0x00000080;
maxDownloadDuration_ = value;
}
/**
* <code>required int32 max_download_duration = 9;</code>
*/
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;
}
/**
* <code>required bool force_download = 7;</code>
* @return Whether the forceDownload field is set.
*/
@java.lang.Override
public boolean hasForceDownload() {
return instance.hasForceDownload();
}
/**
* <code>required bool force_download = 7;</code>
* @return The forceDownload.
*/
@java.lang.Override
public boolean getForceDownload() {
return instance.getForceDownload();
}
/**
* <code>required bool force_download = 7;</code>
* @param value The forceDownload to set.
* @return This builder for chaining.
*/
public Builder setForceDownload(boolean value) {
copyOnWrite();
instance.setForceDownload(value);
return this;
}
/**
* <code>required bool force_download = 7;</code>
* @return This builder for chaining.
*/
public Builder clearForceDownload() {
copyOnWrite();
instance.clearForceDownload();
return this;
}
/**
* <code>required bool disable_download = 8;</code>
* @return Whether the disableDownload field is set.
*/
@java.lang.Override
public boolean hasDisableDownload() {
return instance.hasDisableDownload();
}
/**
* <code>required bool disable_download = 8;</code>
* @return The disableDownload.
*/
@java.lang.Override
public boolean getDisableDownload() {
return instance.getDisableDownload();
}
/**
* <code>required bool disable_download = 8;</code>
* @param value The disableDownload to set.
* @return This builder for chaining.
*/
public Builder setDisableDownload(boolean value) {
copyOnWrite();
instance.setDisableDownload(value);
return this;
}
/**
* <code>required bool disable_download = 8;</code>
* @return This builder for chaining.
*/
public Builder clearDisableDownload() {
copyOnWrite();
instance.clearDisableDownload();
return this;
}
/**
* <code>required int32 max_download_duration = 9;</code>
* @return Whether the maxDownloadDuration field is set.
*/
@java.lang.Override
public boolean hasMaxDownloadDuration() {
return instance.hasMaxDownloadDuration();
}
/**
* <code>required int32 max_download_duration = 9;</code>
* @return The maxDownloadDuration.
*/
@java.lang.Override
public int getMaxDownloadDuration() {
return instance.getMaxDownloadDuration();
}
/**
* <code>required int32 max_download_duration = 9;</code>
* @param value The maxDownloadDuration to set.
* @return This builder for chaining.
*/
public Builder setMaxDownloadDuration(int value) {
copyOnWrite();
instance.setMaxDownloadDuration(value);
return this;
}
/**
* <code>required int32 max_download_duration = 9;</code>
* @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
@@ -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;
@@ -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<CmdlineRemoteProto.Message.ControllerMessage.ParametersMessage.TargetTypeBuildScope> 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;
}
@@ -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;
@@ -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);
@@ -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