-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Change This change has several performance improvements based on profiling. ### Installed package caching A global process cache is stored for the unfiltered install data. It is very basic for updates right now to make it more reasonable to service, but future changes could improve things to examine the system data and only do delta updates. It could also be saved to disk to improve the performance of future processes. The cache itself is not used by any callers, but instead in-memory copies are handed out. The cache sets up event listeners for the current data sources and waits for these events before it will attempt to update again. A full cache hit requires only copying the memory database, which SQLite has an efficient method for. The only performance gain to the update path that is provided by this implementation is to reuse the names of MSIX packages, but since this accounts for a huge amount of creating the index it results in ~50% time reduction in creating an updated installed source (without any MSIX changes). ### ICU regex caching The regular expressions that we use were being compiled repeatedly. Since this is a fixed set of expressions, they are all now cached and copies are used for actual operation. ### Version lookup (string) The version lookup by string (such as `winget show FOO -v VER`) was doing a full table scan. This change shifts to pulling all of the version for the given identifier out and using `Version` object comparisons to find the proper result. This has the side effect of fixing a somewhat annoying user interaction where trailing 0s in a version were still required to find from the command line. One can now provide the smaller version string and still find the expected package version (eg `1.2` will now find version `1.2.0`). ### Version lookup (available version) The round trip from retrieving the available version information to getting the manifest has been improved by including the manifest id value directly in the available version data. The available version package object now caches the version string to manifest id data as well, meaning that any usage of a `PackageVersionKey` that was retrieved from `GetAvailableVersions` will directly return the package version object without querying the index. ### Let property lookups handle an unknown manifest id The `GetProperty` code was enforcing that the manifest id was valid and then reusing existing code that did not handle a missing manifest. Creating new methods that can handle the missing manifest allows us to remove the initial check.
- Loading branch information
Showing
43 changed files
with
1,006 additions
and
236 deletions.
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
Oops, something went wrong.