1 // Import the utility functionality.
3 import jobs.generation.*;
5 def project = GithubProject
6 def branch = GithubBranchName
7 def projectName = Utilities.getFolderName(project)
8 def projectFolder = projectName + '/' + Utilities.getFolderName(branch)
10 def static getOSGroup(def os) {
11 def osGroupMap = ['Ubuntu14.04':'Linux',
13 'Ubuntu16.04': 'Linux',
17 'Windows_NT':'Windows_NT',
20 'OpenSUSE13.2': 'Linux',
21 'OpenSUSE42.1': 'Linux',
22 'LinuxARMEmulator': 'Linux']
23 def osGroup = osGroupMap.get(os, null)
24 assert osGroup != null : "Could not find os group for ${os}"
28 // Setup perflab tests runs
29 [true, false].each { isPR ->
30 ['Windows_NT'].each { os ->
31 ['x64', 'x86'].each { arch ->
32 ['ryujit'].each { jit ->
33 if (arch == 'x64' && jit == 'legacy_backend') {
37 ['full_opt', 'min_opt'].each { opt_level ->
39 def architecture = arch
40 def jobName = "perf_perflab_${os}_${arch}_${opt_level}_${jit}"
43 if (jit == 'legacy_backend') {
44 testEnv = '-testEnv %WORKSPACE%\\tests\\legacyjit_x86_testenv.cmd'
47 def newJob = job(Utilities.getFullJobName(project, jobName, isPR)) {
49 label('windows_server_2016_clr_perf')
52 string('BV_UPLOAD_SAS_TOKEN', 'CoreCLR Perf BenchView Sas')
58 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')
63 stringParam('XUNIT_PERFORMANCE_MAX_ITERATION', '21', 'Sets the number of iterations to twenty one. We are doing this to limit the amount of data that we upload as 20 iterations is enough to get a good sample')
64 stringParam('XUNIT_PERFORMANCE_MAX_ITERATION_INNER_SPECIFIED', '21', 'Sets the number of iterations to twenty one. We are doing this to limit the amount of data that we upload as 20 iterations is enough to get a good sample')
67 def configuration = 'Release'
68 def runType = isPR ? 'private' : 'rolling'
69 def benchViewName = isPR ? 'coreclr private %BenchviewCommitName%' : 'coreclr rolling %GIT_BRANCH_WITHOUT_ORIGIN% %GIT_COMMIT%'
70 def uploadString = '-uploadToBenchview'
75 batchFile("powershell wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile \"%WORKSPACE%\\nuget.exe\"")
76 batchFile("if exist \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\" rmdir /s /q \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\"")
77 batchFile("\"%WORKSPACE%\\nuget.exe\" install Microsoft.BenchView.JSONFormat -Source http://benchviewtestfeed.azurewebsites.net/nuget -OutputDirectory \"%WORKSPACE%\" -Prerelease -ExcludeVersion")
78 //Do this here to remove the origin but at the front of the branch name as this is a problem for BenchView
79 //we have to do it all as one statement because cmd is called each time and we lose the set environment variable
80 batchFile("if \"%GIT_BRANCH:~0,7%\" == \"origin/\" (set \"GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH:origin/=%\") else (set \"GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH%\")\n" +
81 "set \"BENCHVIEWNAME=${benchViewName}\"\n" +
82 "set \"BENCHVIEWNAME=%BENCHVIEWNAME:\"=\"\"%\"\n" +
83 "py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\submission-metadata.py\" --name \"%BENCHVIEWNAME%\" --user-email \"dotnet-bot@microsoft.com\"\n" +
84 "py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\build.py\" git --branch %GIT_BRANCH_WITHOUT_ORIGIN% --type ${runType}")
85 batchFile("py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\machinedata.py\"")
86 batchFile("set __TestIntermediateDir=int&&build.cmd ${configuration} ${architecture}")
88 batchFile("tests\\runtest.cmd ${configuration} ${architecture} GenerateLayoutOnly")
90 def runXUnitPerfCommonArgs = "-arch ${arch} -configuration ${configuration} -generateBenchviewData \"%WORKSPACE%\\Microsoft.Benchview.JSONFormat\\tools\" ${uploadString} -runtype ${runType} ${testEnv} -optLevel ${opt_level} -jitName ${jit} -outputdir \"%WORKSPACE%\\bin\\sandbox_logs\" -stabilityPrefix \"START \"CORECLR_PERF_RUN\" /B /WAIT /HIGH /AFFINITY 0x2\""
92 // Run with just stopwatch: Profile=Off
93 batchFile("tests\\scripts\\run-xunit-perf.cmd ${runXUnitPerfCommonArgs} -testBinLoc bin\\tests\\${os}.${architecture}.${configuration}\\performance\\perflab\\Perflab -library")
94 batchFile("tests\\scripts\\run-xunit-perf.cmd ${runXUnitPerfCommonArgs} -testBinLoc bin\\tests\\${os}.${architecture}.${configuration}\\Jit\\Performance\\CodeQuality")
96 // Run with the full set of counters enabled: Profile=On
97 if (opt_level != 'min_opt') {
98 batchFile("tests\\scripts\\run-xunit-perf.cmd ${runXUnitPerfCommonArgs} -testBinLoc bin\\tests\\${os}.${architecture}.${configuration}\\performance\\perflab\\Perflab -library -collectionFlags default+BranchMispredictions+CacheMisses+InstructionRetired+gcapi")
99 batchFile("tests\\scripts\\run-xunit-perf.cmd ${runXUnitPerfCommonArgs} -testBinLoc bin\\tests\\${os}.${architecture}.${configuration}\\Jit\\Performance\\CodeQuality -collectionFlags default+BranchMispredictions+CacheMisses+InstructionRetired+gcapi")
104 def archiveSettings = new ArchivalSettings()
105 archiveSettings.addFiles('bin/sandbox_logs/**')
106 archiveSettings.addFiles('machinedata.json')
108 Utilities.addArchival(newJob, archiveSettings)
109 Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
113 artifactDaysToKeep(30)
115 artifactNumToKeep(200)
126 TriggerBuilder builder = TriggerBuilder.triggerOnPullRequest()
127 builder.setGithubContext("${os} ${arch} ${opt_level} ${jit} CoreCLR Perf Tests")
130 if (opt_level == 'min_opt') {
131 opts = '\\W+min_opts'
134 if (jit != 'ryujit') {
138 builder.triggerOnlyOnComment()
139 builder.setCustomTriggerPhrase("(?i).*test\\W+${os}\\W+${arch}${opts}${jitt}\\W+perf.*")
140 builder.triggerForBranch(branch)
141 builder.emitTrigger(newJob)
144 // Set a push trigger
145 TriggerBuilder builder = TriggerBuilder.triggerOnCommit()
146 builder.emitTrigger(newJob)
154 // Setup throughput perflab tests runs
155 [true, false].each { isPR ->
156 ['Windows_NT'].each { os ->
157 ['x64', 'x86'].each { arch ->
158 ['ryujit', 'legacy_backend'].each { jit ->
159 [true, false].each { pgo_optimized ->
160 if (arch == 'x64' && jit == 'legacy_backend') {
164 // pgo not supported for legacy_backend
165 if (pgo_optimized && jit == 'legacy_backend') {
169 ['full_opt', 'min_opt'].each { opt_level ->
170 def architecture = arch
175 if (!pgo_optimized) {
176 pgo_build = " -nopgooptimize"
181 def newJob = job(Utilities.getFullJobName(project, "perf_throughput_perflab_${os}_${arch}_${opt_level}_${jit}_${pgo_string}", isPR)) {
183 label('windows_server_2016_clr_perf')
186 string('BV_UPLOAD_SAS_TOKEN', 'CoreCLR Perf BenchView Sas')
192 stringParam('BenchviewCommitName', '\${ghprbPullTitle}', 'The name that will be used to build the full title of a run in Benchview.')
196 def configuration = 'Release'
197 def runType = isPR ? 'private' : 'rolling'
198 def benchViewName = isPR ? 'coreclr-throughput private %BenchviewCommitName%' : 'coreclr-throughput rolling %GIT_BRANCH_WITHOUT_ORIGIN% %GIT_COMMIT%'
202 batchFile("if exist \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\" rmdir /s /q \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\"")
203 batchFile("if exist \"%WORKSPACE%\\Microsoft.BenchView.ThroughputBenchmarks.${architecture}.${os}\" rmdir /s /q \"%WORKSPACE%\\Microsoft.BenchView.ThroughputBenchmarks.${architecture}.${os}\"")
204 batchFile("C:\\Tools\\nuget.exe install Microsoft.BenchView.JSONFormat -Source http://benchviewtestfeed.azurewebsites.net/nuget -OutputDirectory \"%WORKSPACE%\" -Prerelease -ExcludeVersion")
205 batchFile("C:\\Tools\\nuget.exe install Microsoft.BenchView.ThroughputBenchmarks.${architecture}.${os} -Source https://dotnet.myget.org/F/dotnet-core -OutputDirectory \"%WORKSPACE%\" -Prerelease -ExcludeVersion")
206 //Do this here to remove the origin but at the front of the branch name as this is a problem for BenchView
207 //we have to do it all as one statement because cmd is called each time and we lose the set environment variable
208 batchFile("if \"%GIT_BRANCH:~0,7%\" == \"origin/\" (set \"GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH:origin/=%\") else (set \"GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH%\")\n" +
209 "set \"BENCHVIEWNAME=${benchViewName}\"\n" +
210 "set \"BENCHVIEWNAME=%BENCHVIEWNAME:\"=\"\"%\"\n" +
211 "py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\submission-metadata.py\" --name \"${benchViewName}\" --user-email \"dotnet-bot@microsoft.com\"\n" +
212 "py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\build.py\" git --branch %GIT_BRANCH_WITHOUT_ORIGIN% --type ${runType}")
213 batchFile("py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\machinedata.py\"")
214 batchFile("set __TestIntermediateDir=int&&build.cmd ${configuration} ${architecture}${pgo_build} skiptests")
215 batchFile("tests\\runtest.cmd ${configuration} ${architecture} GenerateLayoutOnly")
216 batchFile("py -u tests\\scripts\\run-throughput-perf.py -arch ${arch} -os ${os} -configuration ${configuration} -opt_level ${opt_level} -jit_name ${jit}${pgo_test} -clr_root \"%WORKSPACE%\" -assembly_root \"%WORKSPACE%\\Microsoft.BenchView.ThroughputBenchmarks.${architecture}.${os}\\lib\" -benchview_path \"%WORKSPACE%\\Microsoft.Benchview.JSONFormat\\tools\" -run_type ${runType}")
220 // Save machinedata.json to /artifact/bin/ Jenkins dir
221 def archiveSettings = new ArchivalSettings()
222 archiveSettings.addFiles('throughput-*.csv')
223 Utilities.addArchival(newJob, archiveSettings)
225 Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
229 if (opt_level == 'min_opt') {
230 opts = '\\W+min_opts'
234 if (jit != 'ryujit') {
240 pgo_trigger = "\\W+nopgo"
244 TriggerBuilder builder = TriggerBuilder.triggerOnPullRequest()
245 builder.setGithubContext("${os} ${arch} ${opt_level} ${jit} ${pgo_string} CoreCLR Throughput Perf Tests")
246 builder.triggerOnlyOnComment()
247 builder.setCustomTriggerPhrase("(?i).*test\\W+${os}\\W+${arch}${opts}${jitt}${pgo_trigger}\\W+throughput.*")
248 builder.triggerForBranch(branch)
249 builder.emitTrigger(newJob)
252 // Set a push trigger
253 TriggerBuilder builder = TriggerBuilder.triggerOnCommit()
254 builder.emitTrigger(newJob)
263 def static getFullPerfJobName(def project, def os, def isPR) {
264 return Utilities.getFullJobName(project, "perf_${os}", isPR)
267 // Create the Linux/OSX/CentOS coreclr test leg for debug and release and each scenario
268 [true, false].each { isPR ->
269 def fullBuildJobName = Utilities.getFullJobName(project, 'perf_linux_build', isPR)
270 def architecture = 'x64'
271 def configuration = 'Release'
273 // Build has to happen on RHEL7.2 (that's where we produce the bits we ship)
274 ['RHEL7.2'].each { os ->
275 def newBuildJob = job(fullBuildJobName) {
277 shell("./build.sh verbose ${architecture} ${configuration}")
280 Utilities.setMachineAffinity(newBuildJob, os, 'latest-or-auto')
281 Utilities.standardJobSetup(newBuildJob, project, isPR, "*/${branch}")
282 Utilities.addArchival(newBuildJob, "bin/Product/**,bin/obj/*/tests/**/*.dylib,bin/obj/*/tests/**/*.so", "bin/Product/**/.nuget/**")
286 // Actual perf testing on the following OSes
287 def perfOSList = ['Ubuntu14.04']
288 perfOSList.each { os ->
289 def newJob = job(getFullPerfJobName(project, os, isPR)) {
291 label('linux_clr_perf')
294 string('BV_UPLOAD_SAS_TOKEN', 'CoreCLR Perf BenchView Sas')
300 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')
305 // Cap the maximum number of iterations to 21.
306 stringParam('XUNIT_PERFORMANCE_MAX_ITERATION', '21', 'Sets the number of iterations to twenty one. We are doing this to limit the amount of data that we upload as 20 iterations is enough to get a good sample')
307 stringParam('XUNIT_PERFORMANCE_MAX_ITERATION_INNER_SPECIFIED', '21', 'Sets the number of iterations to twenty one. We are doing this to limit the amount of data that we upload as 20 iterations is enough to get a good sample')
308 stringParam('PRODUCT_BUILD', '', 'Build number from which to copy down the CoreCLR Product binaries built for Linux')
311 def osGroup = getOSGroup(os)
312 def runType = isPR ? 'private' : 'rolling'
313 def benchViewName = isPR ? 'coreclr private \$BenchviewCommitName' : 'coreclr rolling \$GIT_BRANCH_WITHOUT_ORIGIN \$GIT_COMMIT'
316 shell("./tests/scripts/perf-prep.sh")
317 shell("./init-tools.sh")
318 copyArtifacts(fullBuildJobName) {
319 includePatterns("bin/**")
321 buildNumber('\${PRODUCT_BUILD}')
324 shell("GIT_BRANCH_WITHOUT_ORIGIN=\$(echo \$GIT_BRANCH | sed \"s/[^/]*\\/\\(.*\\)/\\1 /\")\n" +
325 "python3.5 \"\${WORKSPACE}/tests/scripts/Microsoft.BenchView.JSONFormat/tools/submission-metadata.py\" --name \" ${benchViewName} \" --user-email \"dotnet-bot@microsoft.com\"\n" +
326 "python3.5 \"\${WORKSPACE}/tests/scripts/Microsoft.BenchView.JSONFormat/tools/build.py\" git --branch \$GIT_BRANCH_WITHOUT_ORIGIN --type ${runType}")
327 shell("""./tests/scripts/run-xunit-perf.sh \\
328 --testRootDir=\"\${WORKSPACE}/bin/tests/Windows_NT.${architecture}.${configuration}\" \\
329 --testNativeBinDir=\"\${WORKSPACE}/bin/obj/${osGroup}.${architecture}.${configuration}/tests\" \\
330 --coreClrBinDir=\"\${WORKSPACE}/bin/Product/${osGroup}.${architecture}.${configuration}\" \\
331 --mscorlibDir=\"\${WORKSPACE}/bin/Product/${osGroup}.${architecture}.${configuration}\" \\
332 --coreFxBinDir=\"\${WORKSPACE}/corefx\" \\
333 --runType=\"${runType}\" \\
334 --benchViewOS=\"${os}\" \\
335 --generatebenchviewdata=\"\${WORKSPACE}/tests/scripts/Microsoft.BenchView.JSONFormat/tools\" \\
336 --stabilityPrefix=\"taskset 0x00000002 nice --adjustment=-10\" \\
337 --uploadToBenchview""")
338 shell("mkdir -p bin/toArchive/sandbox/Logs/")
339 shell("rsync -a bin/sandbox/Logs/Perf-*.* bin/toArchive/sandbox/Logs/")
343 def archiveSettings = new ArchivalSettings()
344 archiveSettings.addFiles('bin/toArchive/**')
345 archiveSettings.addFiles('machinedata.json')
347 Utilities.addArchival(newJob, archiveSettings)
348 Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
350 // For perf, we need to keep the run results longer
352 // Enable the log rotator
354 artifactDaysToKeep(30)
356 artifactNumToKeep(200)
367 def flowJobPerfRunList = perfOSList.collect { os ->
368 "{ build(params + [PRODUCT_BUILD: b.build.number], '${getFullPerfJobName(project, os, isPR)}') }"
370 def newFlowJob = buildFlowJob(Utilities.getFullJobName(project, "perf_linux_flow", isPR, '')) {
373 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')
377 // First, build the bits on RHEL7.2
378 b = build(params, '${fullBuildJobName}')
380 // Then, run the perf tests
382 ${flowJobPerfRunList.join(",\n ")}
387 Utilities.setMachineAffinity(newFlowJob, 'Windows_NT', 'latest-or-auto')
388 Utilities.standardJobSetup(newFlowJob, project, isPR, "*/${branch}")
391 TriggerBuilder builder = TriggerBuilder.triggerOnPullRequest()
392 builder.setGithubContext("Linux Perf Test Flow")
393 builder.triggerOnlyOnComment()
394 builder.setCustomTriggerPhrase("(?i).*test\\W+linux\\W+perf\\W+flow.*")
395 builder.triggerForBranch(branch)
396 builder.emitTrigger(newFlowJob)
399 // Set a push trigger
400 TriggerBuilder builder = TriggerBuilder.triggerOnCommit()
401 builder.emitTrigger(newFlowJob)
406 def static getFullThroughputJobName(def project, def os, def isPR) {
407 return Utilities.getFullJobName(project, "perf_throughput_${os}", isPR)
410 // Create the Linux/OSX/CentOS coreclr test leg for debug and release and each scenario
411 [true, false].each { isPR ->
412 def fullBuildJobName = Utilities.getFullJobName(project, 'perf_throughput_linux_build', isPR)
413 def architecture = 'x64'
414 def configuration = 'Release'
416 // Build has to happen on RHEL7.2 (that's where we produce the bits we ship)
417 ['RHEL7.2'].each { os ->
418 def newBuildJob = job(fullBuildJobName) {
420 shell("./build.sh verbose ${architecture} ${configuration}")
423 Utilities.setMachineAffinity(newBuildJob, os, 'latest-or-auto')
424 Utilities.standardJobSetup(newBuildJob, project, isPR, "*/${branch}")
425 Utilities.addArchival(newBuildJob, "bin/Product/**")
428 // Actual perf testing on the following OSes
429 def throughputOSList = ['Ubuntu14.04']
430 def throughputOptLevelList = ['full_opt', 'min_opt']
432 def throughputOSOptLevelList = []
434 throughputOSList.each { os ->
435 throughputOptLevelList.each { opt_level ->
436 throughputOSOptLevelList.add("${os}_${opt_level}")
440 throughputOSList.each { os ->
441 throughputOptLevelList.each { opt_level ->
442 def newJob = job(getFullThroughputJobName(project, "${os}_${opt_level}", isPR)) {
444 label('linux_clr_perf')
447 string('BV_UPLOAD_SAS_TOKEN', 'CoreCLR Perf BenchView Sas')
453 stringParam('BenchviewCommitName', '\${ghprbPullTitle}', 'The name that will be used to build the full title of a run in Benchview.')
458 stringParam('PRODUCT_BUILD', '', 'Build number from which to copy down the CoreCLR Product binaries built for Linux')
461 def osGroup = getOSGroup(os)
462 def runType = isPR ? 'private' : 'rolling'
463 def benchViewName = isPR ? 'coreclr-throughput private \$BenchviewCommitName' : 'coreclr-throughput rolling \$GIT_BRANCH_WITHOUT_ORIGIN \$GIT_COMMIT'
466 shell("bash ./tests/scripts/perf-prep.sh --throughput")
467 shell("./init-tools.sh")
468 copyArtifacts(fullBuildJobName) {
469 includePatterns("bin/Product/**")
471 buildNumber('\${PRODUCT_BUILD}')
474 shell("GIT_BRANCH_WITHOUT_ORIGIN=\$(echo \$GIT_BRANCH | sed \"s/[^/]*\\/\\(.*\\)/\\1 /\")\n" +
475 "python3.5 \"\${WORKSPACE}/tests/scripts/Microsoft.BenchView.JSONFormat/tools/submission-metadata.py\" --name \" ${benchViewName} \" --user-email \"dotnet-bot@microsoft.com\"\n" +
476 "python3.5 \"\${WORKSPACE}/tests/scripts/Microsoft.BenchView.JSONFormat/tools/build.py\" git --branch \$GIT_BRANCH_WITHOUT_ORIGIN --type ${runType}")
477 shell("""python3.5 ./tests/scripts/run-throughput-perf.py \\
478 -arch \"${architecture}\" \\
480 -configuration \"${configuration}\" \\
481 -opt_level \"${opt_level}\" \\
482 -clr_root \"\${WORKSPACE}\" \\
483 -assembly_root \"\${WORKSPACE}/Microsoft.Benchview.ThroughputBenchmarks.${architecture}.Windows_NT/lib\" \\
484 -run_type \"${runType}\" \\
485 -benchview_path \"\${WORKSPACE}/tests/scripts/Microsoft.BenchView.JSONFormat/tools\"""")
489 // Save machinedata.json to /artifact/bin/ Jenkins dir
490 def archiveSettings = new ArchivalSettings()
491 archiveSettings.addFiles('throughput-*.csv')
492 archiveSettings.addFiles('machinedata.json')
493 Utilities.addArchival(newJob, archiveSettings)
495 Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
497 // For perf, we need to keep the run results longer
499 // Enable the log rotator
501 artifactDaysToKeep(7)
503 artifactNumToKeep(25)
510 def flowJobTPRunList = throughputOSOptLevelList.collect { os ->
511 "{ build(params + [PRODUCT_BUILD: b.build.number], '${getFullThroughputJobName(project, os, isPR)}') }"
513 def newFlowJob = buildFlowJob(Utilities.getFullJobName(project, "perf_throughput_linux_flow", isPR, '')) {
516 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')
520 // First, build the bits on RHEL7.2
521 b = build(params, '${fullBuildJobName}')
523 // Then, run the perf tests
525 ${flowJobTPRunList.join(",\n ")}
530 Utilities.setMachineAffinity(newFlowJob, 'Windows_NT', 'latest-or-auto')
531 Utilities.standardJobSetup(newFlowJob, project, isPR, "*/${branch}")
534 TriggerBuilder builder = TriggerBuilder.triggerOnPullRequest()
535 builder.setGithubContext("Linux Throughput Perf Test Flow")
536 builder.triggerOnlyOnComment()
537 builder.setCustomTriggerPhrase("(?i).*test\\W+linux\\W+throughput\\W+flow.*")
538 builder.triggerForBranch(branch)
539 builder.emitTrigger(newFlowJob)
542 // Set a push trigger
543 TriggerBuilder builder = TriggerBuilder.triggerOnCommit()
544 builder.emitTrigger(newFlowJob)
549 // Setup CoreCLR-Scenarios tests
550 [true, false].each { isPR ->
551 ['Windows_NT'].each { os ->
552 ['x64', 'x86'].each { arch ->
553 ['ryujit'].each { jit ->
554 ['full_opt', 'min_opt', 'tiered'].each { opt_level ->
555 def architecture = arch
556 def newJob = job(Utilities.getFullJobName(project, "perf_scenarios_${os}_${arch}_${opt_level}_${jit}", isPR)) {
561 label('windows_server_2016_clr_perf')
564 string('BV_UPLOAD_SAS_TOKEN', 'CoreCLR Perf BenchView Sas')
570 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')
575 stringParam('XUNIT_PERFORMANCE_MAX_ITERATION', '1', 'Size test, one iteration is sufficient')
576 stringParam('XUNIT_PERFORMANCE_MAX_ITERATION_INNER_SPECIFIED', '1', 'Size test, one iteration is sufficient')
579 def configuration = 'Release'
580 def runType = isPR ? 'private' : 'rolling'
581 def benchViewName = isPR ? 'CoreCLR-Scenarios private %BenchviewCommitName%' : 'CoreCLR-Scenarios rolling %GIT_BRANCH_WITHOUT_ORIGIN% %GIT_COMMIT%'
582 def uploadString = '-uploadToBenchview'
586 batchFile("powershell wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile \"%WORKSPACE%\\nuget.exe\"")
587 batchFile("if exist \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\" rmdir /s /q \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\"")
588 batchFile("\"%WORKSPACE%\\nuget.exe\" install Microsoft.BenchView.JSONFormat -Source http://benchviewtestfeed.azurewebsites.net/nuget -OutputDirectory \"%WORKSPACE%\" -Prerelease -ExcludeVersion")
590 //Do this here to remove the origin but at the front of the branch name as this is a problem for BenchView
591 //we have to do it all as one statement because cmd is called each time and we lose the set environment variable
592 batchFile("if \"%GIT_BRANCH:~0,7%\" == \"origin/\" (set \"GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH:origin/=%\") else (set \"GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH%\")\n" +
593 "set \"BENCHVIEWNAME=${benchViewName}\"\n" +
594 "set \"BENCHVIEWNAME=%BENCHVIEWNAME:\"=\"\"%\"\n" +
595 "py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\submission-metadata.py\" --name \"%BENCHVIEWNAME%\" --user-email \"dotnet-bot@microsoft.com\"\n" +
596 "py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\build.py\" git --branch %GIT_BRANCH_WITHOUT_ORIGIN% --type ${runType}")
597 batchFile("py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\machinedata.py\"")
598 batchFile("set __TestIntermediateDir=int&&build.cmd ${configuration} ${architecture}")
600 batchFile("tests\\runtest.cmd ${configuration} ${architecture} GenerateLayoutOnly")
602 def runXUnitPerfCommonArgs = "-arch ${arch} -configuration ${configuration} -generateBenchviewData \"%WORKSPACE%\\Microsoft.Benchview.JSONFormat\\tools\" ${uploadString} -runtype ${runType} ${testEnv} -optLevel ${opt_level} -jitName ${jit} -outputdir \"%WORKSPACE%\\bin\\sandbox_logs\" -stabilityPrefix \"START \"CORECLR_PERF_RUN\" /B /WAIT /HIGH\" -scenarioTest"
605 batchFile("tests\\scripts\\run-xunit-perf.cmd ${runXUnitPerfCommonArgs} -testBinLoc bin\\tests\\${os}.${architecture}.${configuration}\\performance\\Scenario\\JitBench -group CoreCLR-Scenarios")
608 if (opt_level != 'min_opt') {
609 batchFile("tests\\scripts\\run-xunit-perf.cmd ${runXUnitPerfCommonArgs} -testBinLoc bin\\tests\\${os}.${architecture}.${configuration}\\performance\\Scenario\\JitBench -group CoreCLR-Scenarios -collectionFlags BranchMispredictions+CacheMisses+InstructionRetired")
614 def archiveSettings = new ArchivalSettings()
615 archiveSettings.addFiles('bin/sandbox_logs/**')
616 archiveSettings.addFiles('machinedata.json')
618 Utilities.addArchival(newJob, archiveSettings)
619 Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
623 artifactDaysToKeep(30)
625 artifactNumToKeep(200)
637 if (opt_level == 'min_opt') {
638 opts = '\\W+min_opts'
641 if (jit != 'ryujit') {
645 TriggerBuilder builder = TriggerBuilder.triggerOnPullRequest()
646 builder.setGithubContext("${os} ${arch} ${opt_level} ${jit} Performance Scenarios Tests")
647 builder.triggerOnlyOnComment()
648 builder.setCustomTriggerPhrase("(?i).*test\\W+${os}\\W+${arch}${opts}${jitt}\\W+perf\\W+scenarios.*")
649 builder.triggerForBranch(branch)
650 builder.emitTrigger(newJob)
653 // Set a push trigger
654 TriggerBuilder builder = TriggerBuilder.triggerOnCommit()
655 builder.emitTrigger(newJob)
663 // Setup size-on-disk test
664 ['Windows_NT'].each { os ->
665 ['x64', 'x86'].each { arch ->
666 def architecture = arch
667 def newJob = job(Utilities.getFullJobName(project, "sizeondisk_${arch}", false)) {
671 string('BV_UPLOAD_SAS_TOKEN', 'CoreCLR Perf BenchView Sas')
675 def channel = 'master'
676 def configuration = 'Release'
677 def runType = 'rolling'
678 def benchViewName = 'Dotnet Size on Disk %DATE% %TIME%'
679 def testBin = "%WORKSPACE%\\bin\\tests\\${os}.${architecture}.${configuration}"
680 def coreRoot = "${testBin}\\Tests\\Core_Root"
681 def benchViewTools = "%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools"
684 // Install nuget and get BenchView tools
685 batchFile("powershell wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile \"%WORKSPACE%\\nuget.exe\"")
686 batchFile("if exist \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\" rmdir /s /q \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\"")
687 batchFile("\"%WORKSPACE%\\nuget.exe\" install Microsoft.BenchView.JSONFormat -Source http://benchviewtestfeed.azurewebsites.net/nuget -OutputDirectory \"%WORKSPACE%\" -Prerelease -ExcludeVersion")
689 // Generate submission metadata for BenchView
690 // Do this here to remove the origin but at the front of the branch name as this is a problem for BenchView
691 // we have to do it all as one statement because cmd is called each time and we lose the set environment variable
692 batchFile("if \"%GIT_BRANCH:~0,7%\" == \"origin/\" (set \"GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH:origin/=%\") else (set \"GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH%\")\n" +
693 "set \"BENCHVIEWNAME=${benchViewName}\"\n" +
694 "set \"BENCHVIEWNAME=%BENCHVIEWNAME:\"=\"\"%\"\n" +
695 "py \"${benchViewTools}\\submission-metadata.py\" --name \"%BENCHVIEWNAME%\" --user-email \"dotnet-bot@microsoft.com\"\n" +
696 "py \"${benchViewTools}\\build.py\" git --branch %GIT_BRANCH_WITHOUT_ORIGIN% --type ${runType}")
698 // Generate machine data from BenchView
699 batchFile("py \"${benchViewTools}\\machinedata.py\"")
701 // Build CoreCLR and gnerate test layout
702 batchFile("set __TestIntermediateDir=int&&build.cmd ${configuration} ${architecture}")
703 batchFile("tests\\runtest.cmd ${configuration} ${architecture} GenerateLayoutOnly")
705 // Run the size on disk benchmark
706 batchFile("\"${coreRoot}\\CoreRun.exe\" \"${testBin}\\sizeondisk\\sodbench\\SoDBench\\SoDBench.exe\" -o \"%WORKSPACE%\\sodbench.csv\" --architecture ${arch} --channel ${channel}")
708 // From sodbench.csv, create measurment.json, then submission.json
709 batchFile("py \"${benchViewTools}\\measurement.py\" csv \"%WORKSPACE%\\sodbench.csv\" --metric \"Size on Disk\" --unit \"bytes\" --better \"desc\"")
710 batchFile("py \"${benchViewTools}\\submission.py\" measurement.json --build build.json --machine-data machinedata.json --metadata submission-metadata.json --group \"Dotnet Size on Disk\" --type ${runType} --config-name ${configuration} --architecture ${arch} --machinepool VM --config Channel ${channel}")
712 // If this is a PR, upload submission.json
713 batchFile("py \"${benchViewTools}\\upload.py\" submission.json --container coreclr")
717 Utilities.setMachineAffinity(newJob, "Windows_NT", '20170427-elevated')
719 def archiveSettings = new ArchivalSettings()
720 archiveSettings.addFiles('bin/toArchive/**')
721 archiveSettings.addFiles('machinedata.json')
723 Utilities.addArchival(newJob, archiveSettings)
724 Utilities.standardJobSetup(newJob, project, false, "*/${branch}")
726 // Set the cron job here. We run nightly on each flavor, regardless of code changes
727 Utilities.addPeriodicTrigger(newJob, "@daily", true /*always run*/)
731 artifactDaysToKeep(30)
733 artifactNumToKeep(200)
745 // Setup IlLink tests
746 [true, false].each { isPR ->
747 ['Windows_NT'].each { os ->
748 ['x64'].each { arch ->
749 ['ryujit'].each { jit ->
750 ['full_opt'].each { opt_level ->
751 def architecture = arch
752 def newJob = job(Utilities.getFullJobName(project, "perf_illink_${os}_${arch}_${opt_level}_${jit}", isPR)) {
757 string('BV_UPLOAD_SAS_TOKEN', 'CoreCLR Perf BenchView Sas')
763 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')
768 stringParam('XUNIT_PERFORMANCE_MAX_ITERATION', '1', 'Size test, one iteration is sufficient')
769 stringParam('XUNIT_PERFORMANCE_MAX_ITERATION_INNER_SPECIFIED', '1', 'Size test, one iteration is sufficient')
772 def configuration = 'Release'
773 def runType = isPR ? 'private' : 'rolling'
774 def benchViewName = isPR ? 'CoreCLR-Scenarios private %BenchviewCommitName%' : 'CoreCLR-Scenarios rolling %GIT_BRANCH_WITHOUT_ORIGIN% %GIT_COMMIT%'
775 def uploadString = '-uploadToBenchview'
779 batchFile("powershell wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile \"%WORKSPACE%\\nuget.exe\"")
780 batchFile("if exist \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\" rmdir /s /q \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\"")
781 batchFile("\"%WORKSPACE%\\nuget.exe\" install Microsoft.BenchView.JSONFormat -Source http://benchviewtestfeed.azurewebsites.net/nuget -OutputDirectory \"%WORKSPACE%\" -Prerelease -ExcludeVersion")
783 //Do this here to remove the origin but at the front of the branch name as this is a problem for BenchView
784 //we have to do it all as one statement because cmd is called each time and we lose the set environment variable
785 batchFile("if \"%GIT_BRANCH:~0,7%\" == \"origin/\" (set \"GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH:origin/=%\") else (set \"GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH%\")\n" +
786 "set \"BENCHVIEWNAME=${benchViewName}\"\n" +
787 "set \"BENCHVIEWNAME=%BENCHVIEWNAME:\"=\"\"%\"\n" +
788 "py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\submission-metadata.py\" --name \"%BENCHVIEWNAME%\" --user-email \"dotnet-bot@microsoft.com\"\n" +
789 "py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\build.py\" git --branch %GIT_BRANCH_WITHOUT_ORIGIN% --type ${runType}")
790 batchFile("py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\machinedata.py\"")
791 batchFile("set __TestIntermediateDir=int&&build.cmd ${configuration} ${architecture}")
793 batchFile("tests\\runtest.cmd ${configuration} ${architecture} GenerateLayoutOnly")
795 def runXUnitPerfCommonArgs = "-arch ${arch} -configuration ${configuration} -generateBenchviewData \"%WORKSPACE%\\Microsoft.Benchview.JSONFormat\\tools\" ${uploadString} -runtype ${runType} ${testEnv} -optLevel ${opt_level} -jitName ${jit} -outputdir \"%WORKSPACE%\\bin\\sandbox_logs\" -scenarioTest"
798 batchFile("tests\\scripts\\run-xunit-perf.cmd ${runXUnitPerfCommonArgs} -testBinLoc bin\\tests\\${os}.${architecture}.${configuration}\\performance\\linkbench\\linkbench -group ILLink -nowarmup")
802 def archiveSettings = new ArchivalSettings()
803 archiveSettings.addFiles('bin/sandbox_logs/**')
804 archiveSettings.addFiles('machinedata.json')
806 // Set the label (currently we are only measuring size, therefore we are running on VM).
807 Utilities.setMachineAffinity(newJob, "Windows_NT", '20170427-elevated')
808 Utilities.addArchival(newJob, archiveSettings)
809 Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
813 artifactDaysToKeep(30)
815 artifactNumToKeep(200)
826 TriggerBuilder builder = TriggerBuilder.triggerOnPullRequest()
827 builder.setGithubContext("${os} ${arch} ${opt_level} ${jit} IlLink Tests")
828 builder.triggerOnlyOnComment()
829 builder.setCustomTriggerPhrase("(?i).*test\\W+${os}\\W+${arch}\\W+illink.*")
830 builder.triggerForBranch(branch)
831 builder.emitTrigger(newJob)
834 // Set a push trigger
835 TriggerBuilder builder = TriggerBuilder.triggerOnCommit()
836 builder.emitTrigger(newJob)
844 Utilities.createHelperJob(this, project, branch,
845 "Welcome to the ${project} Perf help",