Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Remove AllScope from most default aliases #5268
Conversation
lzybkr
assigned
daxian-dbw
Oct 29, 2017
lzybkr
requested review from
daxian-dbw,
vors,
BrucePay and
SteveL-MSFT
Oct 29, 2017
|
Does it make sense to leave these aliases readonly? I think we talked about this earlier. We could use |
|
That's 2 questions. I don't feel strongly about using As for using the |
|
If we remove ReadOnly here we can safely move to After PR 3595 I tried to enhance Alias attribute in the my branch. I couldn't implement AllScope and froze the work. But ReadOnly works. If we don't remove ReadOnly here after deletion of so much AllScope, maybe it makes sense to finish the work for ReadOnly here or I can push new PR later if you approve. |
|
If we remove AllScope from all the aliases, what perf impact would it be to the commonly used ones? Also, it seems like we should have an internal overload of SessionStateAliasEntry constructor rather than passing empty string everytime for the description. |
| // Native commands we keep because the functions act correctly on Linux | ||
| - new SessionStateAliasEntry("clear", | ||
| - "Clear-Host", "", ScopedItemOptions.AllScope), | ||
| + new SessionStateAliasEntry("clear", "Clear-Host"), | ||
| //#if !CORECLR is used to disable aliases for cmdlets which are not available on OneCore | ||
| #if !CORECLR |
lzybkr
Oct 30, 2017
Member
I considered that - but maybe a couple still make sense - ise e.g. - and would Out-Printer come back?
| + new SessionStateAliasEntry("rjb", "Remove-Job"), | ||
| + new SessionStateAliasEntry("sajb", "Start-Job"), | ||
| + new SessionStateAliasEntry("spjb", "Stop-Job"), | ||
| + new SessionStateAliasEntry("wjb", "Wait-Job"), | ||
| #if !CORECLR |
|
I considered adding the overload, but if we're fine with removing |
|
As for perf impact on the common commands - it depends a lot, but command lookup isn't exactly cheap - there is a 25% difference in perf between in the two examples below - in the first, command lookup happens just once, in the second, it happens on every invocation. function foo {}
measure-command { & {
$c = Get-Command foo
for ($i = 0; $i -lt 100kb; $i++) { & $c }
} }
measure-command { & {
for ($i = 0; $i -lt 100kb; $i++) {foo }
} } |


lzybkr commentedOct 29, 2017
To speed up scope creation, I removed AllScope from most default aliases.
This results in a 15-20% speedup for:
I left AllScope of a few frequently used aliases because it does make command lookup faster. If we introduce something like dynamic sites for command lookup, then we could probably remove the rest
of the AllScope aliases.
This is a low risk breaking change. One can ask for aliases at a particular scope:
This could now fail if the scope number doesn't correspond to global scope.