Compare commits

...

22 Commits

Author SHA1 Message Date
Michael Niksa 5984fb92d6
Update common.build.post.props 2021-11-24 20:46:47 -08:00
Michael Niksa 904c529980
Update common.build.pre.props 2021-11-24 20:46:12 -08:00
Michael Niksa 548d3e9bc8
Delete common.pgo.runtime.props 2021-11-24 20:44:09 -08:00
Michael Niksa 24a70629e7
Delete common.pgo.compile.props 2021-11-24 20:43:55 -08:00
Michael Niksa f721a5bd57
Update Terminal.PGO.DB.nuspec 2021-11-24 15:21:23 -08:00
Michael Niksa 42305ab6d6
Update pgo-build-and-publish-nuget-job.yml 2021-11-24 13:24:23 -08:00
Michael Niksa 16de6f803b
Update Terminal.PGO.props 2021-11-24 10:56:50 -08:00
Michael Niksa 1746acdea5 Adjust PgoManager format to better match a default pgosweep format 2021-11-23 16:35:51 -08:00
Michael Niksa 8c1baa8aeb try more stuff 2021-11-23 14:53:41 -08:00
Michael Niksa 4bc9756113 uhhh targets 2021-11-23 13:45:15 -08:00
Michael Niksa 8fbe0f6f02 backoff spellbot 2021-11-15 16:33:41 -08:00
Michael Niksa 2dc31ad235 a bit of path rearrangement 2021-11-15 16:29:52 -08:00
Michael Niksa 392ad1c823 another restore line... 2021-11-15 15:31:34 -08:00
Michael Niksa c4f28583ec works better when you restore the package you want to use... 2021-11-15 14:03:19 -08:00
Michael Niksa e1e12e2b16 use the right path, foo 2021-11-15 11:04:51 -08:00
Michael Niksa e5ca94c78d pull nuget onto this machine too 2021-11-12 15:54:27 -08:00
Michael Niksa e0ee7f1b33 target fiddly bits 2021-11-12 14:36:34 -08:00
Michael Niksa 538c5118d0 do this in the other order. 2021-11-12 12:58:32 -08:00
Michael Niksa 92542ab9e8 try more things 2021-11-12 12:31:30 -08:00
Michael Niksa b6a91691e9 Remove double import and fix version path 2021-11-12 11:29:30 -08:00
Michael Niksa 2b80fab4a5 I messed up both of these paths apparently. 2021-11-10 13:44:44 -08:00
Michael Niksa 1645f7f33d attempt to use PGO nuget 2021-11-10 13:13:37 -08:00
32 changed files with 163 additions and 473 deletions

View File

@ -1760,6 +1760,7 @@ PFONTENUMDATA
PFS
pgd
pgdn
PGONu
pgorepro
pgort
PGU

View File

@ -10,6 +10,8 @@
<clear />
</disabledPackageSources>
<config>
<!-- TODO: TEMPORARY UNTIL PGO-Helpers is updated to search both. We shouldn't need to keep the globals path here. -->
<add key="globalPackagesFolder" value=".\packages" />
<add key="repositorypath" value=".\packages" />
</config>
</configuration>

View File

@ -2,4 +2,5 @@
<packages>
<package id="MUXCustomBuildTasks" version="1.0.48" targetFramework="native" />
<package id="Microsoft.Taef" version="10.60.210621002" targetFramework="native" />
<package id="Microsoft.PGO-Helpers.Cpp" version="0.2.22" />
</packages>

4
build/pgo/PGO.DB.proj Normal file
View File

@ -0,0 +1,4 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="Terminal.PGO.props" />
<Import Project="$(PkgMicrosoft_PGO_Helpers_Cpp)\build\Microsoft.PGO-Helpers.Cpp.targets" />
</Project>

View File

@ -0,0 +1,16 @@
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>Microsoft.Internal.Windows.Terminal.PGODatabase</id>
<version>0</version>
<title>Windows Terminal PGO Database</title>
<authors>Microsoft</authors>
<owners>Microsoft</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Windows Terminal PGO Database</description>
</metadata>
<files>
<!-- The target directories for pgd files need to remain as is. PGO optimization pass will rely on this exact directory layout. -->
<file src="x64\*.pgd" target="tools\x64"/>
</files>
</package>

View File

