Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Create JumpList in background thread to improve performance#6985

Merged
iSazonov merged 5 commits intoPowerShell:masterfrom
bergmeister:JumpListPerformanceOptimisation
Jun 5, 2018
Merged

Create JumpList in background thread to improve performance#6985
iSazonov merged 5 commits intoPowerShell:masterfrom
bergmeister:JumpListPerformanceOptimisation

Conversation

@bergmeister
Copy link
Contributor

@bergmeister bergmeister commented Jun 4, 2018

PR Summary

Background/Recap: PR #6913 added a JumpList on Windows only and already made sure that in case of pwsh being non-interactive or not being the owner of the current window, the algorithm aborts as early as possible (<1ms) but in cases when the JumpList needs to be created, the work in the ConsoleHost is done synchronously and takes around 55ms.

This PR enhances the last scenario by eliminating the blocking time completely by doing the work in a background thread without waiting for it and as suggested in the PR review, moving it to a later stage.
Some more info: Once the JumpList is being set the first time, it will persist (if the file path remains the same), therefore it is OK to move it to a later stage in general. As already discussed there is no 'GET' API to check whether the JumpList needs to be created or not. In theory, one could possibly even try to call it in a WiX custom action during the installation but even if that worked, I am questioning its persistence e.g. during one of the bi-annual Windows updates (personally, I have seen e.g. that registry keys, etc. do not get persisted). Therefore I think this optimisation makes it polished enough to not worry about those few extra CPU cycles, especially since Windows deployments nowadays usually have multi-core CPUs as well.

PR Checklist

… when pwsh owns the window (i.e. when the Jumplist has to be created)

#if !UNIX
Microsoft.PowerShell.TaskbarJumpList.CreateElevatedEntry(ConsoleHostStrings.RunAsAdministrator);
Task.Run(() => TaskbarJumpList.CreateElevatedEntry(ConsoleHostStrings.RunAsAdministrator));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe move this in line 217? Code before the line do return and fast exit..

@iSazonov iSazonov self-assigned this Jun 4, 2018
…ight make it exit earlier as suggested in PR review by @iSazonov
Copy link

@anmenaga anmenaga left a comment

Choose a reason for hiding this comment

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

I would recommend adding a comment before this code line - a brief version of what is written in "PR Summary": about saving 55ms, about dependency of a jump list on file path and about absence of 'Get' API...

@iSazonov
Copy link
Collaborator

iSazonov commented Jun 5, 2018

@bergmeister Please address @anmenaga comment and we'll be ready to merge.

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.

4 participants