-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Performance improvements #3808
Merged
Merged
Performance improvements #3808
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
b196b21
Most basic caching, initial tests show ~50% time improvement
JohnMcPMS f2f7dd1
Minor changes and test validation
JohnMcPMS 2957a5e
Expand test to work on server
JohnMcPMS 50122ca
Force a cache update after we install something to override the 1 sec…
JohnMcPMS b91aad1
Spelling
JohnMcPMS ac1c153
Expand tests, fix threading issues
JohnMcPMS 020399b
Spelling
JohnMcPMS af2b066
Change to event driven update determination and add more tests
JohnMcPMS 409d7c8
Make test use different root and maybe fix pipeline pdb publishing
JohnMcPMS 1c1e50a
Add regex caching
JohnMcPMS 5d630f8
Merge from master
JohnMcPMS 331645d
Make single regex static and improve version lookup efficiency
JohnMcPMS 7b6fea8
Optimize version lookups
JohnMcPMS 9789305
Let internal property lookups handle missing manifest
JohnMcPMS d2bb559
Make version comparison case insensitive to match with index
JohnMcPMS aef1eb4
Bring back a forced cache update after an install to reduce timing im…
JohnMcPMS 506f8b3
Skip test to see if it is localized
JohnMcPMS eb2834d
Try disabling optimization for better crash debugging
JohnMcPMS 1863a5f
Restore optimization and disable test for now
JohnMcPMS d26ef84
PR feedback
JohnMcPMS 20c8e88
Spelling and pipeline
JohnMcPMS File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -131,6 +131,7 @@ ENDSESSION | |
EPester | ||
epth | ||
EQU | ||
errcode | ||
errmsg | ||
ERRORONEXIT | ||
ESource | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
#include "pch.h" | ||
#include "TestCommon.h" | ||
#include "TestHooks.h" | ||
#include "Microsoft/ARPHelper.h" | ||
#include "AppInstallerStrings.h" | ||
|
||
using namespace AppInstaller::Manifest; | ||
using namespace AppInstaller::Repository::Microsoft; | ||
using namespace AppInstaller::Utility; | ||
using namespace AppInstaller::Registry; | ||
|
||
|
||
TEST_CASE("ARPHelper_Watcher", "[ARPHelper]") | ||
{ | ||
ARPHelper helper; | ||
|
||
wil::unique_event callbackEvent; | ||
callbackEvent.create(); | ||
|
||
ScopeEnum scopeCallback = ScopeEnum::Unknown; | ||
Architecture architectureCallback = Architecture::Unknown; | ||
|
||
ScopeEnum scopeTarget = ScopeEnum::Machine; | ||
Architecture architectureTarget = Architecture::X86; | ||
|
||
auto fakeRoot = TestCommon::RegCreateVolatileTestRoot(); | ||
TestHook::SetGetARPKey_Override arpOverride([&](ScopeEnum scope, Architecture arch) | ||
{ | ||
if (scope == scopeTarget && arch == architectureTarget) | ||
{ | ||
return Key(fakeRoot.get(), L""); | ||
} | ||
else | ||
{ | ||
return Key{}; | ||
} | ||
}); | ||
|
||
auto watchers = helper.CreateRegistryWatchers(scopeTarget, [&](ScopeEnum scope, Architecture arch, wil::RegistryChangeKind) | ||
{ | ||
scopeCallback = scope; | ||
architectureCallback = arch; | ||
callbackEvent.SetEvent(); | ||
}); | ||
|
||
auto arpKey = helper.GetARPKey(scopeTarget, architectureTarget); | ||
REQUIRE(!!arpKey); | ||
|
||
GUID guid; | ||
std::ignore = CoCreateGuid(&guid); | ||
std::ostringstream stream; | ||
stream << guid; | ||
|
||
auto testKey = TestCommon::RegCreateVolatileSubKey(arpKey, ConvertToUTF16(stream.str())); | ||
|
||
REQUIRE(callbackEvent.wait(1000)); | ||
REQUIRE(scopeTarget == scopeCallback); | ||
REQUIRE(architectureTarget == architectureCallback); | ||
|
||
// Reset for changing a value | ||
scopeCallback = ScopeEnum::Unknown; | ||
architectureCallback = Architecture::Unknown; | ||
|
||
TestCommon::SetRegistryValue(testKey.get(), L"testValue", L"valueValue"); | ||
|
||
REQUIRE(callbackEvent.wait(1000)); | ||
REQUIRE(scopeTarget == scopeCallback); | ||
REQUIRE(architectureTarget == architectureCallback); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
#include <AppInstallerStrings.h> | ||
#include <Microsoft/PredefinedInstalledSourceFactory.h> | ||
#include <Microsoft/ARPHelper.h> | ||
#include <Microsoft/SQLiteIndexSource.h> | ||
|
||
using namespace std::string_literals; | ||
using namespace std::string_view_literals; | ||
|
@@ -18,6 +19,7 @@ using namespace AppInstaller::Runtime; | |
using namespace AppInstaller::Utility; | ||
|
||
using SQLiteIndex = AppInstaller::Repository::Microsoft::SQLiteIndex; | ||
using SQLiteIndexSource = AppInstaller::Repository::Microsoft::SQLiteIndexSource; | ||
using Factory = AppInstaller::Repository::Microsoft::PredefinedInstalledSourceFactory; | ||
using ARPHelper = AppInstaller::Repository::Microsoft::ARPHelper; | ||
|
||
|
@@ -400,3 +402,82 @@ TEST_CASE("PredefinedInstalledSource_Search", "[installed][list]") | |
|
||
REQUIRE_FALSE(results.Matches.empty()); | ||
} | ||
|
||
std::string GetDatabaseIdentifier(const std::shared_ptr<Repository::ISource>& source) | ||
{ | ||
return reinterpret_cast<SQLiteIndexSource*>(source->CastTo(ISourceType::SQLiteIndexSource))->GetIndex().GetDatabaseIdentifier(); | ||
} | ||
|
||
void RequirePackagesHaveSameNames(std::shared_ptr<ISource>& source1, std::shared_ptr<ISource>& source2) | ||
{ | ||
auto result1 = source1->Search({}); | ||
REQUIRE(!result1.Matches.empty()); | ||
|
||
// Ensure that all packages have the same name values | ||
for (const auto& match : result1.Matches) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could/should we check that there are no packages in result2 that aren't in result1? |
||
{ | ||
std::string packageId = match.Package->GetProperty(PackageProperty::Id).get(); | ||
INFO(packageId); | ||
|
||
SearchRequest id2; | ||
id2.Inclusions.emplace_back(PackageMatchFilter{ PackageMatchField::Id, MatchType::CaseInsensitive, packageId }); | ||
auto result2 = source2->Search(id2); | ||
REQUIRE(result2.Matches.size() == 1); | ||
REQUIRE(match.Package->GetProperty(PackageProperty::Name) == result2.Matches[0].Package->GetProperty(PackageProperty::Name)); | ||
} | ||
} | ||
|
||
TEST_CASE("PredefinedInstalledSource_Create_Cached", "[installed][list][installed-cache]") | ||
{ | ||
auto source1 = CreatePredefinedInstalledSource(); | ||
auto source2 = CreatePredefinedInstalledSource(); | ||
|
||
// Ensure the same identifier (which should mean the cache was not updated) | ||
REQUIRE( | ||
GetDatabaseIdentifier(source1) | ||
== | ||
GetDatabaseIdentifier(source2) | ||
); | ||
|
||
RequirePackagesHaveSameNames(source1, source2); | ||
RequirePackagesHaveSameNames(source2, source1); | ||
} | ||
|
||
TEST_CASE("PredefinedInstalledSource_Create_ForceCacheUpdate", "[installed][list][installed-cache]") | ||
{ | ||
auto source1 = CreatePredefinedInstalledSource(); | ||
auto source2 = CreatePredefinedInstalledSource(Factory::Filter::NoneWithForcedCacheUpdate); | ||
|
||
// Ensure different identifier (which should mean the cache was updated) | ||
REQUIRE( | ||
GetDatabaseIdentifier(source1) | ||
!= | ||
GetDatabaseIdentifier(source2) | ||
); | ||
|
||
RequirePackagesHaveSameNames(source1, source2); | ||
RequirePackagesHaveSameNames(source2, source1); | ||
} | ||
|
||
TEST_CASE("PredefinedInstalledSource_Create_ForceCacheUpdate_StillCached", "[installed][list][installed-cache]") | ||
{ | ||
auto source1 = CreatePredefinedInstalledSource(); | ||
auto source2 = CreatePredefinedInstalledSource(Factory::Filter::NoneWithForcedCacheUpdate); | ||
auto source3 = CreatePredefinedInstalledSource(); | ||
|
||
CAPTURE(GetDatabaseIdentifier(source1), GetDatabaseIdentifier(source2), GetDatabaseIdentifier(source3)); | ||
|
||
// Ensure different identifier (which should mean the cache was updated) | ||
REQUIRE( | ||
GetDatabaseIdentifier(source1) | ||
!= | ||
GetDatabaseIdentifier(source2) | ||
); | ||
|
||
// Ensure the same identifier (which should mean the cache was not updated) | ||
REQUIRE( | ||
GetDatabaseIdentifier(source2) | ||
== | ||
GetDatabaseIdentifier(source3) | ||
); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Could you add a comment about what this is loop is doing?