@ -0,0 +1,41 @@
<Project>
<PropertyGroup>
<NuGetPackageDirectory>$(MSBuildThisFileDirectory)..\..\packages</NuGetPackageDirectory>
<PkgMicrosoft_PGO_Helpers_Cpp>$(NuGetPackageDirectory)\Microsoft.PGO-Helpers.Cpp.0.2.22</PkgMicrosoft_PGO_Helpers_Cpp>
</PropertyGroup>
<!-- Get version information -->
<Import Project="$(MSBuildThisFileDirectory)..\..\custom.props" />
<PropertyGroup>
<!-- Optional, defaults to main. Name of the branch which will be used for calculating branch point. -->
<PGOBranch>dev/miniksa/pgo</PGOBranch>
<!-- Mandatory. Name of the NuGet package which will contain PGO databases for consumption by build system. -->
<PGOPackageName>Microsoft.Internal.Windows.Terminal.PGODatabase</PGOPackageName>
<!-- Mandatory. Major version number of the PGO database which should match the version of the product. This can be hardcoded or obtained from other sources in build system. -->
<PGOPackageVersionMajor>$(VersionMajor)</PGOPackageVersionMajor>
<!-- Mandatory. Minor version number of the PGO database which should match the version of the product. This can be hardcoded or obtained from other sources in build system. -->
<PGOPackageVersionMinor>$(VersionMinor)</PGOPackageVersionMinor>
<!-- Mandatory. Path to nuget.config file for the project. Path is relative to where the props file will be. -->
<PGONuGetConfigPath>$(MSBuildThisFileDirectory)..\..\nuget.config</PGONuGetConfigPath>
<!-- Mandatory. Path to PGO database NuSpec, see section below. -->
<PGONuspecPath>$(MSBuildThisFileDirectory)Terminal.PGO.DB.nuspec</PGONuspecPath>
<!-- Optional, defaults to true. Should verification result in build failure or error? -->
<PGOVerifyFailureTreatedAsError>true</PGOVerifyFailureTreatedAsError>
<!-- Optional, defaults to $(IntDir)\Nuspec. Temporary path where PGD files are copied to. -->
<PGONuspecBasePath>$(PGDPathForAllArch)</PGONuspecBasePath>
<!-- Optional, defaults to true. Specifies whether to use default information for PGD files. -->
<PGOUseDefaultPGDFileInfo>true</PGOUseDefaultPGDFileInfo>
</PropertyGroup>
<!-- Import PGO-Helpers -->
<Import Project="$(PkgMicrosoft_PGO_Helpers_Cpp)\build\Microsoft.PGO-Helpers.Cpp.props" />
</Project>

View File

@ -89,6 +89,16 @@ jobs:
displayName: Use NuGet 5.10
inputs:
versionSpec: 5.10
# In the Microsoft Azure DevOps tenant, NuGetCommand is ambiguous.
# This should be `task: NuGetCommand@2`
- task: 333b11bd-d341-40d9-afcf-b32d5ce6f23b@2
displayName: Restore NuGet packages for extraneous build actions
inputs:
command: restore
feedsToUse: config
configPath: NuGet.config
restoreSolution: build/packages.config
restoreDirectory: '$(Build.SourcesDirectory)\packages'
- task: NuGetCommand@2
displayName: NuGet custom
inputs:
@ -140,12 +150,6 @@ jobs:
filePath: .\build\scripts\Generate-ThirdPartyNotices.ps1
arguments: -MarkdownNoticePath .\NOTICE.md -OutputPath .\src\cascadia\CascadiaPackage\NOTICE.html
pwsh: true
- ${{ if eq(parameters.pgoBuildMode, 'Optimize') }}:
- task: PowerShell@2
displayName: Restore PGO Database
inputs:
filePath: tools/PGODatabase/restore-pgodb.ps1
workingDirectory: $(Build.SourcesDirectory)\tools\PGODatabase
- ${{ if eq(parameters.buildTerminal, true) }}:
- task: VSBuild@1
displayName: Build solution **\OpenConsole.sln
@ -164,20 +168,6 @@ jobs:
inputs:
PathtoPublish: $(Build.SourcesDirectory)\msbuild.binlog
ArtifactName: binlog-$(BuildPlatform)
- ${{ if eq(parameters.pgoBuildMode, 'Optimize') }}:
- task: PowerShell@2
displayName: Validate binaries are optimized
condition: and(succeeded(), eq(variables['BuildPlatform'], 'x64'))
inputs:
targetType: inline
script: >-
$Binaries = 'OpenConsole.exe', 'WindowsTerminal.exe', 'TerminalApp.dll', 'TerminalConnection.dll', 'Microsoft.Terminal.Control.dll', 'Microsoft.Terminal.Remoting.dll', 'Microsoft.Terminal.Settings.Editor.dll', 'Microsoft.Terminal.Settings.Model.dll'
foreach ($BinFile in $Binaries) {
& "$(Build.SourcesDirectory)\tools\PGODatabase\verify-pgo.ps1" "$(Build.SourcesDirectory)/src/cascadia/CascadiaPackage/bin/$(BuildPlatform)/$(BuildConfiguration)/$BinFile"
}
- task: PowerShell@2
displayName: Check MSIX for common regressions
inputs:

View File

@ -22,7 +22,7 @@ jobs:
steps:
- template: build-console-steps.yml
parameters:
additionalBuildArguments: ${{ parameters.additionalBuildArguments }}
additionalBuildArguments: '${{ parameters.additionalBuildArguments }}'
- template: helix-runtests-job.yml
parameters:
@ -52,3 +52,4 @@ jobs:
- ProcessTestResults
pgoArtifact: 'PGO'
platform: ${{ parameters.platform }}
configuration: ${{ parameters.configuration }}

View File

