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 ['full_opt', 'min_opt'].each { opt_level ->
35 def architecture = arch
36 def jobName = "perf_perflab_${os}_${arch}_${opt_level}_${jit}"
39 def newJob = job(Utilities.getFullJobName(project, jobName, isPR)) {
41 label('windows_server_2016_clr_perf')
44 string('BV_UPLOAD_SAS_TOKEN', 'CoreCLR Perf BenchView Sas')
50 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')
55 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')
56 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')
59 def configuration = 'Release'
60 def runType = isPR ? 'private' : 'rolling'
61 def benchViewName = isPR ? 'coreclr private %BenchviewCommitName%' : 'coreclr rolling %GIT_BRANCH_WITHOUT_ORIGIN% %GIT_COMMIT%'
62 def uploadString = '-uploadToBenchview'
67 batchFile("powershell -NoProfile wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile \"%WORKSPACE%\\nuget.exe\"")
68 batchFile("if exist \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\" rmdir /s /q \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\"")
69 batchFile("\"%WORKSPACE%\\nuget.exe\" install Microsoft.BenchView.JSONFormat -Source http://benchviewtestfeed.azurewebsites.net/nuget -OutputDirectory \"%WORKSPACE%\" -Prerelease -ExcludeVersion")
70 //Do this here to remove the origin but at the front of the branch name as this is a problem for BenchView
71 //we have to do it all as one statement because cmd is called each time and we lose the set environment variable
72 batchFile("if \"%GIT_BRANCH:~0,7%\" == \"origin/\" (set \"GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH:origin/=%\") else (set \"GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH%\")\n" +
73 "set \"BENCHVIEWNAME=${benchViewName}\"\n" +
74 "set \"BENCHVIEWNAME=%BENCHVIEWNAME:\"=\"\"%\"\n" +
75 "py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\submission-metadata.py\" --name \"%BENCHVIEWNAME%\" --user-email \"dotnet-bot@microsoft.com\"\n" +
76 "py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\build.py\" git --branch %GIT_BRANCH_WITHOUT_ORIGIN% --type ${runType}")
77 batchFile("py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\machinedata.py\"")
78 batchFile("set __TestIntermediateDir=int&&build.cmd ${configuration} ${architecture}")
80 batchFile("tests\\runtest.cmd ${configuration} ${architecture} GenerateLayoutOnly")
82 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\""
84 // Run with just stopwatch: Profile=Off
85 batchFile("tests\\scripts\\run-xunit-perf.cmd ${runXUnitPerfCommonArgs} -testBinLoc bin\\tests\\${os}.${architecture}.${configuration}\\performance\\perflab\\Perflab -library")
86 batchFile("tests\\scripts\\run-xunit-perf.cmd ${runXUnitPerfCommonArgs} -testBinLoc bin\\tests\\${os}.${architecture}.${configuration}\\Jit\\Performance\\CodeQuality")
88 // Run with the full set of counters enabled: Profile=On
89 if (opt_level != 'min_opt') {
90 batchFile("tests\\scripts\\run-xunit-perf.cmd ${runXUnitPerfCommonArgs} -testBinLoc bin\\tests\\${os}.${architecture}.${configuration}\\performance\\perflab\\Perflab -library -collectionFlags default+BranchMispredictions+CacheMisses+InstructionRetired+gcapi")
91 batchFile("tests\\scripts\\run-xunit-perf.cmd ${runXUnitPerfCommonArgs} -testBinLoc bin\\tests\\${os}.${architecture}.${configuration}\\Jit\\Performance\\CodeQuality -collectionFlags default+BranchMispredictions+CacheMisses+InstructionRetired+gcapi")
96 def archiveSettings = new ArchivalSettings()
97 archiveSettings.addFiles('bin/sandbox_logs/**')
98 archiveSettings.addFiles('machinedata.json')
100 Utilities.addArchival(newJob, archiveSettings)
101 Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
105 artifactDaysToKeep(30)
107 artifactNumToKeep(200)
118 TriggerBuilder builder = TriggerBuilder.triggerOnPullRequest()
119 builder.setGithubContext("${os} ${arch} ${opt_level} ${jit} CoreCLR Perf Tests")
122 if (opt_level == 'min_opt') {
123 opts = '\\W+min_opts'
126 if (jit != 'ryujit') {
130 builder.triggerOnlyOnComment()
131 builder.setCustomTriggerPhrase("(?i).*test\\W+${os}\\W+${arch}${opts}${jitt}\\W+perf.*")
132 builder.triggerForBranch(branch)
133 builder.emitTrigger(newJob)
135 else if (opt_level == 'full_opt') {
136 // Set a push trigger
137 TriggerBuilder builder = TriggerBuilder.triggerOnCommit()
138 builder.emitTrigger(newJob)
141 // Set periodic trigger
142 Utilities.addPeriodicTrigger(newJob, '@daily')
150 // Setup throughput perflab tests runs
151 [true, false].each { isPR ->
152 ['Windows_NT'].each { os ->
153 ['x64', 'x86'].each { arch ->
154 ['ryujit'].each { jit ->
155 [true, false].each { pgo_optimized ->
156 ['full_opt', 'min_opt'].each { opt_level ->
157 def architecture = arch
162 if (!pgo_optimized) {
163 pgo_build = " -nopgooptimize"
168 def newJob = job(Utilities.getFullJobName(project, "perf_throughput_perflab_${os}_${arch}_${opt_level}_${jit}_${pgo_string}", isPR)) {
170 label('windows_server_2016_clr_perf')
173 string('BV_UPLOAD_SAS_TOKEN', 'CoreCLR Perf BenchView Sas')
179 stringParam('BenchviewCommitName', '\${ghprbPullTitle}', 'The name that will be used to build the full title of a run in Benchview.')
183 def configuration = 'Release'
184 def runType = isPR ? 'private' : 'rolling'
185 def benchViewName = isPR ? 'coreclr-throughput private %BenchviewCommitName%' : 'coreclr-throughput rolling %GIT_BRANCH_WITHOUT_ORIGIN% %GIT_COMMIT%'
189 batchFile("if exist \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\" rmdir /s /q \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\"")
190 batchFile("if exist \"%WORKSPACE%\\Microsoft.BenchView.ThroughputBenchmarks.${architecture}.${os}\" rmdir /s /q \"%WORKSPACE%\\Microsoft.BenchView.ThroughputBenchmarks.${architecture}.${os}\"")
191 batchFile("C:\\Tools\\nuget.exe install Microsoft.BenchView.JSONFormat -Source http://benchviewtestfeed.azurewebsites.net/nuget -OutputDirectory \"%WORKSPACE%\" -Prerelease -ExcludeVersion")
192 batchFile("C:\\Tools\\nuget.exe install Microsoft.BenchView.ThroughputBenchmarks.${architecture}.${os} -Source https://dotnet.myget.org/F/dotnet-core -OutputDirectory \"%WORKSPACE%\" -Prerelease -ExcludeVersion")
193 //Do this here to remove the origin but at the front of the branch name as this is a problem for BenchView
194 //we have to do it all as one statement because cmd is called each time and we lose the set environment variable
195 batchFile("if \"%GIT_BRANCH:~0,7%\" == \"origin/\" (set \"GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH:origin/=%\") else (set \"GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH%\")\n" +
196 "set \"BENCHVIEWNAME=${benchViewName}\"\n" +
197 "set \"BENCHVIEWNAME=%BENCHVIEWNAME:\"=\"\"%\"\n" +
198 "py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\submission-metadata.py\" --name \"${benchViewName}\" --user-email \"dotnet-bot@microsoft.com\"\n" +
199 "py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\build.py\" git --branch %GIT_BRANCH_WITHOUT_ORIGIN% --type ${runType}")
200 batchFile("py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\machinedata.py\"")
201 batchFile("set __TestIntermediateDir=int&&build.cmd ${configuration} ${architecture}${pgo_build} skiptests")
202 batchFile("tests\\runtest.cmd ${configuration} ${architecture} GenerateLayoutOnly")
203 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}")
207 // Save machinedata.json to /artifact/bin/ Jenkins dir
208 def archiveSettings = new ArchivalSettings()
209 archiveSettings.addFiles('throughput-*.csv')
210 Utilities.addArchival(newJob, archiveSettings)
212 Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
216 if (opt_level == 'min_opt') {
217 opts = '\\W+min_opts'
221 if (jit != 'ryujit') {
227 pgo_trigger = "\\W+nopgo"
231 TriggerBuilder builder = TriggerBuilder.triggerOnPullRequest()
232 builder.setGithubContext("${os} ${arch} ${opt_level} ${jit} ${pgo_string} CoreCLR Throughput Perf Tests")
233 builder.triggerOnlyOnComment()
234 builder.setCustomTriggerPhrase("(?i).*test\\W+${os}\\W+${arch}${opts}${jitt}${pgo_trigger}\\W+throughput.*")
235 builder.triggerForBranch(branch)
236 builder.emitTrigger(newJob)
238 else if (opt_level == 'full_opt' && pgo_optimized) {
239 // Set a push trigger
240 TriggerBuilder builder = TriggerBuilder.triggerOnCommit()
241 builder.emitTrigger(newJob)
244 // Set periodic trigger
245 Utilities.addPeriodicTrigger(newJob, '@daily')
254 def static getFullPerfJobName(def project, def os, def isPR) {
255 return Utilities.getFullJobName(project, "perf_${os}", isPR)
258 // Create the Linux/OSX/CentOS coreclr test leg for debug and release and each scenario
259 [true, false].each { isPR ->
260 def fullBuildJobName = Utilities.getFullJobName(project, 'perf_linux_build', isPR)
261 def architecture = 'x64'
262 def configuration = 'Release'
264 // Build has to happen on RHEL7.2 (that's where we produce the bits we ship)
265 ['RHEL7.2'].each { os ->
266 def newBuildJob = job(fullBuildJobName) {
268 shell("./build.sh verbose ${architecture} ${configuration}")
271 Utilities.setMachineAffinity(newBuildJob, os, 'latest-or-auto')
272 Utilities.standardJobSetup(newBuildJob, project, isPR, "*/${branch}")
273 Utilities.addArchival(newBuildJob, "bin/Product/**,bin/obj/*/tests/**/*.dylib,bin/obj/*/tests/**/*.so", "bin/Product/**/.nuget/**")
277 // Actual perf testing on the following OSes
278 def perfOSList = ['Ubuntu16.04']
279 perfOSList.each { os ->
280 def newJob = job(getFullPerfJobName(project, os, isPR)) {
282 label('ubuntu_1604_clr_perf')
285 string('BV_UPLOAD_SAS_TOKEN', 'CoreCLR Perf BenchView Sas')
291 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')
296 // Cap the maximum number of iterations to 21.
297 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')
298 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')
299 stringParam('PRODUCT_BUILD', '', 'Build number from which to copy down the CoreCLR Product binaries built for Linux')
302 def osGroup = getOSGroup(os)
303 def runType = isPR ? 'private' : 'rolling'
304 def benchViewName = isPR ? 'coreclr private \$BenchviewCommitName' : 'coreclr rolling \$GIT_BRANCH_WITHOUT_ORIGIN \$GIT_COMMIT'
307 shell("./tests/scripts/perf-prep.sh")
308 shell("./init-tools.sh")
309 copyArtifacts(fullBuildJobName) {
310 includePatterns("bin/**")
312 buildNumber('\${PRODUCT_BUILD}')
315 shell("GIT_BRANCH_WITHOUT_ORIGIN=\$(echo \$GIT_BRANCH | sed \"s/[^/]*\\/\\(.*\\)/\\1 /\")\n" +
316 "python3.5 \"\${WORKSPACE}/tests/scripts/Microsoft.BenchView.JSONFormat/tools/submission-metadata.py\" --name \" ${benchViewName} \" --user-email \"dotnet-bot@microsoft.com\"\n" +
317 "python3.5 \"\${WORKSPACE}/tests/scripts/Microsoft.BenchView.JSONFormat/tools/build.py\" git --branch \$GIT_BRANCH_WITHOUT_ORIGIN --type ${runType}")
318 shell("""./tests/scripts/run-xunit-perf.sh \\
319 --testRootDir=\"\${WORKSPACE}/bin/tests/Windows_NT.${architecture}.${configuration}\" \\
320 --testNativeBinDir=\"\${WORKSPACE}/bin/obj/${osGroup}.${architecture}.${configuration}/tests\" \\
321 --coreClrBinDir=\"\${WORKSPACE}/bin/Product/${osGroup}.${architecture}.${configuration}\" \\
322 --mscorlibDir=\"\${WORKSPACE}/bin/Product/${osGroup}.${architecture}.${configuration}\" \\
323 --coreFxBinDir=\"\${WORKSPACE}/corefx\" \\
324 --runType=\"${runType}\" \\
325 --benchViewOS=\"${os}\" \\
326 --generatebenchviewdata=\"\${WORKSPACE}/tests/scripts/Microsoft.BenchView.JSONFormat/tools\" \\
327 --stabilityPrefix=\"taskset 0x00000002 nice --adjustment=-10\" \\
328 --uploadToBenchview""")
329 shell("mkdir -p bin/toArchive/sandbox/Logs/")
330 shell("rsync -a bin/sandbox/Logs/Perf-*.* bin/toArchive/sandbox/Logs/")
334 def archiveSettings = new ArchivalSettings()
335 archiveSettings.addFiles('bin/toArchive/**')
336 archiveSettings.addFiles('machinedata.json')
338 Utilities.addArchival(newJob, archiveSettings)
339 Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
341 // For perf, we need to keep the run results longer
343 // Enable the log rotator
345 artifactDaysToKeep(30)
347 artifactNumToKeep(200)
358 def flowJobPerfRunList = perfOSList.collect { os ->
359 "{ build(params + [PRODUCT_BUILD: b.build.number], '${getFullPerfJobName(project, os, isPR)}') }"
361 def newFlowJob = buildFlowJob(Utilities.getFullJobName(project, "perf_linux_flow", isPR, '')) {
364 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')
368 // First, build the bits on RHEL7.2
369 b = build(params, '${fullBuildJobName}')
371 // Then, run the perf tests
373 ${flowJobPerfRunList.join(",\n ")}
378 Utilities.setMachineAffinity(newFlowJob, 'Windows_NT', 'latest-or-auto')
379 Utilities.standardJobSetup(newFlowJob, project, isPR, "*/${branch}")
382 TriggerBuilder builder = TriggerBuilder.triggerOnPullRequest()
383 builder.setGithubContext("Linux Perf Test Flow")
384 builder.triggerOnlyOnComment()
385 builder.setCustomTriggerPhrase("(?i).*test\\W+linux\\W+perf\\W+flow.*")
386 builder.triggerForBranch(branch)
387 builder.emitTrigger(newFlowJob)
390 // Set a push trigger
391 TriggerBuilder builder = TriggerBuilder.triggerOnCommit()
392 builder.emitTrigger(newFlowJob)
397 def static getFullThroughputJobName(def project, def os, def isPR) {
398 return Utilities.getFullJobName(project, "perf_throughput_${os}", isPR)
401 // Create the Linux/OSX/CentOS coreclr test leg for debug and release and each scenario
402 [true, false].each { isPR ->
403 def fullBuildJobName = Utilities.getFullJobName(project, 'perf_throughput_linux_build', isPR)
404 def architecture = 'x64'
405 def configuration = 'Release'
407 // Build has to happen on RHEL7.2 (that's where we produce the bits we ship)
408 ['RHEL7.2'].each { os ->
409 def newBuildJob = job(fullBuildJobName) {
411 shell("./build.sh verbose ${architecture} ${configuration}")
414 Utilities.setMachineAffinity(newBuildJob, os, 'latest-or-auto')
415 Utilities.standardJobSetup(newBuildJob, project, isPR, "*/${branch}")
416 Utilities.addArchival(newBuildJob, "bin/Product/**")
419 // Actual perf testing on the following OSes
420 def throughputOSList = ['Ubuntu14.04']
421 def throughputOptLevelList = ['full_opt', 'min_opt']
423 def throughputOSOptLevelList = []
425 throughputOSList.each { os ->
426 throughputOptLevelList.each { opt_level ->
427 throughputOSOptLevelList.add("${os}_${opt_level}")
431 throughputOSList.each { os ->
432 throughputOptLevelList.each { opt_level ->
433 def newJob = job(getFullThroughputJobName(project, "${os}_${opt_level}", isPR)) {
435 label('ubuntu_1604_clr_perf')
438 string('BV_UPLOAD_SAS_TOKEN', 'CoreCLR Perf BenchView Sas')
444 stringParam('BenchviewCommitName', '\${ghprbPullTitle}', 'The name that will be used to build the full title of a run in Benchview.')
449 stringParam('PRODUCT_BUILD', '', 'Build number from which to copy down the CoreCLR Product binaries built for Linux')
452 def osGroup = getOSGroup(os)
453 def runType = isPR ? 'private' : 'rolling'
454 def benchViewName = isPR ? 'coreclr-throughput private \$BenchviewCommitName' : 'coreclr-throughput rolling \$GIT_BRANCH_WITHOUT_ORIGIN \$GIT_COMMIT'
457 shell("bash ./tests/scripts/perf-prep.sh --throughput")
458 shell("./init-tools.sh")
459 copyArtifacts(fullBuildJobName) {
460 includePatterns("bin/Product/**")
462 buildNumber('\${PRODUCT_BUILD}')
465 shell("GIT_BRANCH_WITHOUT_ORIGIN=\$(echo \$GIT_BRANCH | sed \"s/[^/]*\\/\\(.*\\)/\\1 /\")\n" +
466 "python3.5 \"\${WORKSPACE}/tests/scripts/Microsoft.BenchView.JSONFormat/tools/submission-metadata.py\" --name \" ${benchViewName} \" --user-email \"dotnet-bot@microsoft.com\"\n" +
467 "python3.5 \"\${WORKSPACE}/tests/scripts/Microsoft.BenchView.JSONFormat/tools/build.py\" git --branch \$GIT_BRANCH_WITHOUT_ORIGIN --type ${runType}")
468 shell("""python3.5 ./tests/scripts/run-throughput-perf.py \\
469 -arch \"${architecture}\" \\
471 -configuration \"${configuration}\" \\
472 -opt_level \"${opt_level}\" \\
473 -clr_root \"\${WORKSPACE}\" \\
474 -assembly_root \"\${WORKSPACE}/Microsoft.Benchview.ThroughputBenchmarks.${architecture}.Windows_NT/lib\" \\
475 -run_type \"${runType}\" \\
476 -benchview_path \"\${WORKSPACE}/tests/scripts/Microsoft.BenchView.JSONFormat/tools\"""")
480 // Save machinedata.json to /artifact/bin/ Jenkins dir
481 def archiveSettings = new ArchivalSettings()
482 archiveSettings.addFiles('throughput-*.csv')
483 archiveSettings.addFiles('machinedata.json')
484 Utilities.addArchival(newJob, archiveSettings)
486 Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
488 // For perf, we need to keep the run results longer
490 // Enable the log rotator
492 artifactDaysToKeep(7)
494 artifactNumToKeep(25)
501 def flowJobTPRunList = throughputOSOptLevelList.collect { os ->
502 "{ build(params + [PRODUCT_BUILD: b.build.number], '${getFullThroughputJobName(project, os, isPR)}') }"
504 def newFlowJob = buildFlowJob(Utilities.getFullJobName(project, "perf_throughput_linux_flow", isPR, '')) {
507 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')
511 // First, build the bits on RHEL7.2
512 b = build(params, '${fullBuildJobName}')
514 // Then, run the perf tests
516 ${flowJobTPRunList.join(",\n ")}
521 Utilities.setMachineAffinity(newFlowJob, 'Windows_NT', 'latest-or-auto')
522 Utilities.standardJobSetup(newFlowJob, project, isPR, "*/${branch}")
525 TriggerBuilder builder = TriggerBuilder.triggerOnPullRequest()
526 builder.setGithubContext("Linux Throughput Perf Test Flow")
527 builder.triggerOnlyOnComment()
528 builder.setCustomTriggerPhrase("(?i).*test\\W+linux\\W+throughput\\W+flow.*")
529 builder.triggerForBranch(branch)
530 builder.emitTrigger(newFlowJob)
533 // Set a push trigger
534 TriggerBuilder builder = TriggerBuilder.triggerOnCommit()
535 builder.emitTrigger(newFlowJob)
540 // Setup CoreCLR-Scenarios tests
541 [true, false].each { isPR ->
542 ['Windows_NT'].each { os ->
543 ['x64', 'x86'].each { arch ->
544 ['ryujit'].each { jit ->
545 ['full_opt', 'min_opt', 'tiered'].each { opt_level ->
546 def architecture = arch
547 def newJob = job(Utilities.getFullJobName(project, "perf_scenarios_${os}_${arch}_${opt_level}_${jit}", isPR)) {
552 label('windows_server_2016_clr_perf')
555 string('BV_UPLOAD_SAS_TOKEN', 'CoreCLR Perf BenchView Sas')
561 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')
566 stringParam('XUNIT_PERFORMANCE_MAX_ITERATION', '1', 'Size test, one iteration is sufficient')
567 stringParam('XUNIT_PERFORMANCE_MAX_ITERATION_INNER_SPECIFIED', '1', 'Size test, one iteration is sufficient')
570 def configuration = 'Release'
571 def runType = isPR ? 'private' : 'rolling'
572 def benchViewName = isPR ? 'CoreCLR-Scenarios private %BenchviewCommitName%' : 'CoreCLR-Scenarios rolling %GIT_BRANCH_WITHOUT_ORIGIN% %GIT_COMMIT%'
573 def uploadString = '-uploadToBenchview'
577 batchFile("powershell -NoProfile wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile \"%WORKSPACE%\\nuget.exe\"")
578 batchFile("if exist \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\" rmdir /s /q \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\"")
579 batchFile("\"%WORKSPACE%\\nuget.exe\" install Microsoft.BenchView.JSONFormat -Source http://benchviewtestfeed.azurewebsites.net/nuget -OutputDirectory \"%WORKSPACE%\" -Prerelease -ExcludeVersion")
581 //Do this here to remove the origin but at the front of the branch name as this is a problem for BenchView
582 //we have to do it all as one statement because cmd is called each time and we lose the set environment variable
583 batchFile("if \"%GIT_BRANCH:~0,7%\" == \"origin/\" (set \"GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH:origin/=%\") else (set \"GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH%\")\n" +
584 "set \"BENCHVIEWNAME=${benchViewName}\"\n" +
585 "set \"BENCHVIEWNAME=%BENCHVIEWNAME:\"=\"\"%\"\n" +
586 "py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\submission-metadata.py\" --name \"%BENCHVIEWNAME%\" --user-email \"dotnet-bot@microsoft.com\"\n" +
587 "py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\build.py\" git --branch %GIT_BRANCH_WITHOUT_ORIGIN% --type ${runType}")
588 batchFile("py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\machinedata.py\"")
589 batchFile("set __TestIntermediateDir=int&&build.cmd ${configuration} ${architecture}")
591 batchFile("tests\\runtest.cmd ${configuration} ${architecture} GenerateLayoutOnly")
593 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"
596 batchFile("tests\\scripts\\run-xunit-perf.cmd ${runXUnitPerfCommonArgs} -testBinLoc bin\\tests\\${os}.${architecture}.${configuration}\\performance\\Scenario\\JitBench -group CoreCLR-Scenarios")
599 if (opt_level != 'min_opt') {
600 batchFile("tests\\scripts\\run-xunit-perf.cmd ${runXUnitPerfCommonArgs} -testBinLoc bin\\tests\\${os}.${architecture}.${configuration}\\performance\\Scenario\\JitBench -group CoreCLR-Scenarios -collectionFlags BranchMispredictions+CacheMisses+InstructionRetired")
605 def archiveSettings = new ArchivalSettings()
606 archiveSettings.addFiles('bin/sandbox_logs/**')
607 archiveSettings.addFiles('machinedata.json')
609 Utilities.addArchival(newJob, archiveSettings)
610 Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
614 artifactDaysToKeep(30)
616 artifactNumToKeep(200)
628 if (opt_level == 'min_opt') {
629 opts = '\\W+min_opts'
632 if (jit != 'ryujit') {
636 TriggerBuilder builder = TriggerBuilder.triggerOnPullRequest()
637 builder.setGithubContext("${os} ${arch} ${opt_level} ${jit} Performance Scenarios Tests")
638 builder.triggerOnlyOnComment()
639 builder.setCustomTriggerPhrase("(?i).*test\\W+${os}\\W+${arch}${opts}${jitt}\\W+perf\\W+scenarios.*")
640 builder.triggerForBranch(branch)
641 builder.emitTrigger(newJob)
643 else if (opt_level == 'full_opt') {
644 // Set a push trigger
645 TriggerBuilder builder = TriggerBuilder.triggerOnCommit()
646 builder.emitTrigger(newJob)
649 // Set periodic trigger
650 Utilities.addPeriodicTrigger(newJob, '@daily')
658 // Setup size-on-disk test
659 ['Windows_NT'].each { os ->
660 ['x64', 'x86'].each { arch ->
661 def architecture = arch
662 def newJob = job(Utilities.getFullJobName(project, "sizeondisk_${arch}", false)) {
666 string('BV_UPLOAD_SAS_TOKEN', 'CoreCLR Perf BenchView Sas')
670 def channel = 'master'
671 def configuration = 'Release'
672 def runType = 'rolling'
673 def benchViewName = 'Dotnet Size on Disk %DATE% %TIME%'
674 def testBin = "%WORKSPACE%\\bin\\tests\\${os}.${architecture}.${configuration}"
675 def coreRoot = "${testBin}\\Tests\\Core_Root"
676 def benchViewTools = "%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools"
679 // Install nuget and get BenchView tools
680 batchFile("powershell -NoProfile wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile \"%WORKSPACE%\\nuget.exe\"")
681 batchFile("if exist \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\" rmdir /s /q \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\"")
682 batchFile("\"%WORKSPACE%\\nuget.exe\" install Microsoft.BenchView.JSONFormat -Source http://benchviewtestfeed.azurewebsites.net/nuget -OutputDirectory \"%WORKSPACE%\" -Prerelease -ExcludeVersion")
684 // Generate submission metadata for BenchView
685 // Do this here to remove the origin but at the front of the branch name as this is a problem for BenchView
686 // we have to do it all as one statement because cmd is called each time and we lose the set environment variable
687 batchFile("if \"%GIT_BRANCH:~0,7%\" == \"origin/\" (set \"GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH:origin/=%\") else (set \"GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH%\")\n" +
688 "set \"BENCHVIEWNAME=${benchViewName}\"\n" +
689 "set \"BENCHVIEWNAME=%BENCHVIEWNAME:\"=\"\"%\"\n" +
690 "py \"${benchViewTools}\\submission-metadata.py\" --name \"%BENCHVIEWNAME%\" --user-email \"dotnet-bot@microsoft.com\"\n" +
691 "py \"${benchViewTools}\\build.py\" git --branch %GIT_BRANCH_WITHOUT_ORIGIN% --type ${runType}")
693 // Generate machine data from BenchView
694 batchFile("py \"${benchViewTools}\\machinedata.py\"")
696 // Build CoreCLR and gnerate test layout
697 batchFile("set __TestIntermediateDir=int&&build.cmd ${configuration} ${architecture}")
698 batchFile("tests\\runtest.cmd ${configuration} ${architecture} GenerateLayoutOnly")
700 // Run the size on disk benchmark
701 batchFile("\"${coreRoot}\\CoreRun.exe\" \"${testBin}\\sizeondisk\\sodbench\\SoDBench\\SoDBench.exe\" -o \"%WORKSPACE%\\sodbench.csv\" --architecture ${arch} --channel ${channel}")
703 // From sodbench.csv, create measurment.json, then submission.json
704 batchFile("py \"${benchViewTools}\\measurement.py\" csv \"%WORKSPACE%\\sodbench.csv\" --metric \"Size on Disk\" --unit \"bytes\" --better \"desc\"")
705 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}")
707 // If this is a PR, upload submission.json
708 batchFile("py \"${benchViewTools}\\upload.py\" submission.json --container coreclr")
712 Utilities.setMachineAffinity(newJob, "Windows_NT", '20170427-elevated')
714 def archiveSettings = new ArchivalSettings()
715 archiveSettings.addFiles('bin/toArchive/**')
716 archiveSettings.addFiles('machinedata.json')
718 Utilities.addArchival(newJob, archiveSettings)
719 Utilities.standardJobSetup(newJob, project, false, "*/${branch}")
721 // Set the cron job here. We run nightly on each flavor, regardless of code changes
722 Utilities.addPeriodicTrigger(newJob, "@daily", true /*always run*/)
726 artifactDaysToKeep(30)
728 artifactNumToKeep(200)
740 // Setup IlLink tests
741 [true, false].each { isPR ->
742 ['Windows_NT'].each { os ->
743 ['x64'].each { arch ->
744 ['ryujit'].each { jit ->
745 ['full_opt'].each { opt_level ->
746 def architecture = arch
747 def newJob = job(Utilities.getFullJobName(project, "perf_illink_${os}_${arch}_${opt_level}_${jit}", isPR)) {
752 string('BV_UPLOAD_SAS_TOKEN', 'CoreCLR Perf BenchView Sas')
758 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')
763 stringParam('XUNIT_PERFORMANCE_MAX_ITERATION', '1', 'Size test, one iteration is sufficient')
764 stringParam('XUNIT_PERFORMANCE_MAX_ITERATION_INNER_SPECIFIED', '1', 'Size test, one iteration is sufficient')
767 def configuration = 'Release'
768 def runType = isPR ? 'private' : 'rolling'
769 def benchViewName = isPR ? 'CoreCLR-Scenarios private %BenchviewCommitName%' : 'CoreCLR-Scenarios rolling %GIT_BRANCH_WITHOUT_ORIGIN% %GIT_COMMIT%'
770 def uploadString = '-uploadToBenchview'
774 batchFile("powershell -NoProfile wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile \"%WORKSPACE%\\nuget.exe\"")
775 batchFile("if exist \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\" rmdir /s /q \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\"")
776 batchFile("\"%WORKSPACE%\\nuget.exe\" install Microsoft.BenchView.JSONFormat -Source http://benchviewtestfeed.azurewebsites.net/nuget -OutputDirectory \"%WORKSPACE%\" -Prerelease -ExcludeVersion")
778 //Do this here to remove the origin but at the front of the branch name as this is a problem for BenchView
779 //we have to do it all as one statement because cmd is called each time and we lose the set environment variable
780 batchFile("if \"%GIT_BRANCH:~0,7%\" == \"origin/\" (set \"GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH:origin/=%\") else (set \"GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH%\")\n" +
781 "set \"BENCHVIEWNAME=${benchViewName}\"\n" +
782 "set \"BENCHVIEWNAME=%BENCHVIEWNAME:\"=\"\"%\"\n" +
783 "py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\submission-metadata.py\" --name \"%BENCHVIEWNAME%\" --user-email \"dotnet-bot@microsoft.com\"\n" +
784 "py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\build.py\" git --branch %GIT_BRANCH_WITHOUT_ORIGIN% --type ${runType}")
785 batchFile("py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\machinedata.py\"")
786 batchFile("set __TestIntermediateDir=int&&build.cmd ${configuration} ${architecture}")
788 batchFile("tests\\runtest.cmd ${configuration} ${architecture} GenerateLayoutOnly")
790 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"
793 batchFile("tests\\scripts\\run-xunit-perf.cmd ${runXUnitPerfCommonArgs} -testBinLoc bin\\tests\\${os}.${architecture}.${configuration}\\performance\\linkbench\\linkbench -group ILLink -nowarmup")
797 def archiveSettings = new ArchivalSettings()
798 archiveSettings.addFiles('bin/sandbox_logs/**')
799 archiveSettings.addFiles('machinedata.json')
801 // Set the label (currently we are only measuring size, therefore we are running on VM).
802 Utilities.setMachineAffinity(newJob, "Windows_NT", '20170427-elevated')
803 Utilities.addArchival(newJob, archiveSettings)
804 Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
808 artifactDaysToKeep(30)
810 artifactNumToKeep(200)
821 TriggerBuilder builder = TriggerBuilder.triggerOnPullRequest()
822 builder.setGithubContext("${os} ${arch} ${opt_level} ${jit} IlLink Tests")
823 builder.triggerOnlyOnComment()
824 builder.setCustomTriggerPhrase("(?i).*test\\W+${os}\\W+${arch}\\W+illink.*")
825 builder.triggerForBranch(branch)
826 builder.emitTrigger(newJob)
829 // Set a push trigger
830 TriggerBuilder builder = TriggerBuilder.triggerOnCommit()
831 builder.emitTrigger(newJob)
839 Utilities.createHelperJob(this, project, branch,
840 "Welcome to the ${project} Perf help",