Minor performance infrastructure changes. (#13557)
authorJosé Rivero <jorive@microsoft.com>
Fri, 25 Aug 2017 23:26:45 +0000 (16:26 -0700)
committerGitHub <noreply@github.com>
Fri, 25 Aug 2017 23:26:45 +0000 (16:26 -0700)
- IlLink scenario will run on a VM (currently it is only measuring MSIL size)
- Updated the patterns of files to search for on scenario runs
- Updated the JitBench commit hash being used ()
- Disable min_opt from the PR correctness mode.
- String was not being interpolated.

perf.groovy
tests/scripts/run-xunit-perf.cmd
tests/src/performance/Scenario/JitBench/JitBenchHarness.cs

index 92073c7..0ef3509 100644 (file)
@@ -37,6 +37,10 @@ def static getOSGroup(def os) {
                     }
 
                     ['full_opt', 'min_opt'].each { opt_level ->
+                        if (isSmoketest && opt_level == 'min_opt') {
+                            return
+                        }
+
                         def architecture = arch
                         def jobName = isSmoketest ? "perf_perflab_${os}_${arch}_${opt_level}_${jit}_smoketest" : "perf_perflab_${os}_${arch}_${opt_level}_${jit}"
                         def testEnv = ""
@@ -105,11 +109,13 @@ def static getOSGroup(def os) {
                                 batchFile("xcopy.exe /VYQK bin\\sandbox\\Logs\\Perf-*.* bin\\toArchive\\sandbox\\Logs\\CodeQuality\\Off\\")
 
                                 // Run with the full set of counters enabled: Profile=On
-                                batchFile("tests\\scripts\\run-xunit-perf.cmd ${runXUnitPerfCommonArgs} -testBinLoc bin\\tests\\${os}.${architecture}.${configuration}\\performance\\perflab\\Perflab -library -collectionFlags default+BranchMispredictions+CacheMisses+InstructionRetired+gcapi")
-                                batchFile("xcopy.exe /VYQK bin\\sandbox\\Logs\\Perf-*.* bin\\toArchive\\sandbox\\Logs\\Perflab\\On\\")
+                                if (opt_level != 'min_opt') {
+                                    batchFile("tests\\scripts\\run-xunit-perf.cmd ${runXUnitPerfCommonArgs} -testBinLoc bin\\tests\\${os}.${architecture}.${configuration}\\performance\\perflab\\Perflab -library -collectionFlags default+BranchMispredictions+CacheMisses+InstructionRetired+gcapi")
+                                    batchFile("xcopy.exe /VYQK bin\\sandbox\\Logs\\Perf-*.* bin\\toArchive\\sandbox\\Logs\\Perflab\\On\\")
 
-                                batchFile("tests\\scripts\\run-xunit-perf.cmd ${runXUnitPerfCommonArgs} -testBinLoc bin\\tests\\${os}.${architecture}.${configuration}\\Jit\\Performance\\CodeQuality -collectionFlags default+BranchMispredictions+CacheMisses+InstructionRetired+gcapi")
-                                batchFile("xcopy.exe /VYQK bin\\sandbox\\Logs\\Perf-*.* bin\\toArchive\\sandbox\\Logs\\CodeQuality\\On\\")
+                                    batchFile("tests\\scripts\\run-xunit-perf.cmd ${runXUnitPerfCommonArgs} -testBinLoc bin\\tests\\${os}.${architecture}.${configuration}\\Jit\\Performance\\CodeQuality -collectionFlags default+BranchMispredictions+CacheMisses+InstructionRetired+gcapi")
+                                    batchFile("xcopy.exe /VYQK bin\\sandbox\\Logs\\Perf-*.* bin\\toArchive\\sandbox\\Logs\\CodeQuality\\On\\")
+                                }
                             }
                         }
 
@@ -147,12 +153,12 @@ def static getOSGroup(def os) {
                                 builder.setGithubContext("${os} ${arch} ${opt_level} ${jit} CoreCLR Perf Tests")
 
                                 def opts = ""
-                                if (opt_level == 'min_opts') {
+                                if (opt_level == 'min_opt') {
                                     opts = '\\W+min_opts'
                                 }
                                 def jitt = ""
                                 if (jit != 'ryujit') {
-                                    jitt = '\\W+${jit}'
+                                    jitt = "\\W+${jit}"
                                 }
 
                                 builder.triggerOnlyOnComment()
@@ -234,13 +240,13 @@ def static getOSGroup(def os) {
 
                     if (isPR) {
                         def opts = ""
-                        if (opt_level == 'min_opts') {
+                        if (opt_level == 'min_opt') {
                             opts = '\\W+min_opts'
                         }
 
                         def jitt = ""
                         if (jit != 'ryujit') {
-                            jitt = '\\W+${jit}'
+                            jitt = "\\W+${jit}"
                         }
 
                         TriggerBuilder builder = TriggerBuilder.triggerOnPullRequest()
@@ -608,23 +614,10 @@ parallel(
                             batchFile("tests\\runtest.cmd ${configuration} ${architecture} GenerateLayoutOnly")
 
                             def runXUnitPerfCommonArgs = "-arch ${arch} -configuration ${configuration} -generateBenchviewData \"%WORKSPACE%\\Microsoft.Benchview.JSONFormat\\tools\" ${uploadString} -runtype ${runType} ${testEnv} -optLevel ${opt_level} -jitName ${jit} -scenarioTest"
-                            def failedOutputLogFilename = "run-xunit-perf-scenario.log"
-
-                            // Using a sentinel file to
-                            batchFile("if exist \"${failedOutputLogFilename}\" del /q /f \"${failedOutputLogFilename}\"")
-                            batchFile("if exist \"${failedOutputLogFilename}\" (echo [ERROR] Failed to delete previously created \"${failedOutputLogFilename}\" file.& exit /b 1)")
 
                             // Scenario: JitBench
-                            batchFile("tests\\scripts\\run-xunit-perf.cmd ${runXUnitPerfCommonArgs} -testBinLoc bin\\tests\\${os}.${architecture}.${configuration}\\performance\\Scenario\\JitBench -group CoreCLR-Scenarios || (echo [ERROR] JitBench failed. 1>>\"${failedOutputLogFilename}\"& exit /b 0)")
+                            batchFile("tests\\scripts\\run-xunit-perf.cmd ${runXUnitPerfCommonArgs} -testBinLoc bin\\tests\\${os}.${architecture}.${configuration}\\performance\\Scenario\\JitBench -group CoreCLR-Scenarios")
                             batchFile("xcopy.exe /VYQK bin\\sandbox\\Perf-*.* bin\\toArchive\\sandbox\\Logs\\Scenario\\JitBench\\")
-
-                            // Scenario: ILLink
-                            if (arch == 'x64' && opt_level == 'full_opt') {
-                                batchFile("tests\\scripts\\run-xunit-perf.cmd ${runXUnitPerfCommonArgs} -testBinLoc bin\\tests\\${os}.${architecture}.${configuration}\\performance\\linkbench\\linkbench -group ILLink -nowarmup || (echo [ERROR] IlLink failed. 1>>\"${failedOutputLogFilename}\"& exit /b 0)")
-                                batchFile("xcopy.exe /VYQK bin\\sandbox\\Perf-*.* bin\\toArchive\\sandbox\\Logs\\Scenario\\LinkBench\\")
-                            }
-
-                            batchFile("if exist \"${failedOutputLogFilename}\" (type \"${failedOutputLogFilename}\"& exit /b 1)")
                         }
                     }
 
@@ -651,12 +644,12 @@ parallel(
 
                     if (isPR) {
                         def opts = ""
-                        if (opt_level == 'min_opts') {
+                        if (opt_level == 'min_opt') {
                             opts = '\\W+min_opts'
                         }
                         def jitt = ""
                         if (jit != 'ryujit') {
-                            jitt = '\\W+${jit}'
+                            jitt = "\\W+${jit}"
                         }
 
                         TriggerBuilder builder = TriggerBuilder.triggerOnPullRequest()
@@ -677,6 +670,107 @@ parallel(
     }
 }
 
+// Setup CoreCLR-Scenarios tests
+[true, false].each { isPR ->
+    ['Windows_NT'].each { os ->
+        ['x64'].each { arch ->
+            ['ryujit'].each { jit ->
+                ['full_opt'].each { opt_level ->
+                    def architecture = arch
+                    def newJob = job(Utilities.getFullJobName(project, "perf_scenarios_${os}_${arch}_${opt_level}_${jit}", isPR)) {
+
+                        def testEnv = ""
+
+                        // Set the label (currently we are only measuring size, therefore we are running on VM).
+                        label('20170427-elevated')
+                        wrappers {
+                            credentialsBinding {
+                                string('BV_UPLOAD_SAS_TOKEN', 'CoreCLR Perf BenchView Sas')
+                            }
+                        }
+
+                        if (isPR) {
+                            parameters {
+                                stringParam('BenchviewCommitName', '\${ghprbPullTitle}', 'The name that you will be used to build the full title of a run in Benchview.  The final name will be of the form <branch> private BenchviewCommitName')
+                            }
+                        }
+
+                        parameters {
+                            stringParam('XUNIT_PERFORMANCE_MAX_ITERATION', '1', 'Size test, one iteration is sufficient')
+                            stringParam('XUNIT_PERFORMANCE_MAX_ITERATION_INNER_SPECIFIED', '1', 'Size test, one iteration is sufficient')
+                        }
+
+                        def configuration = 'Release'
+                        def runType = isPR ? 'private' : 'rolling'
+                        def benchViewName = isPR ? 'CoreCLR-Scenarios private %BenchviewCommitName%' : 'CoreCLR-Scenarios rolling %GIT_BRANCH_WITHOUT_ORIGIN% %GIT_COMMIT%'
+                        def uploadString = '-uploadToBenchview'
+
+                        steps {
+                            // Batch
+                            batchFile("powershell wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile \"%WORKSPACE%\\nuget.exe\"")
+                            batchFile("if exist \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\" rmdir /s /q \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\"")
+                            batchFile("\"%WORKSPACE%\\nuget.exe\" install Microsoft.BenchView.JSONFormat -Source http://benchviewtestfeed.azurewebsites.net/nuget -OutputDirectory \"%WORKSPACE%\" -Prerelease -ExcludeVersion")
+
+                            //Do this here to remove the origin but at the front of the branch name as this is a problem for BenchView
+                            //we have to do it all as one statement because cmd is called each time and we lose the set environment variable
+                            batchFile("if \"%GIT_BRANCH:~0,7%\" == \"origin/\" (set \"GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH:origin/=%\") else (set \"GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH%\")\n" +
+                            "set \"BENCHVIEWNAME=${benchViewName}\"\n" +
+                            "set \"BENCHVIEWNAME=%BENCHVIEWNAME:\"=%\"\n" +
+                            "py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\submission-metadata.py\" --name \"%BENCHVIEWNAME%\" --user \"dotnet-bot@microsoft.com\"\n" +
+                            "py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\build.py\" git --branch %GIT_BRANCH_WITHOUT_ORIGIN% --type ${runType}")
+                            batchFile("py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\machinedata.py\"")
+                            batchFile("set __TestIntermediateDir=int&&build.cmd ${configuration} ${architecture}")
+
+                            batchFile("tests\\runtest.cmd ${configuration} ${architecture} GenerateLayoutOnly")
+
+                            def runXUnitPerfCommonArgs = "-arch ${arch} -configuration ${configuration} -generateBenchviewData \"%WORKSPACE%\\Microsoft.Benchview.JSONFormat\\tools\" ${uploadString} -runtype ${runType} ${testEnv} -optLevel ${opt_level} -jitName ${jit} -scenarioTest"
+
+                            // Scenario: ILLink
+                            batchFile("tests\\scripts\\run-xunit-perf.cmd ${runXUnitPerfCommonArgs} -testBinLoc bin\\tests\\${os}.${architecture}.${configuration}\\performance\\linkbench\\linkbench -group ILLink -nowarmup")
+                            batchFile("xcopy.exe /VYQK bin\\sandbox\\Perf-*.* bin\\toArchive\\sandbox\\Logs\\Scenario\\LinkBench\\")
+                        }
+                    }
+
+                    def archiveSettings = new ArchivalSettings()
+                    archiveSettings.addFiles('bin/toArchive/**')
+                    archiveSettings.addFiles('machinedata.json')
+
+                    Utilities.addArchival(newJob, archiveSettings)
+                    Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
+
+                    newJob.with {
+                        logRotator {
+                            artifactDaysToKeep(30)
+                            daysToKeep(30)
+                            artifactNumToKeep(200)
+                            numToKeep(200)
+                        }
+                        wrappers {
+                            timeout {
+                                absolute(240)
+                            }
+                        }
+                    }
+
+                    if (isPR) {
+                        TriggerBuilder builder = TriggerBuilder.triggerOnPullRequest()
+                        builder.setGithubContext("${os} ${arch} ${opt_level} ${jit} IlLink Tests")
+                        builder.triggerOnlyOnComment()
+                        builder.setCustomTriggerPhrase("(?i).*test\\W+${os}\\W+${arch}\\W+illink.*")
+                        builder.triggerForBranch(branch)
+                        builder.emitTrigger(newJob)
+                    }
+                    else {
+                        // Set a push trigger
+                        TriggerBuilder builder = TriggerBuilder.triggerOnCommit()
+                        builder.emitTrigger(newJob)
+                    }
+                }
+            }
+        }
+    }
+}
+
 Utilities.createHelperJob(this, project, branch,
     "Welcome to the ${project} Perf help",
     "Have a nice day!")
index c352dcf..619ce09 100644 (file)
@@ -28,23 +28,14 @@ setlocal ENABLEDELAYEDEXPANSION
   call :parse_command_line_arguments %*
   if defined USAGE_DISPLAYED exit /b %ERRORLEVEL%
 
-  call :set_test_architecture  || exit /b 1
-  call :set_collection_config  || exit /b 1
-  call :verify_benchview_tools || exit /b 1
-  call :verify_core_overlay    || exit /b 1
-  call :set_perf_run_log       || exit /b 1
-  call :setup_sandbox          || exit /b 1
+  call :set_test_architecture   || exit /b 1
+  call :set_collection_config   || exit /b 1
+  call :verify_benchview_tools  || exit /b 1
+  call :verify_core_overlay     || exit /b 1
+  call :set_perf_run_log        || exit /b 1
+  call :setup_sandbox           || exit /b 1
+  call :build_perfharness       || exit /b 1
 
-  call :run_cmd "%CORECLR_REPO%\Tools\dotnetcli\dotnet.exe" restore "%CORECLR_REPO%\tests\src\Common\PerfHarness\PerfHarness.csproj" || (
-    call :print_error Failed to restore PerfHarness.csproj
-    exit /b 1
-  )
-  call :run_cmd "%CORECLR_REPO%\Tools\dotnetcli\dotnet.exe" publish "%CORECLR_REPO%\tests\src\Common\PerfHarness\PerfHarness.csproj" -c Release -o "%LV_SANDBOX_DIR%" || (
-    call :print_error Failed to publish PerfHarness.csproj
-    exit /b 1
-  )
-
-  rem TODO: Remove the version of the package to copy. e.g.) if multiple version exist, then error out?
   call :run_cmd xcopy /sy "%CORECLR_REPO%\bin\tests\Windows_NT.%TEST_ARCH%.%TEST_CONFIG%\Tests\Core_Root"\* . >> %RUNLOG% || exit /b 1
 
   rem find and stage the tests
@@ -295,7 +286,6 @@ rem ****************************************************************************
   )
   exit /b 0
 
-
 :set_perf_run_log
 rem ****************************************************************************
 rem   Sets the script's output log file.
@@ -335,6 +325,20 @@ rem ****************************************************************************
   cd "%LV_SANDBOX_DIR%"
   exit /b %ERRORLEVEL%
 
+:build_perfharness
+rem ****************************************************************************
+rem   Restores and publish the PerfHarness.
+rem ****************************************************************************
+  call :run_cmd "%CORECLR_REPO%\Tools\dotnetcli\dotnet.exe" restore "%CORECLR_REPO%\tests\src\Common\PerfHarness\PerfHarness.csproj" || (
+    call :print_error Failed to restore PerfHarness.csproj
+    exit /b 1
+  )
+  call :run_cmd "%CORECLR_REPO%\Tools\dotnetcli\dotnet.exe" publish "%CORECLR_REPO%\tests\src\Common\PerfHarness\PerfHarness.csproj" -c Release -o "%LV_SANDBOX_DIR%" || (
+    call :print_error Failed to publish PerfHarness.csproj
+    exit /b 1
+  )
+  exit /b 0
+
 :generate_results_for_benchview
 rem ****************************************************************************
 rem   Generates results for BenchView, by appending new data to the existing
@@ -356,7 +360,8 @@ rem ****************************************************************************
   rem Currently xUnit Performance Api saves the scenario output
   rem   files on the current working directory.
   set LV_PATTERN="%LV_BENCHMARKS_OUTPUT_DIR%\%LV_RUNID%-%BENCHNAME%.xml"
-  if defined IS_SCENARIO_TEST set LV_PATTERN="%LV_RUNID%-*-%BENCHNAME%.xml"
+  rem The first pattern is the general case, the second is used by IlLink
+  if defined IS_SCENARIO_TEST set LV_PATTERN="%LV_RUNID%-%BENCHNAME%.xml" "%LV_RUNID%-*-%BENCHNAME%.xml"
 
   for %%f in (%LV_PATTERN%) do (
     call :run_cmd py.exe "%BENCHVIEW_PATH%\measurement.py" %LV_MEASUREMENT_ARGS% "%%~f"
index 51a3be2..9c00fbf 100644 (file)
@@ -249,7 +249,7 @@ namespace JitBench
 
         private const string MusicStoreRedirectedStandardOutputFileName = "measures.txt";
         private const string JitBenchRepoUrl = "https://github.com/aspnet/JitBench";
-        private const string JitBenchCommitSha1Id = "a44cd96e4ff8d7c1b43fe3c96a597919bb1544bd";
+        private const string JitBenchCommitSha1Id = "f4a56adc31e08368ef927c4273eded38e158646b";
         private const string JitBenchTargetFramework = "netcoreapp2.0";
 
         private static void PostIteration()