@ -12,17 +12,10 @@ steps:
inputs:
versionSpec: 5.2.0
- task: NuGetAuthenticate@0
# In the Microsoft Azure DevOps tenant, NuGetCommand is ambiguous.
# This should be `task: NuGetCommand@2`
- task: 333b11bd-d341-40d9-afcf-b32d5ce6f23b@2
displayName: Restore NuGet packages for solution
inputs:
command: restore
feedsToUse: config
configPath: NuGet.config
restoreSolution: OpenConsole.sln
restoreDirectory: '$(Build.SourcesDirectory)\packages'
- task: 333b11bd-d341-40d9-afcf-b32d5ce6f23b@2
displayName: Restore NuGet packages for extraneous build actions
inputs:
@ -32,6 +25,15 @@ steps:
restoreSolution: build/packages.config
restoreDirectory: '$(Build.SourcesDirectory)\packages'
- task: 333b11bd-d341-40d9-afcf-b32d5ce6f23b@2
displayName: Restore NuGet packages for solution
inputs:
command: restore
feedsToUse: config
configPath: NuGet.config
restoreSolution: OpenConsole.sln
restoreDirectory: '$(Build.SourcesDirectory)\packages'
# The environment variable VCToolsInstallDir isn't defined on lab machines, so we need to retrieve it ourselves.
- script: |
"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -Latest -requires Microsoft.Component.MSBuild -property InstallationPath > %TEMP%\vsinstalldir.txt
@ -47,14 +49,6 @@ steps:
inputs:
filename: 'set'
- task: powershell@2
displayName: 'Restore PGO database'
condition: eq(variables['PGOBuildMode'], 'Optimize')
inputs:
targetType: filePath
workingDirectory: $(Build.SourcesDirectory)\tools\PGODatabase
filePath: $(Build.SourcesDirectory)\tools\PGODatabase\restore-pgodb.ps1
- task: VSBuild@1
displayName: 'Build solution **\OpenConsole.sln'
inputs:
@ -62,7 +56,7 @@ steps:
vsVersion: 16.0
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
msbuildArgs: "${{ parameters.additionalBuildArguments }}"
msbuildArgs: "${{ parameters.additionalBuildArguments }} /p:PGOBuildMode=$(PGOBuildMode) /p:PGOCopyRuntime=true"
clean: true
maximumCpuCount: true
@ -95,18 +89,6 @@ steps:
If ($Arch -Eq "x86") { $Arch = "Win32" }
Write-Host "##vso[task.setvariable variable=RationalizedBuildPlatform]${Arch}"
- task: PowerShell@2
displayName: 'Validate binaries are optimized'
condition: eq(variables['pgoBuildMode'], 'Optimize')
inputs:
targetType: inline
script: |
$Binaries = 'OpenConsole.exe', 'WindowsTerminal.exe', 'TerminalApp.dll', 'TerminalConnection.dll', 'Microsoft.Terminal.Control.dll', 'Microsoft.Terminal.Remoting.dll', 'Microsoft.Terminal.Settings.Editor.dll', 'Microsoft.Terminal.Settings.Model.dll'
foreach ($BinFile in $Binaries)
{
& "$(Build.SourcesDirectory)\tools\PGODatabase\verify-pgo.ps1" "$(Build.SourcesDirectory)/bin/$(RationalizedBuildPlatform)/$(BuildConfiguration)/$BinFile"
}
- task: PowerShell@2
displayName: 'Run Unit Tests'
inputs:

View File

@ -11,7 +11,7 @@ jobs:
vmImage: 'windows-2019'
variables:
artifactsPath: $(Build.SourcesDirectory)\Artifacts
pgoToolsPath: $(Build.SourcesDirectory)\tools\PGODatabase
pgoToolsPath: $(Build.SourcesDirectory)\build\PGO
nuspecPath: $(pgoToolsPath)\NuSpecs
nuspecFilename: PGO.nuspec
@ -30,28 +30,22 @@ jobs:
inputs:
versionSpec: 5.8.0
- task: CopyFiles@2
displayName: 'Copy pgd files to NuGet build directory'
inputs:
sourceFolder: $(artifactsPath)\${{ parameters.pgoArtifact }}
contents: '**\*.pgd'
targetFolder: $(nuspecPath)\tools
- task: powershell@2
displayName: 'Generate NuSpec file'
inputs:
targetType: filePath
filePath: $(pgoToolsPath)\generate-nuspec.ps1
workingDirectory: $(pgoToolsPath)
arguments: $(nuspecPath)\$(nuspecFilename).template $(nuspecPath)\$(nuspecFilename)
# In the Microsoft Azure DevOps tenant, NuGetCommand is ambiguous.
# This should be `task: NuGetCommand@2`
- task: 333b11bd-d341-40d9-afcf-b32d5ce6f23b@2
displayName: 'NuGet pack'
displayName: Restore NuGet packages for extraneous build actions
inputs:
command: pack
packagesToPack: '$(nuspecPath)\$(nuspecFilename)'
basePath: '$(nuspecPath)'
packDestination: '$(Build.ArtifactStagingDirectory)'
command: restore
feedsToUse: config
configPath: NuGet.config
restoreSolution: build/packages.config
restoreDirectory: '$(Build.SourcesDirectory)\packages'
- task: MSBuild@1
displayName: 'Create PGO Nuget'
inputs:
solution: $(pgoToolsPath)\PGO.DB.proj
msbuildArguments: '/t:CreatePGONuGet /p:PGDPathForAllArch=$(artifactsPath)\${{ parameters.pgoArtifact }} /p:PGOOutputPath=$(Build.ArtifactStagingDirectory)'
- task: PublishBuildArtifacts@1
inputs:
@ -69,4 +63,4 @@ jobs:
# This is the name of that connection
publishFeedCredentials: 'Terminal Public Artifact Feed'
feedsToUse: config
nugetConfigPath: '$(Build.SourcesDirectory)/NuGet.config'
nugetConfigPath: '$(Build.SourcesDirectory)/NuGet.config'

