Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Utilize vulnerabilities caching service for in manage packages page #8620

Merged
merged 2 commits into from
Jun 16, 2021

Conversation

drewgillies
Copy link
Contributor

@drewgillies drewgillies commented Jun 7, 2021

Addresses #8361, with a far more performant approach (no direct database queries) than #8435 which we've left behind a disabled feature flag for this reason. This change utilizes the cache set up here: #8580.

@drewgillies drewgillies requested a review from a team as a code owner June 7, 2021 01:19
@drewgillies drewgillies force-pushed the dg-managepackagespage-usesvulncache branch 2 times, most recently from fb57d56 to bab06bd Compare June 7, 2021 01:45
@drewgillies drewgillies force-pushed the dg-managepackagespage-usesvulncache branch from bab06bd to 37865bb Compare June 7, 2021 04:53
@drewgillies drewgillies changed the base branch from main to dev June 7, 2021 07:13
@skofman1
Copy link
Contributor

skofman1 commented Jun 8, 2021

How is perf looking?

@drewgillies
Copy link
Contributor Author

drewgillies commented Jun 8, 2021

How is perf looking?

@skofman1 I'd like to see it in INT before evaluating, but this change introduces no new queries, simply a dictionary lookup. Perf on the caching itself (a different change for Package Details) is looking fine in INT, with no discernable regression in the INT Package Details page as it has many queries already and is not under high load.

@drewgillies
Copy link
Contributor Author

@skofman1 I've done some preliminary perf investigations (comparing enabling/disabling the feature) in DEV and:

  • for a large list (359 listed packages), I see a consistent regression of ~450ms, averaging over multiple attempts
  • for a small list (5 packages), I actually saw small perf improvement of 35ms, which is unlikely to be related--so, a negligible perf difference.

This is different from the previous approach (direct SQL queries) where a consistent perf regression of ~1000ms applied to manage packages packages regardless of package list size.

[Fact]
public void GetsVulnerableStatusOfPackage()
{
// Arrange
Setup();
var entitiesContext = new Mock<IEntitiesContext>();
Copy link
Contributor

@zhhyu zhhyu Jun 9, 2021

Choose a reason for hiding this comment

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

For discussions: I am not very sure whether we need to set up and mock so many dependencies here. I can see that "PackageVulnerabilitiesService" only has one dependency: "IPackageVulnerabilitiesCacheService". Will it work if we just mock the method "_packageVulnerabilitiesCacheService.GetVulnerabilitiesById(id)"? This will help us keep the unit test efficient and clean with the minimal scope.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call, Zhaohua--that simplifies the tests. I've included this change now.

@drewgillies drewgillies force-pushed the dg-managepackagespage-usesvulncache branch from 83cfe00 to 0d080c6 Compare June 11, 2021 04:12
@drewgillies drewgillies requested a review from zhhyu June 11, 2021 04:13
{
Key = 0,
PackageRegistration = registrationVulnerable,
Version = "1.0.0",
VulnerablePackageRanges = new List<VulnerablePackageVersionRange> {versionRangeModerate}
VulnerablePackageRanges = new List<VulnerablePackageVersionRange> { versionRangeModerate }
};
Copy link
Contributor

@zhhyu zhhyu Jun 15, 2021

Choose a reason for hiding this comment

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

It will be better if we have a test to cover the following case:
The package registration Id matches, but the package key can't be found in the dictionary returned by "GetVulnerabilitiesById".

@zhhyu
Copy link
Contributor

zhhyu commented Jun 15, 2021

Nice work! 👍

@drewgillies drewgillies merged commit 3223185 into dev Jun 16, 2021
@drewgillies drewgillies deleted the dg-managepackagespage-usesvulncache branch June 16, 2021 01:01
@dannyjdev dannyjdev mentioned this pull request Jun 29, 2021
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants