diff --git a/src/Agent.Plugins/GitCliManager.cs b/src/Agent.Plugins/GitCliManager.cs index ca36a5c69d..ff26e269d1 100644 --- a/src/Agent.Plugins/GitCliManager.cs +++ b/src/Agent.Plugins/GitCliManager.cs @@ -87,7 +87,16 @@ public virtual async Task LoadGitExecutionInfo(AgentTaskPluginExecutionContext c { string agentHomeDir = context.Variables.GetValueOrDefault("agent.homedirectory")?.Value; ArgUtil.NotNullOrEmpty(agentHomeDir, nameof(agentHomeDir)); - gitPath = Path.Combine(agentHomeDir, "externals", "git", "cmd", $"git.exe"); + + if (AgentKnobs.FixPossibleGitOutOfMemoryProblem.GetValue(context).AsBoolean()) + { + gitPath = Path.Combine(agentHomeDir, "externals", "ff_git", "cmd", $"git.exe"); + } + else + { + gitPath = Path.Combine(agentHomeDir, "externals", "git", "cmd", $"git.exe"); + } + gitLfsPath = Path.Combine(agentHomeDir, "externals", "git", PlatformUtil.BuiltOnX86 ? "mingw32" : "mingw64", "bin", "git-lfs.exe"); // Prepend the PATH. diff --git a/src/Agent.Plugins/GitSourceProvider.cs b/src/Agent.Plugins/GitSourceProvider.cs index 6af5fd4804..38a2750c6c 100644 --- a/src/Agent.Plugins/GitSourceProvider.cs +++ b/src/Agent.Plugins/GitSourceProvider.cs @@ -684,6 +684,17 @@ public async Task GetSourceAsync( executionContext.Warning("Unable turn off git auto garbage collection, git fetch operation may trigger auto garbage collection which will affect the performance of fetching."); } + if (AgentKnobs.FixPossibleGitOutOfMemoryProblem.GetValue(executionContext).AsBoolean()) + { + await gitCommandManager.GitConfig(executionContext, targetPath, "pack.threads", "1"); + await gitCommandManager.GitConfig(executionContext, targetPath, "http.postBuffer", "524288000"); + await gitCommandManager.GitConfig(executionContext, targetPath, "core.packedgitwindowsize", "256m"); + await gitCommandManager.GitConfig(executionContext, targetPath, "core.packedgitlimit", "256m"); + await gitCommandManager.GitConfig(executionContext, targetPath, "pack.windowmemory", "256m"); + await gitCommandManager.GitConfig(executionContext, targetPath, "pack.deltaCacheSize", "256m"); + await gitCommandManager.GitConfig(executionContext, targetPath, "pack.packSizeLimit", "256m"); + } + // always remove any possible left extraheader setting from git config. if (await gitCommandManager.GitConfigExist(executionContext, targetPath, $"http.{repositoryUrl.AbsoluteUri}.extraheader")) { diff --git a/src/Agent.Sdk/Knob/AgentKnobs.cs b/src/Agent.Sdk/Knob/AgentKnobs.cs index 4114b88b31..dc4e8d7a43 100644 --- a/src/Agent.Sdk/Knob/AgentKnobs.cs +++ b/src/Agent.Sdk/Knob/AgentKnobs.cs @@ -121,6 +121,13 @@ public class AgentKnobs new EnvironmentKnobSource("AGENT_GIT_USE_SECURE_PARAMETER_PASSING"), new BuiltInDefaultKnobSource("true")); + public static readonly Knob FixPossibleGitOutOfMemoryProblem = new Knob( + nameof(FixPossibleGitOutOfMemoryProblem), + "When true, set config git properties to fix possible out of memory problem", + new RuntimeKnobSource("FIX_POSSIBLE_GIT_OUT_OF_MEMORY_PROBLEM"), + new EnvironmentKnobSource("FIX_POSSIBLE_GIT_OUT_OF_MEMORY_PROBLEM"), + new BuiltInDefaultKnobSource("false")); + public static readonly Knob TfVCUseSecureParameterPassing = new Knob( nameof(TfVCUseSecureParameterPassing), "If true, don't pass auth token in TFVC parameters", diff --git a/src/Misc/externals.sh b/src/Misc/externals.sh index 1b49a8cc78..81dd68f16f 100644 --- a/src/Misc/externals.sh +++ b/src/Misc/externals.sh @@ -19,6 +19,7 @@ NODE10_VERSION="10.24.1" NODE16_VERSION="16.20.2" NODE20_VERSION="20.3.1" MINGIT_VERSION="2.39.1" +FF_MINGIT_VERSION="2.42.0.2" LFS_VERSION="3.3.0" get_abs_path() { @@ -160,6 +161,7 @@ if [[ "$PACKAGERUNTIME" == "win-x"* ]]; then acquireExternalTool "$CONTAINER_URL/vstsom/m122_887c6659/vstsom.zip" vstsom fi + acquireExternalTool "$CONTAINER_URL/mingit/${FF_MINGIT_VERSION}/MinGit-${FF_MINGIT_VERSION}-${BIT}-bit.zip" ff_git acquireExternalTool "$CONTAINER_URL/mingit/${MINGIT_VERSION}/MinGit-${MINGIT_VERSION}-${BIT}-bit.zip" git acquireExternalTool "$CONTAINER_URL/git-lfs/${LFS_VERSION}/x${BIT}/git-lfs.exe" "git/mingw${BIT}/bin" acquireExternalTool "$CONTAINER_URL/pdbstr/1/pdbstr.zip" pdbstr