Skip to content
This repository was archived by the owner on Jul 30, 2024. It is now read-only.

Commit 8459db8

Browse files
authored
Speed up the revalidation job by the batch size (#675)
Currently, the job will increase its revalidation rate by 1 revalidation per hour each time it enqueues a batch of revalidations. As a result, the job speeds up very slowly. This change makes the job increase its revalidation rate by the batch size. Meaning, the revalidation job will increase its revalidation rate by 64 revalidations per hour if it enqueues 64 revalidations.
1 parent 5296038 commit 8459db8

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

src/NuGet.Services.Revalidate/Services/RevalidationJobStateService.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ await _state.MaybeUpdateStateAsync(state =>
104104
return false;
105105
}
106106

107-
var nextRate = Math.Min(_config.MaxPackageEventRate, state.DesiredPackageEventRate + 1);
107+
var nextRate = state.DesiredPackageEventRate + _config.Queue.MaxBatchSize;
108+
nextRate = Math.Min(_config.MaxPackageEventRate, nextRate);
108109

109110
_logger.LogInformation(
110111
"Increasing desired package event rate to {ToRate} from {FromRate}",

tests/NuGet.Services.Revalidate.Tests/Services/RevalidationJobStateServiceFacts.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ public async Task IncreasesDesiredPackageEventRateValue()
183183
await _target.IncreaseDesiredPackageEventRateAsync();
184184

185185
// Assert
186-
Assert.Equal(124, state.DesiredPackageEventRate);
186+
Assert.Equal(143, state.DesiredPackageEventRate);
187187
Assert.True(result);
188188

189189
_state.Verify(s => s.MaybeUpdateStateAsync(It.IsAny<Func<RevalidationState, bool>>()), Times.Once);
@@ -261,6 +261,11 @@ public FactsBase()
261261
{
262262
MinPackageEventRate = 100,
263263
MaxPackageEventRate = 500,
264+
265+
Queue = new RevalidationQueueConfiguration
266+
{
267+
MaxBatchSize = 20
268+
}
264269
};
265270

266271
_target = new RevalidationJobStateService(

0 commit comments

Comments
 (0)