View File

@ -2,6 +2,7 @@ parameters:
dependsOn: ''
pgoArtifact: PGO
platform: ''
configuration: ''
jobs:
- job: MergePGD
@ -12,6 +13,7 @@ jobs:
artifactsPath: $(Build.SourcesDirectory)\Artifacts
pgoArtifactsPath: $(artifactsPath)\${{ parameters.pgoArtifact }}
buildPlatform: ${{ parameters.platform }}
buildConfiguration: ${{ parameters.configuration }}
steps:
# The environment variable VCToolsInstallDir isn't defined on lab machines, so we need to retrieve it ourselves.
@ -24,58 +26,36 @@ jobs:
echo ##vso[task.setvariable variable=VCToolsInstallDir]%VCToolsInstallDir%
displayName: 'Retrieve VC tools directory'
- task: NuGetToolInstaller@0
displayName: 'Use NuGet 5.2.0'
inputs:
versionSpec: 5.2.0
- task: NuGetAuthenticate@0
# In the Microsoft Azure DevOps tenant, NuGetCommand is ambiguous.
# This should be `task: NuGetCommand@2`
- task: 333b11bd-d341-40d9-afcf-b32d5ce6f23b@2
displayName: Restore NuGet packages for extraneous build actions
inputs:
command: restore
feedsToUse: config
configPath: NuGet.config
restoreSolution: build/packages.config
restoreDirectory: '$(Build.SourcesDirectory)\packages'
- task: DownloadBuildArtifacts@0
inputs:
artifactName: ${{ parameters.pgoArtifact }}
downloadPath: $(artifactsPath)
- script: |
cd $(buildPlatform)
"%VCToolsInstallDir%\bin\hostx64\x64\pgomgr.exe" /merge WindowsTerminal*.pgc WindowsTerminal.pgd
displayName: 'Merge Terminal pgc files into pgd'
workingDirectory: $(pgoArtifactsPath)
- script: |
cd $(buildPlatform)
"%VCToolsInstallDir%\bin\hostx64\x64\pgomgr.exe" /merge OpenConsole*.pgc OpenConsole.pgd
displayName: 'Merge OpenConsole pgc files into pgd'
workingDirectory: $(pgoArtifactsPath)
- script: |
cd $(buildPlatform)
"%VCToolsInstallDir%\bin\hostx64\x64\pgomgr.exe" /merge Microsoft.Terminal.Control*.pgc Microsoft.Terminal.Control.pgd
displayName: 'Merge Microsoft.Terminal.Control pgc files into pgd'
workingDirectory: $(pgoArtifactsPath)
- script: |
cd $(buildPlatform)
"%VCToolsInstallDir%\bin\hostx64\x64\pgomgr.exe" /merge Microsoft.Terminal.Remoting*.pgc Microsoft.Terminal.Remoting.pgd
displayName: 'Merge Microsoft.Terminal.Remoting pgc files into pgd'
workingDirectory: $(pgoArtifactsPath)
- script: |
cd $(buildPlatform)
"%VCToolsInstallDir%\bin\hostx64\x64\pgomgr.exe" /merge Microsoft.Terminal.Settings.Editor*.pgc Microsoft.Terminal.Settings.Editor.pgd
displayName: 'Merge Microsoft.Terminal.Settings.Editor pgc files into pgd'
workingDirectory: $(pgoArtifactsPath)
- script: |
cd $(buildPlatform)
"%VCToolsInstallDir%\bin\hostx64\x64\pgomgr.exe" /merge Microsoft.Terminal.Settings.Model*.pgc Microsoft.Terminal.Settings.Model.pgd
displayName: 'Merge Microsoft.Terminal.Settings.Model pgc files into pgd'
workingDirectory: $(pgoArtifactsPath)
- script: |
cd $(buildPlatform)
"%VCToolsInstallDir%\bin\hostx64\x64\pgomgr.exe" /merge TerminalApp*.pgc TerminalApp.pgd
displayName: 'Merge TerminalApp pgc files into pgd'
workingDirectory: $(pgoArtifactsPath)
- script: |
cd $(buildPlatform)
"%VCToolsInstallDir%\bin\hostx64\x64\pgomgr.exe" /merge TerminalConnection*.pgc TerminalConnection.pgd
displayName: 'Merge TerminalConnection pgc files into pgd'
workingDirectory: $(pgoArtifactsPath)
- task: MSBuild@1
displayName: Merge counts into PGD
inputs:
solution: $(Build.SourcesDirectory)\OpenConsole.sln
platform: $(buildPlatform)
configuration: $(buildConfiguration)
msbuildArguments: '/t:MergePGOCounts /p:PGDPath=$(pgoArtifactsPath)\$(buildPlatform) /p:PGCRootPath=$(pgoArtifactsPath)\$(buildPlatform)'
- task: CopyFiles@2
displayName: 'Copy merged pgd to artifact staging'

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
@ -9,16 +9,25 @@ namespace WindowsTerminal.UIA.Tests.Common
{
public static class PgoManager
{
private static string TrimExtension(string str)
{
if (str.EndsWith(".exe") || str.EndsWith(".dll"))
{
return str.Substring(0, str.Length - 4);
}
return str;
}
public static void PgoSweepIfInstrumented(TestContext context, string assemblyName)
{
#if PGO_INSTRUMENT
#if true
string pgcFileName = context.TestName;
Log.Comment($"Running pgosweep on '{assemblyName}' for test: {pgcFileName}");
try
{
var startInfo = new ProcessStartInfo() {
FileName = Path.GetFullPath(Path.Combine(context.TestDeploymentDir, "pgosweep.exe")),
Arguments = $"{assemblyName} {assemblyName}-{pgcFileName}.pgc",
Arguments = $"{assemblyName} {TrimExtension(assemblyName)}!{pgcFileName}.pgc",
UseShellExecute = false,
RedirectStandardOutput = true
};

View File

@ -117,6 +117,8 @@
</ItemGroup>
</When>
</Choose>
<!-- Install an empty one for projects that don't PGO. -->
<Target Name="MergePGOCounts" />
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>

View File

@ -29,6 +29,9 @@
</PackageReference>
</ItemGroup>
<!-- Install an empty one for CSPROJ projects as they don't PGO. -->
<Target Name="MergePGOCounts" />
<Target Name="CollectNativePackContents">
<ItemGroup>
<None Include="$(RepoBinPath)\Win32\$(Configuration)\PublicTerminalCore.dll">

View File

@ -33,9 +33,7 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<!-- PGO -->
<Import Condition="'$(PgoTarget)' == 'true' And '$(PGOBuildMode)' == 'Optimize'" Project="$(SolutionDir)packages\$(PGODatabaseId).$(PGODatabaseVersion)\build\PGO.targets" />
<Import Condition="'$(PgoTarget)' == 'true' And '$(PGOBuildMode)' == 'Instrument'" Project="$(SolutionDir)\src\common.pgo.runtime.props" />
<Import Condition="'$(PgoTarget)' == 'true' And '$(Platform)'=='x64'" Project="$(PkgMicrosoft_PGO_Helpers_Cpp)\build\Microsoft.PGO-Helpers.Cpp.targets" />
<!-- Exclude our dependencies from static analysis. CAExcludePath can only be
set after we've imported Microsoft.Cpp.targets -->

View File

@ -174,8 +174,10 @@
</Link>
</ItemDefinitionGroup>
<Import Condition="'$(PgoTarget)' == 'true' And '$(Configuration)' == 'Release'" Project="$(SolutionDir)\src\common.pgo.compile.props" />
<Import Condition="'$(PgoTarget)' == 'true' And '$(PGOBuildMode)' == 'Optimize'" Project="$(SolutionDir)\tools\PGODatabase\PGO.version.props" />
<!-- Install an empty one for projects that won't have one.
The following import will override it when it needs to happen. -->
<Target Name="MergePGOCounts" />
<Import Condition="'$(PgoTarget)' == 'true' And '$(Platform)'=='x64'" Project="$(SolutionDir)\build\PGO\Terminal.PGO.props" />
<!-- For Win32 (x86) ONLY ... we use all defaults for AMD64. No def for those. -->
<ItemDefinitionGroup Condition="'$(Platform)'=='Win32'">

View File

@ -1,19 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- From our friends at MUX: https://github.com/microsoft/microsoft-ui-xaml/blob/main/PGO.compile.props -->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(PGOBuildMode)' == 'Instrument'">
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<!-- Enable PGO optimization only for Release builds. -->
<ItemDefinitionGroup Condition="'$(PGOBuildMode)' == 'Instrument'">
<Link>
<AdditionalOptions>/GENPROFILE %(AdditionalOptions)</AdditionalOptions>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
<AdditionalDependencies Condition="'$(Platform)'=='ARM'">$(VC_ReferencesPath_VC_ARM)\pgort.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies Condition="'$(Platform)'=='ARM64'">$(VC_ReferencesPath_VC_ARM64)\pgort.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies Condition="'$(Platform)'=='Win32'">$(VC_ReferencesPath_VC_x86)\pgort.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies Condition="'$(Platform)'=='x64'">$(VC_ReferencesPath_VC_x64)\pgort.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
</Project>

View File

@ -1,30 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- From our friends at MUX: https://github.com/microsoft/microsoft-ui-xaml/blob/main/PGO.runtime.props -->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PlatformShortName Condition="'$(PlatformShortName)'==''">$(Platform)</PlatformShortName>
<PlatformShortName Condition="'$(PlatformShortName)'=='Win32'">x86</PlatformShortName>
<PlatformShortName Condition="'$(PlatformShortName)'=='AnyCPU' and '$(Prefer32Bit)'==''">x64</PlatformShortName>
<PlatformShortName Condition="'$(PlatformShortName)'=='AnyCPU' and '$(Prefer32Bit)'=='true'">x64</PlatformShortName>
<PlatformShortName Condition="'$(PlatformShortName)'=='AnyCPU' and '$(Prefer32Bit)'=='false'">x64</PlatformShortName>
<HostFolderName Condition="'$(VCToolArchitecture)'=='Native32Bit'">Hostx86</HostFolderName>
<HostFolderName Condition="'$(VCToolArchitecture)'=='Native64Bit'">Hostx64</HostFolderName>
<PGOFilesDir>$(VCToolsInstallDir)bin\$(HostFolderName)\$(PlatformShortName)</PGOFilesDir>
<PGOFilesDir Condition="'$(PlatformShortName)'=='ARM' or '$(PlatformShortName)'=='ARM64'">$(VCToolsInstallDir)bin\$(PlatformShortName)</PGOFilesDir>
</PropertyGroup>
<ItemGroup>
<None Include="$(PGOFilesDir)\pgort140.dll">
<Link>%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(PGOFilesDir)\pgosweep.exe">
<Link>%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(PGOFilesDir)\vcruntime140.dll" Condition="Exists('$(PGOFilesDir)\vcruntime140.dll')">
<Link>%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View File

@ -140,6 +140,8 @@
</ItemGroup>
</When>
</Choose>
<!-- Install an empty one for CSPROJ projects as they don't PGO. -->
<Target Name="MergePGOCounts" />
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>

View File

@ -45,6 +45,8 @@
<Platform>AnyCPU</Platform>
</ProjectConfiguration>
</ItemGroup>
<!-- Install an empty one for projects that don't PGO. -->
<Target Name="MergePGOCounts" />
<PropertyGroup>
<WapProjPath Condition="'$(WapProjPath)'==''">$(MSBuildExtensionsPath)\Microsoft\DesktopBridge\</WapProjPath>
</PropertyGroup>

View File

@ -56,6 +56,8 @@
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- Install an empty one for CSPROJ projects as they don't PGO. -->
<Target Name="MergePGOCounts" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">

View File

@ -51,6 +51,9 @@
<ProjectCapability Include="AssemblyReferences" />
</ItemGroup>
<!-- Install an empty one for WAP projects as they don't PGO. -->
<Target Name="MergePGOCounts" />
<PropertyGroup>
<WapProjPath Condition="'$(WapProjPath)'==''">$(MSBuildExtensionsPath)\Microsoft\DesktopBridge\</WapProjPath>
<!-- Turn off the 6+MB Windows.winmd that's emitted into our package

View File

@ -1,18 +0,0 @@
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>$id</id>
<version>$version</version>
<title>PGO Database</title>
<authors>Microsoft</authors>
<owners>Microsoft</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>PGO Database</description>
<releaseNotes>Initial release</releaseNotes>
<copyright>Copyright 2021</copyright>
</metadata>
<files>
<file target="build\PGO.targets" src="build\PGO.targets"/>
<file target="tools\x64\" src="tools\x64\*.pgd"/>
</files>
</package>

View File

@ -1,20 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License. See LICENSE in the project root for license information. -->
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PlatformShortName Condition="'$(PlatformShortName)'==''">$(Platform)</PlatformShortName>
<PlatformShortName Condition="'$(PlatformShortName)'=='Win32'">x86</PlatformShortName>
<PlatformShortName Condition="'$(PlatformShortName)'=='AnyCPU' and '$(Prefer32Bit)'==''">x64</PlatformShortName>
<PlatformShortName Condition="'$(PlatformShortName)'=='AnyCPU' and '$(Prefer32Bit)'=='true'">x64</PlatformShortName>
<PlatformShortName Condition="'$(PlatformShortName)'=='AnyCPU' and '$(Prefer32Bit)'=='false'">x64</PlatformShortName>
<ProfileGuidedDatabaseFileName>$(MSBuildThisFileDirectory)..\tools\$(PlatformShortName)\$(TargetName).pgd</ProfileGuidedDatabaseFileName>
</PropertyGroup>
<!-- Enable PGO optimization only for if the pgds file exists. -->
<ItemDefinitionGroup Condition="'$(Configuration)' == 'Release' and '$(PGOBuildMode)' == 'Optimize' and Exists('$(ProfileGuidedDatabaseFileName)')">
<Link>
<LinkTimeCodeGeneration>PGUpdate</LinkTimeCodeGeneration>
<ProfileGuidedDatabase>$(ProfileGuidedDatabaseFileName)</ProfileGuidedDatabase>
<AdditionalOptions>/force:pgorepro %(AdditionalOptions)</AdditionalOptions>
</Link>
</ItemDefinitionGroup>
</Project>

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License. See LICENSE in the project root for license information. -->
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<PGODatabaseId>$id</PGODatabaseId>
<PGODatabaseVersion>$version</PGODatabaseVersion>
</PropertyGroup>
</Project>

View File

@ -1,7 +0,0 @@
$pgoBranch = "main"
$packageId = "Microsoft.Internal.Windows.Terminal.PGODatabase"
# Get release version
[xml] $customProps = ( Get-Content "..\..\custom.props" )
$releaseVersionMajor = ( [int]::Parse( $customProps.GetElementsByTagName("VersionMajor").'#text' ) )
$releaseVersionMinor = ( [int]::Parse( $customProps.GetElementsByTagName("VersionMinor").'#text' ) )

View File

@ -1,11 +0,0 @@
Param(
[Parameter(Mandatory = $true, Position = 1)] [string] $templatePath,
[Parameter(Mandatory = $true, Position = 2)] [string] $outputPath)
. .\version.ps1
. .\template.ps1
. .\config.ps1
$version = FormatVersion ( MakeVersion $releaseVersionMajor $releaseVersionMinor ( GetDatetimeStamp $pgoBranch ) )
Write-Host ( "PGO INSTRUMENT: generating {0} version {1}" -f $packageId, $version )
FillOut-Template $templatePath $outputPath @{ "version" = $version; "id" = $packageId }

View File

@ -1,49 +0,0 @@
# Profile Guided Optimization
**NOTE: All PGO work builds on work from Microsoft/Microsoft-UI-XAML**
## Description
We generate PGO database NuGet package which is versioned based on product release version and branch name/time stamp of the code that was used for instrumentation and training. In CI/release builds an initialization step enumerates all available versions, filters out those for other releases and branches. Given a list of applicable versions, it will find the one that is closest (BEFORE) the time-stamp of the last commit or a fork-point from instrumented branch. That package version will be installed and version references will be updated. The PGO branch is determined by variable $pgoBranch in tools/PGODatabase/config.ps1. It will need to be updated if a forked branch should be PGO'd.
## Scenarios
For the purpose of illustration, lets assume the following is a chronological list of check-ins to two branches (main and release/2.4). Some of them have had instrumentation/training run done on them and have generated PGO NuGets (version numbers in parentheses). To simplify, lets assume that release major and minor versions are the same for all check-in as they merely act as filters for what versions are considered to be available.
1b27fd5f -- main --
7b303f74 -- main --
930ff585 -- main -- 2.4.2001312227-main
63948a75 -- main --
0d379b51 -- main --
f23f1fad -- main -- 2.4.2001312205-main
bcf9adaa -- main --
6ef44a23 -- main --
310bc133 -- release/2.4 --
80a4ab55 -- release/2.4 -- 2.4.2001312054-release_2_4
18b956f6 -- release/2.4 --
4abd4d54 -- main -- 2.4.2001312033-main
d150eae0 -- main -- 2.4.2001312028-main
### Optimizing on PGOd branch
If we are building on main (which in this example is PGOd), the version picked will be the one that has the same major and minor versions AND branch name and is the same or is right before the SHA being built.
E.g.
1b27fd5f -- 2.4.2001312227-main
f23f1fad -- 2.4.2001312205-main
bcf9adaa -- 2.4.2001312033-main
### Optimizing release branch
A branch which will be PGOd requires a slightly different handling. Lets say release/2.4 forked from main on commit 4abd4d54. Initially, it will be configured to track main and 18b956f6 will be optimized with 2.4.2001312033-main. When the configuration is changed to start tracking release/2.4 (change branch name $pgoBranch in tools/PGODatabase/config.ps1 script), it will start tracking its own branch.
E.g.
18b956f6 -- if tracking main -> 2.4.2001312033-main,
if tracking release/2.4 -> ERROR (no database exists)
310bc133 -- 2.4.2001312054-release_2_4
### Optimizing topic branch
Assuming topic branch will not have a training run done, it can still use database from branch it was forked from. Lets say we have a branch which was forked from main on 4abd4d54. If we dont change which branch its tracking, it will keep using 2.4.2001312033-main. Merging main on f23f1fad into topic branch, will change used database to 2.4.2001312205-main.

View File

@ -1,47 +0,0 @@
. .\version.ps1
. .\template.ps1
. .\config.ps1
$feedUri = "https://pkgs.dev.azure.com/ms/terminal/_packaging/TerminalDependencies/nuget/v2"
$currentVersion = MakeVersion $releaseVersionMajor $releaseVersionMinor ( GetDatetimeStamp $pgoBranch )
Write-Host ( "PGO OPTIMIZE: requesting {0} version {1}" -f $packageId, ( FormatVersion $currentVersion ) )
$packageSource = Register-PackageSource -ForceBootstrap -Name TerminalDependencies -Location $feedUri -ProviderName NuGet -Trusted
$packages = ( Find-Package $packageId -Source TerminalDependencies -AllowPrereleaseVersions -AllVersions ) | Sort-Object -Property Version -Descending
$best = $null
foreach ( $existing in $packages )
{
$existingVersion = MakeVersionFromString $existing.Version
if ( ( CompareBranches $existingVersion $currentVersion ) -eq $False -or
( CompareReleases $existingVersion $currentVersion ) -ne 0 )
{
# If this is different release or branch, then skip it.
continue
}
if ( ( CompareRevisions $existingVersion $currentVersion ) -le 0 )
{
# Version are sorted in descending order, the first one less than or equal to the current is the one we want.
# NOTE: at this point the only difference between versions will be revision (date-time stamp)
# which is formatted as a fixed-length string, so string comparison WILL sort it correctly.
$best = $existing
break
}
}
if ( $best -eq $null )
{
throw "Appropriate database cannot be found"
}
Write-Host ( "PGO OPTIMIZE: picked {0} version {1}" -f $packageId, $best.Version )
$best | Install-Package -Destination ..\..\packages -Force
$packageSource | Unregister-PackageSource
FillOut-Template "PGO.version.props.template" "PGO.version.props" @{ "version" = $best.Version; "id" = $packageId }

View File

@ -1,16 +0,0 @@
function Replace-Many ( $string, $dictionary )
{
foreach ( $key in $dictionary.Keys )
{
$field = '$' + $key.ToString()
$string = $string.Replace( $field, $dictionary[$key].ToString() )
}
return $string
}
function FillOut-Template ( $inputPath, $outputPath, $dictionary )
{
$replaced = Replace-Many ( Get-Content $inputPath ) $dictionary
Write-Output $replaced | Set-Content $outputPath -Force | Out-Null
}

View File

@ -1,45 +0,0 @@
Param(
[Parameter(Mandatory = $true, Position = 1)]
[string] $module)
if ( !( Test-Path $module ) )
{
throw "File does not exist $module"
}
$vsPath = &(Join-Path ${env:ProgramFiles(x86)} "\Microsoft Visual Studio\Installer\vswhere.exe") -property installationpath
Import-Module (Get-ChildItem $vsPath -Recurse -File -Filter Microsoft.VisualStudio.DevShell.dll).FullName
Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation
$output = ( & link.exe /dump /headers /coffgroup $module )
$regex1 = [regex] '^\s*[A-F0-9]+ coffgrp(\s+[A-F0-9]+){4} \(PGU\)$'
$regex2 = [regex] '^\s*([A-F0-9]+\s+){2}\.text\$zz$'
$matchFlags = 0
foreach ( $line in $output )
{
if ( $line -match $regex1 )
{
$matchFlags = $matchFlags -bor 1
}
if ( $line -match $regex2 )
{
$matchFlags = $matchFlags -bor 2
}
}
$optimized = $matchFlags -eq 3
$message = "$module is $( if ( $optimized ) { "optimized" } else { "not optimized" } )"
if ( -not $optimized )
{
throw $message
}
else
{
write-host $message
}

View File

@ -1,75 +0,0 @@
function MakeVersion ( $major, $minor, $datetimeStamp )
{
$revision, $branch = $datetimeStamp.Split("-", 2)
if ( $branch -eq $null )
{
$branch = ""
}
return [PSCustomObject] @{
Major = $major
Minor = $minor
Revision = $revision
Branch = $branch
}
}
function MakeVersionFromString ( $str )
{
$parts = $str.Split(".")
return MakeVersion ( [int]::Parse($parts[0]) ) ( [int]::Parse($parts[1]) ) $parts[2]
}
function FormatVersion ( $version )
{
$branch = ""
if ( $version.Branch -ne "" )
{
$branch = "-{0}" -f $version.Branch
}
return "{0}.{1}.{2}{3}" -f $version.Major, $version.Minor, $version.Revision, $branch
}
function CompareReleases ( $version1, $version2 )
{
$cmpMajor = [Math]::Sign($version1.Major - $version2.Major)
if ( $cmpMajor -ne 0 )
{
return $cmpMajor
}
return [Math]::Sign($version1.Minor - $version2.Minor)
}
function CompareRevisions ( $version1, $version2 )
{
return [Math]::Sign($version1.Revision - $version2.Revision)
}
function CompareBranches ( $version1, $version2 )
{
return $version1.Branch -eq $version2.Branch
}
function GetDatetimeStamp ( $pgoBranch )
{
$forkSHA = $( git merge-base origin/$pgoBranch HEAD )
if ( $LastExitCode -ne 0 )
{
throw "FAILED: git merge-base"
}
$forkDate = ( Get-Date -Date $( git log -1 $forkSHA --date=iso --pretty=format:"%ad" ) ).ToUniversalTime().ToString("yyMMddHHmm")
if ( $LastExitCode -ne 0 )
{
throw "FAILED: Get forkDate"
}
return $forkDate + "-" + ( $pgoBranch -replace "(/|\.|@|>|<)", "-" )
}