Skip to content
This repository has been archived by the owner on Jul 30, 2024. It is now read-only.
/ NuGet.Jobs Public archive

[Revalidation] Improve throughput by batching revalidations #667

Merged
merged 4 commits into from
Nov 15, 2018

Conversation

loic-sharma
Copy link
Contributor

@loic-sharma loic-sharma commented Nov 10, 2018

Increase the throughput of the revalidation job by batching revalidations. The revalidation job does a bunch of work before enqueueing revalidations as it must:

  1. Ensure the revalidation job hasn't been killswitched
  2. Verify that the ingestion pipeline is healthy
  3. Verify that the desired package event rate hasn't been reached

This change amortizes that work by enqueueing revalidations in batches. Also, the job now takes into account how long it spent enqueueing revalidations when deciding how long to sleep for.

Addresses https://github.com/NuGet/Engineering/issues/1877

// Split the list of revalidations by which ones have been completed.
var completed = new List<PackageRevalidation>();
var uncompleted = revalidations.ToDictionary(
r => Tuple.Create(r.PackageId, r.PackageNormalizedVersion),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create [](start = 27, length = 6)

Can we use PackageIdentity or an anonymous type instead?

Copy link
Contributor Author

@loic-sharma loic-sharma Nov 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I replaced the tuple with a string. This was necessary for the Entity Framework queries to work.

@joelverhagen
Copy link
Member

What are the measurements for this performance improvement?

Copy link
Member

@joelverhagen joelverhagen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🕐

Update tests and config

Improving logging

Undo hack :'(

Update connection strings
/// </summary>
public int? MaximumPackageVersions { get; set; }
public int MaxBatchSize { get; set; } = 64;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 64? I think every limit we've used so far has been a multiple of 100.

Copy link
Contributor Author

@loic-sharma loic-sharma Nov 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

64 was chosen rather arbitrarily as this is the largest number that fits in a single catalog commit. This number directly correlates into how big queries into the Gallery DB are, so I think we should avoid any thing too big.

Side-note: at 64 revalidations per batch, each batch on DEV spend ~30 seconds deciding whether to enqueue the batch, and ~3 seconds actually enqueueing the batch.

@loic-sharma
Copy link
Contributor Author

@joelverhagen I configured the job to do 1500 revalidations per hour on DEV, and it was able to maintain ~1470 revalidations per hour for nine hours. Previously, the highest rate I was able to reach with the job was ~1300 revalidations per hour, and to reach that rate I had to configure the job to do 2000 revalidations per hour.

@loic-sharma loic-sharma merged commit 297a5cf into dev Nov 15, 2018
@loic-sharma loic-sharma deleted the loshar-speed branch November 15, 2018 21:32
joelverhagen pushed a commit that referenced this pull request Oct 26, 2020
Increase the throughput of the revalidation job by batching revalidations. The revalidation job does a bunch of work before enqueueing revalidations as it must:

1. Ensure the revalidation job hasn't been killswitched
2. Verify that the ingestion pipeline is healthy
3. Verify that the desired package event rate hasn't been reached

This change amortizes that work by enqueueing revalidations in batches. Also, the job now takes into account how long it spent enqueueing revalidations when deciding how long to sleep for.

Addresses https://github.com/NuGet/Engineering/issues/1877
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants