Skip to content
This repository has been archived by the owner on Mar 16, 2021. It is now read-only.

Commit

Permalink
Add configurable parallelism for RegistrationComparer
Browse files Browse the repository at this point in the history
  • Loading branch information
joelverhagen committed Jan 24, 2020
1 parent 5aad4d0 commit 90872d3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/NuGet.Jobs.RegistrationComparer/HiveComparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NuGet.Protocol.Catalog;
Expand All @@ -22,15 +23,18 @@ public class HiveComparer
{
private readonly HttpClient _httpClient;
private readonly JsonComparer _comparer;
private readonly IOptionsSnapshot<RegistrationComparerConfiguration> _options;
private readonly ILogger<HiveComparer> _logger;

public HiveComparer(
HttpClient httpClient,
JsonComparer comparer,
IOptionsSnapshot<RegistrationComparerConfiguration> options,
ILogger<HiveComparer> logger)
{
_httpClient = httpClient ?? throw new ArgumentNullException(nameof(httpClient));
_comparer = comparer ?? throw new ArgumentNullException(nameof(comparer));
_options = options ?? throw new ArgumentNullException(nameof(options));
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
}

Expand Down Expand Up @@ -113,7 +117,8 @@ await ParallelAsync.Repeat(
var json = await GetJObjectOrNullAsync(pageUrl);
urlToJson.TryAdd(pageUrl, json.Data);
}
});
},
_options.Value.MaxConcurrentPageAndLeafDownloadsPerId);

// Compare the pages.
for (var i = 1; i < baseUrls.Count; i++)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ await ParallelAsync
await work();
}
},
degreeOfParallelism: 32);
degreeOfParallelism: _options.Value.MaxConcurrentComparisons);

if (failures > 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public class RegistrationComparerConfiguration : ICommitCollectorConfiguration
public List<HivesConfiguration> Registrations { get; set; }
public string Source { get; set; }
public int MaxConcurrentCatalogLeafDownloads { get; set; } = 64;
public int MaxConcurrentComparisons { get; set; } = 32;
public int MaxConcurrentPageAndLeafDownloadsPerId { get; set; } = 32;
public TimeSpan HttpClientTimeout { get; set; } = TimeSpan.FromMinutes(10);
}
}

0 comments on commit 90872d3

Please sign in to comment.