Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions assets/files.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,6 @@
<Component Id="cmp7F0E91316B501D5C0C5FDC147C91981E" Guid="{E3D382A4-8DC4-4BD1-816B-9ADB12A83412}">
<File Id="filB2058AD00ED3F7C051D3F6A4705F37C6" KeyPath="yes" Source="$(env.ProductSourcePath)\System.IO.FileSystem.DriveInfo.dll" />
</Component>
<Component Id="cmp03B6932DD9DCA3B838936482F6C72DF5" Guid="{4D708BC6-412F-482A-867C-4D2EF354900E}">
<File Id="fil3FC478E85DC9718A496BC8FA9D2AFE3E" KeyPath="yes" Source="$(env.ProductSourcePath)\pwsh.pdb" />
</Component>
<Component Id="cmp49EA2B6077C3CFE16C87CE6C69B211FB" Guid="{04C22CA0-2365-4E40-9B4B-6B42AA205BCD}">
<File Id="filDB9405064AEB93B55BA7A5608BBBFA97" KeyPath="yes" Source="$(env.ProductSourcePath)\Install-PowerShellRemoting.ps1" />
</Component>
Expand Down Expand Up @@ -2456,7 +2453,6 @@
<ComponentRef Id="cmp9568B438265B4B9537FB278425E51F9D" />
<ComponentRef Id="cmp96F5D79C2A39A3FCE2832C9F0DA1FFB9" />
<ComponentRef Id="cmp7F0E91316B501D5C0C5FDC147C91981E" />
<ComponentRef Id="cmp03B6932DD9DCA3B838936482F6C72DF5" />
<ComponentRef Id="cmp49EA2B6077C3CFE16C87CE6C69B211FB" />
<ComponentRef Id="cmpFD2810C7EB4AE4047C456491CE5AABA5" />
<ComponentRef Id="cmpCB73A07CE8A738AA1591F9E7C13B0DC6" />
Expand Down
1 change: 1 addition & 0 deletions build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -2154,6 +2154,7 @@ function Start-CrossGen {

# Common PowerShell libraries to crossgen
$psCoreAssemblyList = @(
"pwsh.dll",
"Microsoft.PowerShell.Commands.Utility.dll",
"Microsoft.PowerShell.Commands.Management.dll",
"Microsoft.PowerShell.Security.dll",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -498,21 +498,6 @@ private static bool TryParseSettingFileHelper(string[] args, int settingFileArgI
return true;
}

/// <summary>
/// Processes the command line parameters to ConsoleHost which must be parsed before the Host is created.
/// Success to indicate that the program should continue running.
/// </summary>
/// <param name="args">
/// The command line parameters to be processed.
/// </param>
internal static void EarlyParse(string[] args)
{
// indicates that we've called this method on this instance, and that when it's done, the state variables
// will reflect the parse.

EarlyParseHelper(args);
}

private static string GetConfigurationNameFromGroupPolicy()
{
// Current user policy takes precedence.
Expand All @@ -529,7 +514,7 @@ private static string GetConfigurationNameFromGroupPolicy()
/// <param name="args">
/// The command line parameters to be processed.
/// </param>
private static void EarlyParseHelper(string[] args)
internal static void EarlyParse(string[] args)
{
if (args == null)
{
Expand Down
24 changes: 13 additions & 11 deletions src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using System.Management.Automation.Remoting;
using System.Management.Automation.Security;
using System.Threading;
using System.Runtime;
using System.Runtime.InteropServices;
using System.Management.Automation.Language;

Expand Down Expand Up @@ -133,7 +134,7 @@ internal static int Start(
Directory.CreateDirectory(profileDir);
}
#endif
ClrFacade.SetProfileOptimizationRoot(profileDir);
ProfileOptimization.SetProfileRoot(profileDir);
}
catch
{
Expand All @@ -143,7 +144,7 @@ internal static int Start(

uint exitCode = ExitCodeSuccess;

System.Threading.Thread.CurrentThread.Name = "ConsoleHost main thread";
Thread.CurrentThread.Name = "ConsoleHost main thread";

try
{
Expand Down Expand Up @@ -205,26 +206,26 @@ internal static int Start(
// First check for and handle PowerShell running in a server mode.
if (s_cpp.ServerMode)
{
ClrFacade.StartProfileOptimization("StartupProfileData-ServerMode");
ProfileOptimization.StartProfile("StartupProfileData-ServerMode");
System.Management.Automation.Remoting.Server.OutOfProcessMediator.Run(s_cpp.InitialCommand);
exitCode = 0;
}
else if (s_cpp.NamedPipeServerMode)
{
ClrFacade.StartProfileOptimization("StartupProfileData-NamedPipeServerMode");
ProfileOptimization.StartProfile("StartupProfileData-NamedPipeServerMode");
System.Management.Automation.Remoting.RemoteSessionNamedPipeServer.RunServerMode(
s_cpp.ConfigurationName);
exitCode = 0;
}
else if (s_cpp.SSHServerMode)
{
ClrFacade.StartProfileOptimization("StartupProfileData-SSHServerMode");
ProfileOptimization.StartProfile("StartupProfileData-SSHServerMode");
System.Management.Automation.Remoting.Server.SSHProcessMediator.Run(s_cpp.InitialCommand);
exitCode = 0;
}
else if (s_cpp.SocketServerMode)
{
ClrFacade.StartProfileOptimization("StartupProfileData-SocketServerMode");
ProfileOptimization.StartProfile("StartupProfileData-SocketServerMode");
System.Management.Automation.Remoting.Server.HyperVSocketMediator.Run(s_cpp.InitialCommand,
s_cpp.ConfigurationName);
exitCode = 0;
Expand All @@ -238,16 +239,17 @@ internal static int Start(
throw hostException;
}

ProfileOptimization.StartProfile(
s_theConsoleHost.LoadPSReadline()
? "StartupProfileData-Interactive"
: "StartupProfileData-NonInteractive");

s_theConsoleHost.BindBreakHandler();
PSHost.IsStdOutputRedirected = Console.IsOutputRedirected;

// Send startup telemetry for ConsoleHost startup
ApplicationInsightsTelemetry.SendPSCoreStartupTelemetry();

ClrFacade.StartProfileOptimization(
s_theConsoleHost.LoadPSReadline()
? "StartupProfileData-Interactive"
: "StartupProfileData-NonInteractive");
exitCode = s_theConsoleHost.Run(s_cpp, false);
}
}
Expand Down Expand Up @@ -2833,7 +2835,7 @@ private class ConsoleHostStartupException : Exception
private ConsoleControl.ConsoleModes _savedConsoleMode = ConsoleControl.ConsoleModes.Unknown;
private ConsoleControl.ConsoleModes _initialConsoleMode = ConsoleControl.ConsoleModes.Unknown;
#endif
private System.Threading.Thread _breakHandlerThread;
private Thread _breakHandlerThread;
private bool _isDisposed;
internal ConsoleHostUserInterface ui;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ public sealed class UnmanagedPSEntry
/// <param name="args">
/// Command line arguments to the managed MSH
/// </param>
#pragma warning disable 1573
/// <param name="argc" />
public static int Start(string consoleFilePath, [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr, SizeParamIndex = 2)]string[] args, int argc)
#pragma warning restore 1573
{
// Warm up some components concurrently on background threads.
System.Management.Automation.Runspaces.EarlyStartup.Init();

// We need to read the settings file before we create the console host
Microsoft.PowerShell.CommandLineParameterParser.EarlyParse(args);
System.Management.Automation.Runspaces.EarlyStartup.Init();

#if !UNIX
// NOTE: On Unix, logging has to be deferred until after command-line parsing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,22 +194,6 @@ internal IEnumerable<Assembly> GetAssembly(string namespaceQualifiedTypeName)
return null;
}

/// <summary>
/// Set the profile optimization root on the appropriate load context.
/// </summary>
internal void SetProfileOptimizationRootImpl(string directoryPath)
{
AssemblyLoadContext.Default.SetProfileOptimizationRoot(directoryPath);
}

/// <summary>
/// Start the profile optimization on the appropriate load context.
/// </summary>
internal void StartProfileOptimizationImpl(string profile)
{
AssemblyLoadContext.Default.StartProfileOptimization(profile);
}

#endregion Internal_Methods

#region Private_Methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ internal static void Init()
{
// Loading the resources for System.Management.Automation can be expensive, so force that to
// happen early on a background thread.
var unused0 = RunspaceInit.OutputEncodingDescription;
_ = RunspaceInit.OutputEncodingDescription;

// This will init some tables and could load some assemblies.
var unused1 = TypeAccelerators.builtinTypeAccelerators;
_ = TypeAccelerators.builtinTypeAccelerators;

// This will init some tables and could load some assemblies.
var unused2 = LanguagePrimitives.GetEnumerator(null);
LanguagePrimitives.GetEnumerator(null);
});
}
}
Expand Down
18 changes: 0 additions & 18 deletions src/System.Management.Automation/utils/ClrFacade.cs
Original file line number Diff line number Diff line change
Expand Up @@ -361,24 +361,6 @@ internal static string ToDmtfDateTime(DateTime date)
#endif
}

/// <summary>
/// Facade for ProfileOptimization.SetProfileRoot.
/// </summary>
/// <param name="directoryPath">The full path to the folder where profile files are stored for the current application domain.</param>
internal static void SetProfileOptimizationRoot(string directoryPath)
{
PSAssemblyLoadContext.SetProfileOptimizationRootImpl(directoryPath);
}

/// <summary>
/// Facade for ProfileOptimization.StartProfile.
/// </summary>
/// <param name="profile">The file name of the profile to use.</param>
internal static void StartProfileOptimization(string profile)
{
PSAssemblyLoadContext.StartProfileOptimizationImpl(profile);
}

#endregion Misc

/// <summary>
Expand Down
5 changes: 3 additions & 2 deletions tools/performance/GC.Regions.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?xml version='1.0' encoding='utf-8' standalone='yes'?>
<!-- See definitions in C:\Windows\Microsoft.NET\Framework\v4.0.30319\CLR-ETW.man for .NET events -->
<!-- See MSDN docs about 'region of interest': https://docs.microsoft.com/windows-hardware/test/wpt/regions-of-interest -->
<!--
Unlike JIT GC is largely single threaded and the times correlate very well with PerfView where we can drill down into each GC
Unlike JIT, GC is largely single threaded and the times correlate very well with PerfView where we can drill down into each GC
generation in the region graph in WPA.
We use bascially the GC Start/Stop events where the GC Start event has also the generation traced which enables us to create
regions for each GC type.
GC suspensions work a bit different were I use the GCSuspendEE_V1 as start and GCRestartEEEnd as end event. This allows us
to capture in principle also the time where the suspension or resumption itself takes an abnormally long time whic would indicate
to capture in principle also the time where the suspension or resumption itself takes. An abnormally long time would indicate
a GC bug or a thread priority problem.
-->
<InstrumentationManifest>
Expand Down
28 changes: 5 additions & 23 deletions tools/performance/Invoke-PerfviewPS.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ param(
$ScriptBlock,

$LogFileName = '.\perfview.log',

$PowerShellPath = $(Get-Command pwsh.exe).Source)
$PowerShellPath = $(Get-Command -Name pwsh.exe).Source,
$PerfViewPath = $(Get-Command -Name PerfView.exe).Source
)

$EncodedScriptBlock = [System.Convert]::ToBase64String([System.Text.Encoding]::UNICODE.GetBytes($ScriptBlock.ToString()))
$perfViewArgs = @(
Expand All @@ -30,26 +31,7 @@ $perfViewArgs = @(
$EncodedScriptBlock
)

$process = Start-Process -FilePath (Get-Command PerfView.exe).Source -ArgumentList $perfViewArgs -PassThru

$rs = [runspacefactory]::CreateRunspace($host)
$rs.Open()
$ps = [powershell]::Create()
$ps.Runspace = $rs

$null = $ps.AddCommand("Get-Content").
AddArgument($LogFileName).
AddParameter("Wait").
AddParameter("Tail", 0)
$null = $ps.AddCommand("Out-Host")

# If log file doesn't exist yet, wait a little bit so Get-Content doesn't fail
while (!(Test-Path $LogFileName))
{
Start-Sleep -Seconds 1
}

$null = $ps.BeginInvoke()
$process = Start-Process -FilePath $PerfViewPath -ArgumentList $perfViewArgs -PassThru
$process.WaitForExit()
$ps.Stop()

Get-Content $LogFileName | Out-Host
1 change: 1 addition & 0 deletions tools/performance/PowerShell.Regions.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version='1.0' encoding='utf-8' standalone='yes'?>
<?Copyright (c) Microsoft Corporation. All rights reserved.?>
<!-- See MSDN docs about 'region of interest': https://docs.microsoft.com/windows-hardware/test/wpt/regions-of-interest -->
<InstrumentationManifest>
<Instrumentation>
<Regions>
Expand Down
9 changes: 5 additions & 4 deletions tools/performance/PowerShell.stacktags
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- To work with ngen'd images and non-ngen'd images, entries are duplicated,
once with .dll, and again with .ni.dll -->
<!-- See MSDN docs about 'region of interest': https://docs.microsoft.com/windows-hardware/test/wpt/stack-tags -->
<Tag Name="PowerShell">
<Tag Name="Pipeline Execution">
<Tag Name="Interpreter">
<Entrypoint Module="System.Management.Automation.dll" Method="System.Management.Automation.Interpreter.*"/>
<Entrypoint Module="System.Core.dll" Method="System.Dynamic.UpdateDelegates.*"/>
<Entrypoint Module="System.Core.dll" Method="System.Runtime.CompilerServices.CallSiteBinder.*"/>
<Entrypoint Module="System.Linq.Expressions.dll" Method="System.Dynamic.UpdateDelegates.*"/>
<Entrypoint Module="System.Linq.Expressions.dll" Method="System.Runtime.CompilerServices.CallSiteBinder.*"/>
<Entrypoint Module="System.Management.Automation.ni.dll" Method="System.Management.Automation.Interpreter.*"/>
<Entrypoint Module="System.Core.ni.dll" Method="System.Dynamic.UpdateDelegates.*"/>
<Entrypoint Module="System.Core.ni.dll" Method="System.Runtime.CompilerServices.CallSiteBinder.*"/>
<Entrypoint Module="System.Linq.Expressions.ni.dll" Method="System.Dynamic.UpdateDelegates.*"/>
<Entrypoint Module="System.Linq.Expressions.ni.dll" Method="System.Runtime.CompilerServices.CallSiteBinder.*"/>
</Tag>
<Tag Name="CommandDiscovery">
<Entrypoint Module="System.Management.Automation.dll" Method="System.Management.Automation.CommandDiscovery.*"/>
Expand Down