-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
[PT Run] Improve the Win32 Program Indexing speed #11364
[PT Run] Improve the Win32 Program Indexing speed #11364
Conversation
@royvou |
fd82b4c
to
d52e3c9
Compare
@royvou |
I need to verify the filewatcher/update deduplicate logic as the unit tests are failing. Main logic/changes are completed though! |
d52e3c9
to
2fe0b11
Compare
src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/Win32Program.cs
Outdated
Show resolved
Hide resolved
src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/Win32Program.cs
Outdated
Show resolved
Hide resolved
src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/Win32Program.cs
Outdated
Show resolved
Hide resolved
src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/Win32Program.cs
Outdated
Show resolved
Hide resolved
@enricogior |
src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/Win32Program.cs
Outdated
Show resolved
Hide resolved
src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/Win32Program.cs
Show resolved
Hide resolved
src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/Win32Program.cs
Show resolved
Hide resolved
Measured improvement. Debug build. The branch: Master: |
@@ -17,6 +17,31 @@ namespace Microsoft.Plugin.Program.Logger | |||
/// </summary> | |||
internal static class ProgramLogger | |||
{ | |||
/// <summary> |
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.
Added Warn Method which could be used for non-fatal index related issues (e.g. Not found / not accessible / not parse able)
@@ -118,6 +104,20 @@ public void Init(PluginInitContext context) | |||
_context.API.ThemeChanged += OnThemeChanged; | |||
|
|||
UpdateUWPIconPath(_context.API.GetCurrentTheme()); | |||
|
|||
var a = Task.Run(() => |
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.
Moved from Constructor to Initialize method so it won't run if you disable the program plugin
@check-spelling-bot ReportUnrecognized words, please review:
Previously acknowledged words that are now absentapos autoupdate bc bh Chris's classmethod cls CMDARG cn cx cz deque df dw EB ev fd fody fx getmembers gh hc hh hk hu ip ismethod jp Kf lambson laute loadingbar messagebox multithreading nonwin NX overlaywindow pb Pn pv pw px QI rpc ru rv rx sz tadele td tt tw Tz ul uv vh vk vm vw Vx watsonportal wostringstream xa XY yy Zc zh zipfolder zmTo accept these unrecognized words as correct (and remove the previously acknowledged and now absent words), run the following commands... in a clone of the [email protected]:royvou/PowerToys.git repository
If you see a bunch of garbageIf it relates to a ... well-formed patternSee if there's a pattern that would match it. If not, try writing one and adding it to the Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines. Note that patterns can't match multiline strings. binary-ish stringPlease add a file path to the File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.
|
@@ -28,6 +27,8 @@ namespace Microsoft.Plugin.Program.Programs | |||
[Serializable] | |||
public class Win32Program : IProgram | |||
{ | |||
public static readonly Win32Program InvalidProgram = new Win32Program { Valid = false, Enabled = false }; |
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.
Single Instance Method (which can be reused to reduce allocations)
@@ -53,7 +54,7 @@ public class Win32Program : IProgram | |||
|
|||
public bool Enabled { get; set; } | |||
|
|||
public bool HasArguments { get; set; } | |||
public bool HasArguments => !string.IsNullOrEmpty(Arguments); |
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.
This parameter can easily be forgotten, this will calculate the HasArgument at runtime
@@ -104,10 +105,12 @@ public bool IsWebApplication() | |||
{ | |||
// To Filter PWAs when the user searches for the main application | |||
// All Chromium based applications contain the --app-id argument | |||
// Reference : https://codereview.chromium.org/399045/show | |||
// Reference : https://codereview.chromium.org/399045 |
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.
The old link was throwing a 404 :(
@@ -119,9 +122,6 @@ public bool FilterWebApplication(string query) | |||
return false; | |||
} | |||
|
|||
// Set the subtitle to 'Web Application' |
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.
Moved this check inside the LnkProgram
@@ -403,65 +395,62 @@ private static Win32Program InternetShortcutProgram(string path) | |||
{ | |||
urlPath = line.Substring(urlPrefix.Length); | |||
|
|||
try | |||
if (!Uri.TryCreate(urlPath, UriKind.RelativeOrAbsolute, out Uri _)) |
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.
Use "Safe" TryParse (which does not throw an exception, but we log the warning anyway for debugging purpose
} | ||
} | ||
|
||
private static readonly Regex InternetShortcutURLPrefixes = new Regex(@"^steam:\/\/(rungameid|run)\/|^com\.epicgames\.launcher:\/\/apps\/", RegexOptions.Compiled); |
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.
Regex can be cached/reused
{ | ||
Name = Path.GetFileNameWithoutExtension(path), | ||
ExecutableName = Path.GetFileName(path), | ||
IcoPath = iconPath, | ||
FullPath = urlPath, | ||
FullPath = urlPath.ToLowerInvariant(), |
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.
All Other Win32Programs use LowerInvariant
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.
Can we change it ToUpperInvariant as it is recommended?
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.
Since its shown to the user (and all other types also use the lowercase variant) I don't think we should!
Ah sorry @htcfreek ! (Yes i can search on those names in this PR) |
EN-UK, but this seems not to have changed over the current PT Run release, so let's continue that in the other issue :) |
Issue exists since while. :) |
@royvou / @mykhailopylyp what is missing to close this out |
…(from multiple sources) & Optimze Paralell indexing
- ProgramLogger.Warn allow Exception NULL - Add "CustomProgramPaths" back - Moved Enumeration/Distinct - ToList on each "ProgramSource" - Moved Enumeration/Distinct to All - Moved DisabledProgramList check to All - Changed ToArray to ToList in All to optimize allocations - Add InitialSize to HashSet to prevent HashSet resize
6855291
to
92012eb
Compare
@mykhailopylyp / @crutkas I'll revert the change that .lnks will always have the .exe name set to the name of the exe (e.g. WINWORD for word) and we should create a seperate issue for that how we want that to behave. Also added back the previous comparer. |
@check-spelling-bot ReportUnrecognized words, please review:
Previously acknowledged words that are now absentautoupdate CMDARG Dbg deque multithreading nonwin overlaywindow watsonportal wostringstream zipfolderTo accept these unrecognized words as correct (and remove the previously acknowledged and now absent words), run the following commands... in a clone of the [email protected]:royvou/PowerToys.git repository
If you see a bunch of garbageIf it relates to a ... well-formed patternSee if there's a pattern that would match it. If not, try writing one and adding it to the Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines. Note that patterns can't match multiline strings. binary-ish stringPlease add a file path to the File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.
|
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.
LGTM, Good job! Tested, works as expected
Summary of the Pull Request
What is this about:
Improve the performance of the Win32 scanning.
What is include in the PR:
Allow Searching by executable name (e.g. WINWORD.EXE) exluded as this changes behaviorHow does someone test / validate:
Quality Checklist
Contributor License Agreement (CLA)
A CLA must be signed. If not, go over here and sign the CLA.
Additional Information