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} -os ${os} -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("py tests\\scripts\\run-xunit-perf.py ${runXUnitPerfCommonArgs} -testBinLoc bin\\tests\\${os}.${architecture}.${configuration}\\performance\\perflab\\Perflab -library")
86 batchFile("py tests\\scripts\\run-xunit-perf.py ${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("py tests\\scripts\\run-xunit-perf.py ${runXUnitPerfCommonArgs} -testBinLoc bin\\tests\\${os}.${architecture}.${configuration}\\performance\\perflab\\Perflab -library -collectionFlags default+BranchMispredictions+CacheMisses+InstructionRetired+gcapi")
91 batchFile("py tests\\scripts\\run-xunit-perf.py ${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')
99 archiveSettings.setAlwaysArchive()
101 Utilities.addArchival(newJob, archiveSettings)
102 Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
106 artifactDaysToKeep(30)
108 artifactNumToKeep(200)
119 TriggerBuilder builder = TriggerBuilder.triggerOnPullRequest()
120 builder.setGithubContext("${os} ${arch} ${opt_level} ${jit} CoreCLR Perf Tests")
123 if (opt_level == 'min_opt') {
124 opts = '\\W+min_opts'
127 if (jit != 'ryujit') {
131 builder.triggerOnlyOnComment()
132 builder.setCustomTriggerPhrase("(?i).*test\\W+${os}\\W+${arch}${opts}${jitt}\\W+perf.*")
133 builder.triggerForBranch(branch)
134 builder.emitTrigger(newJob)
136 else if (opt_level == 'full_opt') {
137 // Set a push trigger
138 TriggerBuilder builder = TriggerBuilder.triggerOnCommit()
139 builder.emitTrigger(newJob)
142 // Set periodic trigger
143 Utilities.addPeriodicTrigger(newJob, '@daily')
151 // Setup throughput perflab tests runs
152 [true, false].each { isPR ->
153 ['Windows_NT'].each { os ->
154 ['x64', 'x86'].each { arch ->
155 ['ryujit'].each { jit ->
156 [true, false].each { pgo_optimized ->
157 ['full_opt', 'min_opt'].each { opt_level ->
158 def architecture = arch
163 if (!pgo_optimized) {
164 pgo_build = " -nopgooptimize"
169 def newJob = job(Utilities.getFullJobName(project, "perf_throughput_perflab_${os}_${arch}_${opt_level}_${jit}_${pgo_string}", isPR)) {
171 label('windows_server_2016_clr_perf')
174 string('BV_UPLOAD_SAS_TOKEN', 'CoreCLR Perf BenchView Sas')
180 stringParam('BenchviewCommitName', '\${ghprbPullTitle}', 'The name that will be used to build the full title of a run in Benchview.')
184 def configuration = 'Release'
185 def runType = isPR ? 'private' : 'rolling'
186 def benchViewName = isPR ? 'coreclr-throughput private %BenchviewCommitName%' : 'coreclr-throughput rolling %GIT_BRANCH_WITHOUT_ORIGIN% %GIT_COMMIT%'
190 batchFile("if exist \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\" rmdir /s /q \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\"")
191 batchFile("if exist \"%WORKSPACE%\\Microsoft.BenchView.ThroughputBenchmarks.${architecture}.${os}\" rmdir /s /q \"%WORKSPACE%\\Microsoft.BenchView.ThroughputBenchmarks.${architecture}.${os}\"")
192 batchFile("C:\\Tools\\nuget.exe install Microsoft.BenchView.JSONFormat -Source http://benchviewtestfeed.azurewebsites.net/nuget -OutputDirectory \"%WORKSPACE%\" -Prerelease -ExcludeVersion")
193 batchFile("C:\\Tools\\nuget.exe install Microsoft.BenchView.ThroughputBenchmarks.${architecture}.${os} -Source https://dotnet.myget.org/F/dotnet-core -OutputDirectory \"%WORKSPACE%\" -Prerelease -ExcludeVersion")
194 //Do this here to remove the origin but at the front of the branch name as this is a problem for BenchView
195 //we have to do it all as one statement because cmd is called each time and we lose the set environment variable
196 batchFile("if \"%GIT_BRANCH:~0,7%\" == \"origin/\" (set \"GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH:origin/=%\") else (set \"GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH%\")\n" +
197 "set \"BENCHVIEWNAME=${benchViewName}\"\n" +
198 "set \"BENCHVIEWNAME=%BENCHVIEWNAME:\"=\"\"%\"\n" +
199 "py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\submission-metadata.py\" --name \"${benchViewName}\" --user-email \"dotnet-bot@microsoft.com\"\n" +
200 "py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\build.py\" git --branch %GIT_BRANCH_WITHOUT_ORIGIN% --type ${runType}")
201 batchFile("py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\machinedata.py\"")
202 batchFile("set __TestIntermediateDir=int&&build.cmd ${configuration} ${architecture}${pgo_build} skiptests")
203 batchFile("tests\\runtest.cmd ${configuration} ${architecture} GenerateLayoutOnly")
204 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}")
208 // Save machinedata.json to /artifact/bin/ Jenkins dir
209 def archiveSettings = new ArchivalSettings()
210 archiveSettings.addFiles('throughput-*.csv')
211 archiveSettings.setAlwaysArchive()
212 Utilities.addArchival(newJob, archiveSettings)
214 Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
218 if (opt_level == 'min_opt') {
219 opts = '\\W+min_opts'
223 if (jit != 'ryujit') {
229 pgo_trigger = "\\W+nopgo"
233 TriggerBuilder builder = TriggerBuilder.triggerOnPullRequest()
234 builder.setGithubContext("${os} ${arch} ${opt_level} ${jit} ${pgo_string} CoreCLR Throughput Perf Tests")
235 builder.triggerOnlyOnComment()
236 builder.setCustomTriggerPhrase("(?i).*test\\W+${os}\\W+${arch}${opts}${jitt}${pgo_trigger}\\W+throughput.*")
237 builder.triggerForBranch(branch)
238 builder.emitTrigger(newJob)
240 else if (opt_level == 'full_opt' && pgo_optimized) {
241 // Set a push trigger
242 TriggerBuilder builder = TriggerBuilder.triggerOnCommit()
243 builder.emitTrigger(newJob)
246 // Set periodic trigger
247 Utilities.addPeriodicTrigger(newJob, '@daily')
256 def static getFullPerfJobName(def project, def os, def isPR) {
257 return Utilities.getFullJobName(project, "perf_${os}", isPR)
260 // Create the Linux/OSX/CentOS coreclr test leg for debug and release and each scenario
261 [true, false].each { isPR ->
262 def fullBuildJobName = Utilities.getFullJobName(project, 'perf_linux_build', isPR)
263 def architecture = 'x64'
264 def configuration = 'Release'
266 // Build has to happen on RHEL7.2 (that's where we produce the bits we ship)
267 ['RHEL7.2'].each { os ->
268 def newBuildJob = job(fullBuildJobName) {
270 shell("./build.sh verbose ${architecture} ${configuration}")
271 shell("./build-test.sh generatelayoutonly ${architecture} ${configuration}")
274 Utilities.setMachineAffinity(newBuildJob, os, 'latest-or-auto')
275 Utilities.standardJobSetup(newBuildJob, project, isPR, "*/${branch}")
276 Utilities.addArchival(newBuildJob, "bin/Product/**,bin/obj/*/tests/**/*.dylib,bin/obj/*/tests/**/*.so,bin/tests/**", "bin/Product/**/.nuget/**")
280 // Actual perf testing on the following OSes
281 def perfOSList = ['Ubuntu16.04']
282 perfOSList.each { os ->
283 def newJob = job(getFullPerfJobName(project, os, isPR)) {
285 label('ubuntu_1604_clr_perf')
288 string('BV_UPLOAD_SAS_TOKEN', 'CoreCLR Perf BenchView Sas')
294 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')
299 // Cap the maximum number of iterations to 21.
300 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')
301 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')
302 stringParam('PRODUCT_BUILD', '', 'Build number from which to copy down the CoreCLR Product binaries built for Linux')
305 def osGroup = getOSGroup(os)
306 def runType = isPR ? 'private' : 'rolling'
307 def benchViewName = isPR ? 'coreclr private \$BenchviewCommitName' : 'coreclr rolling \$GIT_BRANCH_WITHOUT_ORIGIN \$GIT_COMMIT'
308 def uploadString = '-uploadToBenchview'
310 def runXUnitCommonArgs = "-arch ${architecture} -os ${os} -configuration ${configuration} -stabilityPrefix \"taskset 0x00000002 nice --adjustment=-10\" -generateBenchviewData \"\${WORKSPACE}/tests/scripts/Microsoft.BenchView.JSONFormat/tools\" ${uploadString} -runtype ${runType} -outputdir \"\${WORKSPACE}/bin/sandbox_logs\""
313 shell("./tests/scripts/perf-prep.sh --nocorefx")
314 shell("./init-tools.sh")
315 copyArtifacts(fullBuildJobName) {
316 includePatterns("bin/**")
318 buildNumber('\${PRODUCT_BUILD}')
321 shell("GIT_BRANCH_WITHOUT_ORIGIN=\$(echo \$GIT_BRANCH | sed \"s/[^/]*\\/\\(.*\\)/\\1 /\")\n" +
322 "python3.5 \"\${WORKSPACE}/tests/scripts/Microsoft.BenchView.JSONFormat/tools/submission-metadata.py\" --name \" ${benchViewName} \" --user-email \"dotnet-bot@microsoft.com\"\n" +
323 "python3.5 \"\${WORKSPACE}/tests/scripts/Microsoft.BenchView.JSONFormat/tools/build.py\" git --branch \$GIT_BRANCH_WITHOUT_ORIGIN --type ${runType}")
324 shell("""python3 ./tests/scripts/run-xunit-perf.py -testBinLoc bin/tests/Windows_NT.${architecture}.${configuration}/JIT/Performance/CodeQuality ${runXUnitCommonArgs}""")
328 def archiveSettings = new ArchivalSettings()
329 archiveSettings.addFiles('bin/sandbox_logs/**')
330 archiveSettings.addFiles('machinedata.json')
331 archiveSettings.setAlwaysArchive()
333 Utilities.addArchival(newJob, archiveSettings)
334 Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
336 // For perf, we need to keep the run results longer
338 // Enable the log rotator
340 artifactDaysToKeep(30)
342 artifactNumToKeep(200)
353 def flowJobPerfRunList = perfOSList.collect { os ->
354 "{ build(params + [PRODUCT_BUILD: b.build.number], '${getFullPerfJobName(project, os, isPR)}') }"
356 def newFlowJob = buildFlowJob(Utilities.getFullJobName(project, "perf_linux_flow", isPR, '')) {
359 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')
363 // First, build the bits on RHEL7.2
364 b = build(params, '${fullBuildJobName}')
366 // Then, run the perf tests
368 ${flowJobPerfRunList.join(",\n ")}
373 Utilities.setMachineAffinity(newFlowJob, 'Windows_NT', 'latest-or-auto')
374 Utilities.standardJobSetup(newFlowJob, project, isPR, "*/${branch}")
377 TriggerBuilder builder = TriggerBuilder.triggerOnPullRequest()
378 builder.setGithubContext("Linux Perf Test Flow")
379 builder.triggerOnlyOnComment()
380 builder.setCustomTriggerPhrase("(?i).*test\\W+linux\\W+perf\\W+flow.*")
381 builder.triggerForBranch(branch)
382 builder.emitTrigger(newFlowJob)
385 // Set a push trigger
386 TriggerBuilder builder = TriggerBuilder.triggerOnCommit()
387 builder.emitTrigger(newFlowJob)
392 def static getFullThroughputJobName(def project, def os, def isPR) {
393 return Utilities.getFullJobName(project, "perf_throughput_${os}", isPR)
396 // Create the Linux/OSX/CentOS coreclr test leg for debug and release and each scenario
397 [true, false].each { isPR ->
398 def fullBuildJobName = Utilities.getFullJobName(project, 'perf_throughput_linux_build', isPR)
399 def architecture = 'x64'
400 def configuration = 'Release'
402 // Build has to happen on RHEL7.2 (that's where we produce the bits we ship)
403 ['RHEL7.2'].each { os ->
404 def newBuildJob = job(fullBuildJobName) {
406 shell("./build.sh verbose ${architecture} ${configuration}")
409 Utilities.setMachineAffinity(newBuildJob, os, 'latest-or-auto')
410 Utilities.standardJobSetup(newBuildJob, project, isPR, "*/${branch}")
411 Utilities.addArchival(newBuildJob, "bin/Product/**")
414 // Actual perf testing on the following OSes
415 def throughputOSList = ['Ubuntu14.04']
416 def throughputOptLevelList = ['full_opt', 'min_opt']
418 def throughputOSOptLevelList = []
420 throughputOSList.each { os ->
421 throughputOptLevelList.each { opt_level ->
422 throughputOSOptLevelList.add("${os}_${opt_level}")
426 throughputOSList.each { os ->
427 throughputOptLevelList.each { opt_level ->
428 def newJob = job(getFullThroughputJobName(project, "${os}_${opt_level}", isPR)) {
430 label('ubuntu_1604_clr_perf')
433 string('BV_UPLOAD_SAS_TOKEN', 'CoreCLR Perf BenchView Sas')
439 stringParam('BenchviewCommitName', '\${ghprbPullTitle}', 'The name that will be used to build the full title of a run in Benchview.')
444 stringParam('PRODUCT_BUILD', '', 'Build number from which to copy down the CoreCLR Product binaries built for Linux')
447 def osGroup = getOSGroup(os)
448 def runType = isPR ? 'private' : 'rolling'
449 def benchViewName = isPR ? 'coreclr-throughput private \$BenchviewCommitName' : 'coreclr-throughput rolling \$GIT_BRANCH_WITHOUT_ORIGIN \$GIT_COMMIT'
452 shell("bash ./tests/scripts/perf-prep.sh --throughput")
453 shell("./init-tools.sh")
454 copyArtifacts(fullBuildJobName) {
455 includePatterns("bin/Product/**")
457 buildNumber('\${PRODUCT_BUILD}')
460 shell("GIT_BRANCH_WITHOUT_ORIGIN=\$(echo \$GIT_BRANCH | sed \"s/[^/]*\\/\\(.*\\)/\\1 /\")\n" +
461 "python3.5 \"\${WORKSPACE}/tests/scripts/Microsoft.BenchView.JSONFormat/tools/submission-metadata.py\" --name \" ${benchViewName} \" --user-email \"dotnet-bot@microsoft.com\"\n" +
462 "python3.5 \"\${WORKSPACE}/tests/scripts/Microsoft.BenchView.JSONFormat/tools/build.py\" git --branch \$GIT_BRANCH_WITHOUT_ORIGIN --type ${runType}")
463 shell("""python3.5 ./tests/scripts/run-throughput-perf.py \\
464 -arch \"${architecture}\" \\
466 -configuration \"${configuration}\" \\
467 -opt_level \"${opt_level}\" \\
468 -clr_root \"\${WORKSPACE}\" \\
469 -assembly_root \"\${WORKSPACE}/Microsoft.Benchview.ThroughputBenchmarks.${architecture}.Windows_NT/lib\" \\
470 -run_type \"${runType}\" \\
471 -benchview_path \"\${WORKSPACE}/tests/scripts/Microsoft.BenchView.JSONFormat/tools\"""")
475 // Save machinedata.json to /artifact/bin/ Jenkins dir
476 def archiveSettings = new ArchivalSettings()
477 archiveSettings.addFiles('throughput-*.csv')
478 archiveSettings.addFiles('machinedata.json')
479 archiveSettings.setAlwaysArchive()
480 Utilities.addArchival(newJob, archiveSettings)
482 Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
484 // For perf, we need to keep the run results longer
486 // Enable the log rotator
488 artifactDaysToKeep(7)
490 artifactNumToKeep(25)
497 def flowJobTPRunList = throughputOSOptLevelList.collect { os ->
498 "{ build(params + [PRODUCT_BUILD: b.build.number], '${getFullThroughputJobName(project, os, isPR)}') }"
500 def newFlowJob = buildFlowJob(Utilities.getFullJobName(project, "perf_throughput_linux_flow", isPR, '')) {
503 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')
507 // First, build the bits on RHEL7.2
508 b = build(params, '${fullBuildJobName}')
510 // Then, run the perf tests
512 ${flowJobTPRunList.join(",\n ")}
517 Utilities.setMachineAffinity(newFlowJob, 'Windows_NT', 'latest-or-auto')
518 Utilities.standardJobSetup(newFlowJob, project, isPR, "*/${branch}")
521 TriggerBuilder builder = TriggerBuilder.triggerOnPullRequest()
522 builder.setGithubContext("Linux Throughput Perf Test Flow")
523 builder.triggerOnlyOnComment()
524 builder.setCustomTriggerPhrase("(?i).*test\\W+linux\\W+throughput\\W+flow.*")
525 builder.triggerForBranch(branch)
526 builder.emitTrigger(newFlowJob)
529 // Set a push trigger
530 TriggerBuilder builder = TriggerBuilder.triggerOnCommit()
531 builder.emitTrigger(newFlowJob)
536 // Setup CoreCLR-Scenarios tests
537 [true, false].each { isPR ->
538 ['Windows_NT'].each { os ->
539 ['x64', 'x86'].each { arch ->
540 ['ryujit'].each { jit ->
541 ['full_opt', 'min_opt', 'tiered'].each { opt_level ->
542 def architecture = arch
543 def newJob = job(Utilities.getFullJobName(project, "perf_scenarios_${os}_${arch}_${opt_level}_${jit}", isPR)) {
548 label('windows_server_2016_clr_perf')
551 string('BV_UPLOAD_SAS_TOKEN', 'CoreCLR Perf BenchView Sas')
557 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')
562 stringParam('XUNIT_PERFORMANCE_MAX_ITERATION', '1', 'Size test, one iteration is sufficient')
563 stringParam('XUNIT_PERFORMANCE_MAX_ITERATION_INNER_SPECIFIED', '1', 'Size test, one iteration is sufficient')
566 def configuration = 'Release'
567 def runType = isPR ? 'private' : 'rolling'
568 def benchViewName = isPR ? 'CoreCLR-Scenarios private %BenchviewCommitName%' : 'CoreCLR-Scenarios rolling %GIT_BRANCH_WITHOUT_ORIGIN% %GIT_COMMIT%'
569 def uploadString = '-uploadToBenchview'
573 batchFile("powershell -NoProfile wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile \"%WORKSPACE%\\nuget.exe\"")
574 batchFile("if exist \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\" rmdir /s /q \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\"")
575 batchFile("\"%WORKSPACE%\\nuget.exe\" install Microsoft.BenchView.JSONFormat -Source http://benchviewtestfeed.azurewebsites.net/nuget -OutputDirectory \"%WORKSPACE%\" -Prerelease -ExcludeVersion")
577 //Do this here to remove the origin but at the front of the branch name as this is a problem for BenchView
578 //we have to do it all as one statement because cmd is called each time and we lose the set environment variable
579 batchFile("if \"%GIT_BRANCH:~0,7%\" == \"origin/\" (set \"GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH:origin/=%\") else (set \"GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH%\")\n" +
580 "set \"BENCHVIEWNAME=${benchViewName}\"\n" +
581 "set \"BENCHVIEWNAME=%BENCHVIEWNAME:\"=\"\"%\"\n" +
582 "py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\submission-metadata.py\" --name \"%BENCHVIEWNAME%\" --user-email \"dotnet-bot@microsoft.com\"\n" +
583 "py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\build.py\" git --branch %GIT_BRANCH_WITHOUT_ORIGIN% --type ${runType}")
584 batchFile("py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\machinedata.py\"")
585 batchFile("set __TestIntermediateDir=int&&build.cmd ${configuration} ${architecture}")
587 batchFile("tests\\runtest.cmd ${configuration} ${architecture} GenerateLayoutOnly")
589 def runXUnitPerfCommonArgs = "-arch ${arch} -configuration ${configuration} -os ${os} -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"
592 batchFile("py tests\\scripts\\run-xunit-perf.py ${runXUnitPerfCommonArgs} -testBinLoc bin\\tests\\${os}.${architecture}.${configuration}\\performance\\Scenario\\JitBench -group CoreCLR-Scenarios")
595 if (opt_level != 'min_opt') {
596 batchFile("py tests\\scripts\\run-xunit-perf.py ${runXUnitPerfCommonArgs} -testBinLoc bin\\tests\\${os}.${architecture}.${configuration}\\performance\\Scenario\\JitBench -group CoreCLR-Scenarios -collectionFlags BranchMispredictions+CacheMisses+InstructionRetired")
601 def archiveSettings = new ArchivalSettings()
602 archiveSettings.addFiles('bin/sandbox_logs/**')
603 archiveSettings.addFiles('machinedata.json')
604 archiveSettings.setAlwaysArchive()
606 Utilities.addArchival(newJob, archiveSettings)
607 Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
611 artifactDaysToKeep(30)
613 artifactNumToKeep(200)
625 if (opt_level == 'min_opt') {
626 opts = '\\W+min_opts'
629 if (jit != 'ryujit') {
633 TriggerBuilder builder = TriggerBuilder.triggerOnPullRequest()
634 builder.setGithubContext("${os} ${arch} ${opt_level} ${jit} Performance Scenarios Tests")
635 builder.triggerOnlyOnComment()
636 builder.setCustomTriggerPhrase("(?i).*test\\W+${os}\\W+${arch}${opts}${jitt}\\W+perf\\W+scenarios.*")
637 builder.triggerForBranch(branch)
638 builder.emitTrigger(newJob)
640 else if (opt_level == 'full_opt') {
641 // Set a push trigger
642 TriggerBuilder builder = TriggerBuilder.triggerOnCommit()
643 builder.emitTrigger(newJob)
646 // Set periodic trigger
647 Utilities.addPeriodicTrigger(newJob, '@daily')
655 // Setup size-on-disk test
656 ['Windows_NT'].each { os ->
657 ['x64', 'x86'].each { arch ->
658 def architecture = arch
659 def newJob = job(Utilities.getFullJobName(project, "sizeondisk_${arch}", false)) {
663 string('BV_UPLOAD_SAS_TOKEN', 'CoreCLR Perf BenchView Sas')
667 def channel = 'master'
668 def configuration = 'Release'
669 def runType = 'rolling'
670 def benchViewName = 'Dotnet Size on Disk %DATE% %TIME%'
671 def testBin = "%WORKSPACE%\\bin\\tests\\${os}.${architecture}.${configuration}"
672 def coreRoot = "${testBin}\\Tests\\Core_Root"
673 def benchViewTools = "%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools"
676 // Install nuget and get BenchView tools
677 batchFile("powershell -NoProfile wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile \"%WORKSPACE%\\nuget.exe\"")
678 batchFile("if exist \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\" rmdir /s /q \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\"")
679 batchFile("\"%WORKSPACE%\\nuget.exe\" install Microsoft.BenchView.JSONFormat -Source http://benchviewtestfeed.azurewebsites.net/nuget -OutputDirectory \"%WORKSPACE%\" -Prerelease -ExcludeVersion")
681 // Generate submission metadata for BenchView
682 // Do this here to remove the origin but at the front of the branch name as this is a problem for BenchView
683 // we have to do it all as one statement because cmd is called each time and we lose the set environment variable
684 batchFile("if \"%GIT_BRANCH:~0,7%\" == \"origin/\" (set \"GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH:origin/=%\") else (set \"GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH%\")\n" +
685 "set \"BENCHVIEWNAME=${benchViewName}\"\n" +
686 "set \"BENCHVIEWNAME=%BENCHVIEWNAME:\"=\"\"%\"\n" +
687 "py \"${benchViewTools}\\submission-metadata.py\" --name \"%BENCHVIEWNAME%\" --user-email \"dotnet-bot@microsoft.com\"\n" +
688 "py \"${benchViewTools}\\build.py\" git --branch %GIT_BRANCH_WITHOUT_ORIGIN% --type ${runType}")
690 // Generate machine data from BenchView
691 batchFile("py \"${benchViewTools}\\machinedata.py\"")
693 // Build CoreCLR and gnerate test layout
694 batchFile("set __TestIntermediateDir=int&&build.cmd ${configuration} ${architecture}")
695 batchFile("tests\\runtest.cmd ${configuration} ${architecture} GenerateLayoutOnly")
697 // Run the size on disk benchmark
698 batchFile("\"${coreRoot}\\CoreRun.exe\" \"${testBin}\\sizeondisk\\sodbench\\SoDBench\\SoDBench.exe\" -o \"%WORKSPACE%\\sodbench.csv\" --architecture ${arch} --channel ${channel}")
700 // From sodbench.csv, create measurment.json, then submission.json
701 batchFile("py \"${benchViewTools}\\measurement.py\" csv \"%WORKSPACE%\\sodbench.csv\" --metric \"Size on Disk\" --unit \"bytes\" --better \"desc\"")
702 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}")
704 // If this is a PR, upload submission.json
705 batchFile("py \"${benchViewTools}\\upload.py\" submission.json --container coreclr")
709 Utilities.setMachineAffinity(newJob, "Windows_NT", '20170427-elevated')
711 def archiveSettings = new ArchivalSettings()
712 archiveSettings.addFiles('bin/toArchive/**')
713 archiveSettings.addFiles('machinedata.json')
714 archiveSettings.setAlwaysArchive()
716 Utilities.addArchival(newJob, archiveSettings)
717 Utilities.standardJobSetup(newJob, project, false, "*/${branch}")
719 // Set the cron job here. We run nightly on each flavor, regardless of code changes
720 Utilities.addPeriodicTrigger(newJob, "@daily", true /*always run*/)
724 artifactDaysToKeep(30)
726 artifactNumToKeep(200)
738 // Setup IlLink tests
739 [true, false].each { isPR ->
740 ['Windows_NT'].each { os ->
741 ['x64'].each { arch ->
742 ['ryujit'].each { jit ->
743 ['full_opt'].each { opt_level ->
744 def architecture = arch
745 def newJob = job(Utilities.getFullJobName(project, "perf_illink_${os}_${arch}_${opt_level}_${jit}", isPR)) {
750 string('BV_UPLOAD_SAS_TOKEN', 'CoreCLR Perf BenchView Sas')
756 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')
761 stringParam('XUNIT_PERFORMANCE_MAX_ITERATION', '1', 'Size test, one iteration is sufficient')
762 stringParam('XUNIT_PERFORMANCE_MAX_ITERATION_INNER_SPECIFIED', '1', 'Size test, one iteration is sufficient')
765 def configuration = 'Release'
766 def runType = isPR ? 'private' : 'rolling'
767 def benchViewName = isPR ? 'CoreCLR-Scenarios private %BenchviewCommitName%' : 'CoreCLR-Scenarios rolling %GIT_BRANCH_WITHOUT_ORIGIN% %GIT_COMMIT%'
768 def uploadString = '-uploadToBenchview'
772 batchFile("powershell -NoProfile wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile \"%WORKSPACE%\\nuget.exe\"")
773 batchFile("if exist \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\" rmdir /s /q \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\"")
774 batchFile("\"%WORKSPACE%\\nuget.exe\" install Microsoft.BenchView.JSONFormat -Source http://benchviewtestfeed.azurewebsites.net/nuget -OutputDirectory \"%WORKSPACE%\" -Prerelease -ExcludeVersion")
776 //Do this here to remove the origin but at the front of the branch name as this is a problem for BenchView
777 //we have to do it all as one statement because cmd is called each time and we lose the set environment variable
778 batchFile("if \"%GIT_BRANCH:~0,7%\" == \"origin/\" (set \"GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH:origin/=%\") else (set \"GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH%\")\n" +
779 "set \"BENCHVIEWNAME=${benchViewName}\"\n" +
780 "set \"BENCHVIEWNAME=%BENCHVIEWNAME:\"=\"\"%\"\n" +
781 "py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\submission-metadata.py\" --name \"%BENCHVIEWNAME%\" --user-email \"dotnet-bot@microsoft.com\"\n" +
782 "py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\build.py\" git --branch %GIT_BRANCH_WITHOUT_ORIGIN% --type ${runType}")
783 batchFile("py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\machinedata.py\"")
784 batchFile("set __TestIntermediateDir=int&&build.cmd ${configuration} ${architecture}")
786 batchFile("tests\\runtest.cmd ${configuration} ${architecture} GenerateLayoutOnly")
788 def runXUnitPerfCommonArgs = "-arch ${arch} -configuration ${configuration} -os ${os} -generateBenchviewData \"%WORKSPACE%\\Microsoft.Benchview.JSONFormat\\tools\" ${uploadString} -runtype ${runType} ${testEnv} -optLevel ${opt_level} -jitName ${jit} -outputdir \"%WORKSPACE%\\bin\\sandbox_logs\" -scenarioTest"
791 batchFile("\"%VS140COMNTOOLS%\\..\\..\\VC\\vcvarsall.bat\" x86_amd64 && " +
792 "py tests\\scripts\\run-xunit-perf.py ${runXUnitPerfCommonArgs} -testBinLoc bin\\tests\\${os}.${architecture}.${configuration}\\performance\\linkbench\\linkbench -group ILLink -nowarmup")
796 def archiveSettings = new ArchivalSettings()
797 archiveSettings.addFiles('bin/sandbox_logs/**')
798 archiveSettings.addFiles('machinedata.json')
799 archiveSettings.setAlwaysArchive()
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",