Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions src/AzurePipelines/PipelineCachingCacheClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading;
Expand Down Expand Up @@ -134,20 +135,28 @@ public PipelineCachingCacheClient(
},
SourceLevels.All);

VssBasicCredential token = AzDOHelpers.GetCredentials();
Uri artifacts = AzDOHelpers.GetServiceUriFromEnv("artifacts");

int connectionLimit = Environment.GetEnvironmentVariable("MSBUILDCACHE_PIPELINECACHING_SERVICEPOINT_CONNECTION_LIMIT") switch
{
string s when int.TryParse(s, out int i) => i,
_ => Math.Min(128, Environment.ProcessorCount * 4),
};
ServicePointManager.DefaultConnectionLimit = connectionLimit;


int timeoutSeconds = Environment.GetEnvironmentVariable("MSBUILDCACHE_PIPELINECACHING_HTTP_TIMEOUT") switch
{
string s when int.TryParse(s, out int i) => i,
_ => 10,
};

var settings = new VssHttpRequestSettings(AzDOHelpers.SessionGuid)
{
SendTimeout = TimeSpan.FromSeconds(timeoutSeconds),
};

VssBasicCredential token = AzDOHelpers.GetCredentials();
Uri artifacts = AzDOHelpers.GetServiceUriFromEnv("artifacts");

_cacheClient = new PipelineCacheHttpClient(artifacts, token, settings);

Uri blob = AzDOHelpers.GetServiceUriFromEnv("vsblob");
Expand Down Expand Up @@ -607,11 +616,11 @@ private async Task<byte[]> GetBytes(Context context, DedupIdentifier dedupId, Ca
{
using var ms = new MemoryStream();
return await WithHttpRetries(async () =>
{
ms.Position = 0;
await _manifestClient.DownloadToStreamAsync(dedupId, ms, proxyUri: null, cancellationToken);
return ms.ToArray();
},
{
ms.Position = 0;
await _manifestClient.DownloadToStreamAsync(dedupId, ms, proxyUri: null, cancellationToken);
return ms.ToArray();
},
context.ToString()!,
cancellationToken);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Common/Caching/CacheClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ public async Task<NodeBuildResult> AddNodeAsync(
return nodeBuildResult;
}

public async Task AddNodeInternalAsync(
private async Task AddNodeInternalAsync(
NodeContext nodeContext,
PathSet? pathSet,
NodeBuildResult nodeBuildResult,
Expand Down Expand Up @@ -360,7 +360,7 @@ await AddNodeAsync(
return result;
}

public async Task<(PathSet?, NodeBuildResult?)> GetNodeInternalAsync(
private async Task<(PathSet?, NodeBuildResult?)> GetNodeInternalAsync(
NodeContext nodeContext,
CancellationToken cancellationToken)
{
Expand Down