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} -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("xcopy.exe /VYQK bin\\sandbox\\Logs\\Perf-*.* bin\\toArchive\\sandbox\\Logs\\Perflab\\Off\\")
96 batchFile("tests\\scripts\\run-xunit-perf.cmd ${runXUnitPerfCommonArgs} -testBinLoc bin\\tests\\${os}.${architecture}.${configuration}\\Jit\\Performance\\CodeQuality")
97 batchFile("xcopy.exe /VYQK bin\\sandbox\\Logs\\Perf-*.* bin\\toArchive\\sandbox\\Logs\\CodeQuality\\Off\\")
99 // Run with the full set of counters enabled: Profile=On
100 if (opt_level != 'min_opt') {
101 batchFile("tests\\scripts\\run-xunit-perf.cmd ${runXUnitPerfCommonArgs} -testBinLoc bin\\tests\\${os}.${architecture}.${configuration}\\performance\\perflab\\Perflab -library -collectionFlags default+BranchMispredictions+CacheMisses+InstructionRetired+gcapi")
102 batchFile("xcopy.exe /VYQK bin\\sandbox\\Logs\\Perf-*.* bin\\toArchive\\sandbox\\Logs\\Perflab\\On\\")
104 batchFile("tests\\scripts\\run-xunit-perf.cmd ${runXUnitPerfCommonArgs} -testBinLoc bin\\tests\\${os}.${architecture}.${configuration}\\Jit\\Performance\\CodeQuality -collectionFlags default+BranchMispredictions+CacheMisses+InstructionRetired+gcapi")
105 batchFile("xcopy.exe /VYQK bin\\sandbox\\Logs\\Perf-*.* bin\\toArchive\\sandbox\\Logs\\CodeQuality\\On\\")
110 def archiveSettings = new ArchivalSettings()
111 archiveSettings.addFiles('bin/toArchive/**')
112 archiveSettings.addFiles('machinedata.json')
114 Utilities.addArchival(newJob, archiveSettings)
115 Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
119 artifactDaysToKeep(30)
121 artifactNumToKeep(200)
132 TriggerBuilder builder = TriggerBuilder.triggerOnPullRequest()
133 builder.setGithubContext("${os} ${arch} ${opt_level} ${jit} CoreCLR Perf Tests")
136 if (opt_level == 'min_opt') {
137 opts = '\\W+min_opts'
140 if (jit != 'ryujit') {
144 builder.triggerOnlyOnComment()
145 builder.setCustomTriggerPhrase("(?i).*test\\W+${os}\\W+${arch}${opts}${jitt}\\W+perf.*")
146 builder.triggerForBranch(branch)
147 builder.emitTrigger(newJob)
150 // Set a push trigger
151 TriggerBuilder builder = TriggerBuilder.triggerOnCommit()
152 builder.emitTrigger(newJob)
160 // Setup throughput perflab tests runs
161 [true, false].each { isPR ->
162 ['Windows_NT'].each { os ->
163 ['x64', 'x86'].each { arch ->
164 ['ryujit', 'legacy_backend'].each { jit ->
165 [true, false].each { pgo_optimized ->
166 if (arch == 'x64' && jit == 'legacy_backend') {
170 // pgo not supported for legacy_backend
171 if (pgo_optimized && jit == 'legacy_backend') {
175 ['full_opt', 'min_opt'].each { opt_level ->
176 def architecture = arch
181 if (!pgo_optimized) {
182 pgo_build = " -nopgooptimize"
187 def newJob = job(Utilities.getFullJobName(project, "perf_throughput_perflab_${os}_${arch}_${opt_level}_${jit}_${pgo_string}", isPR)) {
189 label('windows_server_2016_clr_perf')
192 string('BV_UPLOAD_SAS_TOKEN', 'CoreCLR Perf BenchView Sas')
198 stringParam('BenchviewCommitName', '\${ghprbPullTitle}', 'The name that will be used to build the full title of a run in Benchview.')
202 def configuration = 'Release'
203 def runType = isPR ? 'private' : 'rolling'
204 def benchViewName = isPR ? 'coreclr-throughput private %BenchviewCommitName%' : 'coreclr-throughput rolling %GIT_BRANCH_WITHOUT_ORIGIN% %GIT_COMMIT%'
208 batchFile("if exist \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\" rmdir /s /q \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\"")
209 batchFile("if exist \"%WORKSPACE%\\Microsoft.BenchView.ThroughputBenchmarks.${architecture}.${os}\" rmdir /s /q \"%WORKSPACE%\\Microsoft.BenchView.ThroughputBenchmarks.${architecture}.${os}\"")
210 batchFile("C:\\Tools\\nuget.exe install Microsoft.BenchView.JSONFormat -Source http://benchviewtestfeed.azurewebsites.net/nuget -OutputDirectory \"%WORKSPACE%\" -Prerelease -ExcludeVersion")
211 batchFile("C:\\Tools\\nuget.exe install Microsoft.BenchView.ThroughputBenchmarks.${architecture}.${os} -Source https://dotnet.myget.org/F/dotnet-core -OutputDirectory \"%WORKSPACE%\" -Prerelease -ExcludeVersion")
212 //Do this here to remove the origin but at the front of the branch name as this is a problem for BenchView
213 //we have to do it all as one statement because cmd is called each time and we lose the set environment variable
214 batchFile("if \"%GIT_BRANCH:~0,7%\" == \"origin/\" (set \"GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH:origin/=%\") else (set \"GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH%\")\n" +
215 "set \"BENCHVIEWNAME=${benchViewName}\"\n" +
216 "set \"BENCHVIEWNAME=%BENCHVIEWNAME:\"=\"\"%\"\n" +
217 "py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\submission-metadata.py\" --name \"${benchViewName}\" --user-email \"dotnet-bot@microsoft.com\"\n" +
218 "py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\build.py\" git --branch %GIT_BRANCH_WITHOUT_ORIGIN% --type ${runType}")
219 batchFile("py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\machinedata.py\"")
220 batchFile("set __TestIntermediateDir=int&&build.cmd ${configuration} ${architecture}${pgo_build} skiptests")
221 batchFile("tests\\runtest.cmd ${configuration} ${architecture} GenerateLayoutOnly")
222 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}")
226 // Save machinedata.json to /artifact/bin/ Jenkins dir
227 def archiveSettings = new ArchivalSettings()
228 archiveSettings.addFiles('throughput-*.csv')
229 Utilities.addArchival(newJob, archiveSettings)
231 Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
235 if (opt_level == 'min_opt') {
236 opts = '\\W+min_opts'
240 if (jit != 'ryujit') {
246 pgo_trigger = "\\W+nopgo"
250 TriggerBuilder builder = TriggerBuilder.triggerOnPullRequest()
251 builder.setGithubContext("${os} ${arch} ${opt_level} ${jit} ${pgo_string} CoreCLR Throughput Perf Tests")
252 builder.triggerOnlyOnComment()
253 builder.setCustomTriggerPhrase("(?i).*test\\W+${os}\\W+${arch}${opts}${jitt}${pgo_trigger}\\W+throughput.*")
254 builder.triggerForBranch(branch)
255 builder.emitTrigger(newJob)
258 // Set a push trigger
259 TriggerBuilder builder = TriggerBuilder.triggerOnCommit()
260 builder.emitTrigger(newJob)
269 def static getFullPerfJobName(def project, def os, def isPR) {
270 return Utilities.getFullJobName(project, "perf_${os}", isPR)
273 // Create the Linux/OSX/CentOS coreclr test leg for debug and release and each scenario
274 [true, false].each { isPR ->
275 def fullBuildJobName = Utilities.getFullJobName(project, 'perf_linux_build', isPR)
276 def architecture = 'x64'
277 def configuration = 'Release'
279 // Build has to happen on RHEL7.2 (that's where we produce the bits we ship)
280 ['RHEL7.2'].each { os ->
281 def newBuildJob = job(fullBuildJobName) {
283 shell("./build.sh verbose ${architecture} ${configuration}")
286 Utilities.setMachineAffinity(newBuildJob, os, 'latest-or-auto')
287 Utilities.standardJobSetup(newBuildJob, project, isPR, "*/${branch}")
288 Utilities.addArchival(newBuildJob, "bin/Product/**,bin/obj/*/tests/**/*.dylib,bin/obj/*/tests/**/*.so", "bin/Product/**/.nuget/**")
292 // Actual perf testing on the following OSes
293 def perfOSList = ['Ubuntu14.04']
294 perfOSList.each { os ->
295 def newJob = job(getFullPerfJobName(project, os, isPR)) {
297 label('linux_clr_perf')
300 string('BV_UPLOAD_SAS_TOKEN', 'CoreCLR Perf BenchView Sas')
306 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')
311 // Cap the maximum number of iterations to 21.
312 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')
313 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')
314 stringParam('PRODUCT_BUILD', '', 'Build number from which to copy down the CoreCLR Product binaries built for Linux')
317 def osGroup = getOSGroup(os)
318 def runType = isPR ? 'private' : 'rolling'
319 def benchViewName = isPR ? 'coreclr private \$BenchviewCommitName' : 'coreclr rolling \$GIT_BRANCH_WITHOUT_ORIGIN \$GIT_COMMIT'
322 shell("./tests/scripts/perf-prep.sh")
323 shell("./init-tools.sh")
324 copyArtifacts(fullBuildJobName) {
325 includePatterns("bin/**")
327 buildNumber('\${PRODUCT_BUILD}')
330 shell("GIT_BRANCH_WITHOUT_ORIGIN=\$(echo \$GIT_BRANCH | sed \"s/[^/]*\\/\\(.*\\)/\\1 /\")\n" +
331 "python3.5 \"\${WORKSPACE}/tests/scripts/Microsoft.BenchView.JSONFormat/tools/submission-metadata.py\" --name \" ${benchViewName} \" --user-email \"dotnet-bot@microsoft.com\"\n" +
332 "python3.5 \"\${WORKSPACE}/tests/scripts/Microsoft.BenchView.JSONFormat/tools/build.py\" git --branch \$GIT_BRANCH_WITHOUT_ORIGIN --type ${runType}")
333 shell("""./tests/scripts/run-xunit-perf.sh \\
334 --testRootDir=\"\${WORKSPACE}/bin/tests/Windows_NT.${architecture}.${configuration}\" \\
335 --testNativeBinDir=\"\${WORKSPACE}/bin/obj/${osGroup}.${architecture}.${configuration}/tests\" \\
336 --coreClrBinDir=\"\${WORKSPACE}/bin/Product/${osGroup}.${architecture}.${configuration}\" \\
337 --mscorlibDir=\"\${WORKSPACE}/bin/Product/${osGroup}.${architecture}.${configuration}\" \\
338 --coreFxBinDir=\"\${WORKSPACE}/corefx\" \\
339 --runType=\"${runType}\" \\
340 --benchViewOS=\"${os}\" \\
341 --generatebenchviewdata=\"\${WORKSPACE}/tests/scripts/Microsoft.BenchView.JSONFormat/tools\" \\
342 --stabilityPrefix=\"taskset 0x00000002 nice --adjustment=-10\" \\
343 --uploadToBenchview""")
344 shell("mkdir -p bin/toArchive/sandbox/Logs/")
345 shell("rsync -a bin/sandbox/Logs/Perf-*.* bin/toArchive/sandbox/Logs/")
349 def archiveSettings = new ArchivalSettings()
350 archiveSettings.addFiles('bin/toArchive/**')
351 archiveSettings.addFiles('machinedata.json')
353 Utilities.addArchival(newJob, archiveSettings)
354 Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
356 // For perf, we need to keep the run results longer
358 // Enable the log rotator
360 artifactDaysToKeep(30)
362 artifactNumToKeep(200)
373 def flowJobPerfRunList = perfOSList.collect { os ->
374 "{ build(params + [PRODUCT_BUILD: b.build.number], '${getFullPerfJobName(project, os, isPR)}') }"
376 def newFlowJob = buildFlowJob(Utilities.getFullJobName(project, "perf_linux_flow", isPR, '')) {
379 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')
383 // First, build the bits on RHEL7.2
384 b = build(params, '${fullBuildJobName}')
386 // Then, run the perf tests
388 ${flowJobPerfRunList.join(",\n ")}
393 Utilities.setMachineAffinity(newFlowJob, 'Windows_NT', 'latest-or-auto')
394 Utilities.standardJobSetup(newFlowJob, project, isPR, "*/${branch}")
397 TriggerBuilder builder = TriggerBuilder.triggerOnPullRequest()
398 builder.setGithubContext("Linux Perf Test Flow")
399 builder.triggerOnlyOnComment()
400 builder.setCustomTriggerPhrase("(?i).*test\\W+linux\\W+perf\\W+flow.*")
401 builder.triggerForBranch(branch)
402 builder.emitTrigger(newFlowJob)
405 // Set a push trigger
406 TriggerBuilder builder = TriggerBuilder.triggerOnCommit()
407 builder.emitTrigger(newFlowJob)
412 def static getFullThroughputJobName(def project, def os, def isPR) {
413 return Utilities.getFullJobName(project, "perf_throughput_${os}", isPR)
416 // Create the Linux/OSX/CentOS coreclr test leg for debug and release and each scenario
417 [true, false].each { isPR ->
418 def fullBuildJobName = Utilities.getFullJobName(project, 'perf_throughput_linux_build', isPR)
419 def architecture = 'x64'
420 def configuration = 'Release'
422 // Build has to happen on RHEL7.2 (that's where we produce the bits we ship)
423 ['RHEL7.2'].each { os ->
424 def newBuildJob = job(fullBuildJobName) {
426 shell("./build.sh verbose ${architecture} ${configuration}")
429 Utilities.setMachineAffinity(newBuildJob, os, 'latest-or-auto')
430 Utilities.standardJobSetup(newBuildJob, project, isPR, "*/${branch}")
431 Utilities.addArchival(newBuildJob, "bin/Product/**")
434 // Actual perf testing on the following OSes
435 def throughputOSList = ['Ubuntu14.04']
436 def throughputOptLevelList = ['full_opt', 'min_opt']
438 def throughputOSOptLevelList = []
440 throughputOSList.each { os ->
441 throughputOptLevelList.each { opt_level ->
442 throughputOSOptLevelList.add("${os}_${opt_level}")
446 throughputOSList.each { os ->
447 throughputOptLevelList.each { opt_level ->
448 def newJob = job(getFullThroughputJobName(project, "${os}_${opt_level}", isPR)) {
450 label('linux_clr_perf')
453 string('BV_UPLOAD_SAS_TOKEN', 'CoreCLR Perf BenchView Sas')
459 stringParam('BenchviewCommitName', '\${ghprbPullTitle}', 'The name that will be used to build the full title of a run in Benchview.')
464 stringParam('PRODUCT_BUILD', '', 'Build number from which to copy down the CoreCLR Product binaries built for Linux')
467 def osGroup = getOSGroup(os)
468 def runType = isPR ? 'private' : 'rolling'
469 def benchViewName = isPR ? 'coreclr-throughput private \$BenchviewCommitName' : 'coreclr-throughput rolling \$GIT_BRANCH_WITHOUT_ORIGIN \$GIT_COMMIT'
472 shell("bash ./tests/scripts/perf-prep.sh --throughput")
473 shell("./init-tools.sh")
474 copyArtifacts(fullBuildJobName) {
475 includePatterns("bin/Product/**")
477 buildNumber('\${PRODUCT_BUILD}')
480 shell("GIT_BRANCH_WITHOUT_ORIGIN=\$(echo \$GIT_BRANCH | sed \"s/[^/]*\\/\\(.*\\)/\\1 /\")\n" +
481 "python3.5 \"\${WORKSPACE}/tests/scripts/Microsoft.BenchView.JSONFormat/tools/submission-metadata.py\" --name \" ${benchViewName} \" --user-email \"dotnet-bot@microsoft.com\"\n" +
482 "python3.5 \"\${WORKSPACE}/tests/scripts/Microsoft.BenchView.JSONFormat/tools/build.py\" git --branch \$GIT_BRANCH_WITHOUT_ORIGIN --type ${runType}")
483 shell("""python3.5 ./tests/scripts/run-throughput-perf.py \\
484 -arch \"${architecture}\" \\
486 -configuration \"${configuration}\" \\
487 -opt_level \"${opt_level}\" \\
488 -clr_root \"\${WORKSPACE}\" \\
489 -assembly_root \"\${WORKSPACE}/Microsoft.Benchview.ThroughputBenchmarks.${architecture}.Windows_NT/lib\" \\
490 -run_type \"${runType}\" \\
491 -benchview_path \"\${WORKSPACE}/tests/scripts/Microsoft.BenchView.JSONFormat/tools\"""")
495 // Save machinedata.json to /artifact/bin/ Jenkins dir
496 def archiveSettings = new ArchivalSettings()
497 archiveSettings.addFiles('throughput-*.csv')
498 archiveSettings.addFiles('machinedata.json')
499 Utilities.addArchival(newJob, archiveSettings)
501 Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
503 // For perf, we need to keep the run results longer
505 // Enable the log rotator
507 artifactDaysToKeep(7)
509 artifactNumToKeep(25)
516 def flowJobTPRunList = throughputOSOptLevelList.collect { os ->
517 "{ build(params + [PRODUCT_BUILD: b.build.number], '${getFullThroughputJobName(project, os, isPR)}') }"
519 def newFlowJob = buildFlowJob(Utilities.getFullJobName(project, "perf_throughput_linux_flow", isPR, '')) {
522 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')
526 // First, build the bits on RHEL7.2
527 b = build(params, '${fullBuildJobName}')
529 // Then, run the perf tests
531 ${flowJobTPRunList.join(",\n ")}
536 Utilities.setMachineAffinity(newFlowJob, 'Windows_NT', 'latest-or-auto')
537 Utilities.standardJobSetup(newFlowJob, project, isPR, "*/${branch}")
540 TriggerBuilder builder = TriggerBuilder.triggerOnPullRequest()
541 builder.setGithubContext("Linux Throughput Perf Test Flow")
542 builder.triggerOnlyOnComment()
543 builder.setCustomTriggerPhrase("(?i).*test\\W+linux\\W+throughput\\W+flow.*")
544 builder.triggerForBranch(branch)
545 builder.emitTrigger(newFlowJob)
548 // Set a push trigger
549 TriggerBuilder builder = TriggerBuilder.triggerOnCommit()
550 builder.emitTrigger(newFlowJob)
555 // Setup CoreCLR-Scenarios tests
556 [true, false].each { isPR ->
557 ['Windows_NT'].each { os ->
558 ['x64', 'x86'].each { arch ->
559 ['ryujit'].each { jit ->
560 ['full_opt', 'min_opt', 'tiered'].each { opt_level ->
561 def architecture = arch
562 def newJob = job(Utilities.getFullJobName(project, "perf_scenarios_${os}_${arch}_${opt_level}_${jit}", isPR)) {
567 label('windows_server_2016_clr_perf')
570 string('BV_UPLOAD_SAS_TOKEN', 'CoreCLR Perf BenchView Sas')
576 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')
581 stringParam('XUNIT_PERFORMANCE_MAX_ITERATION', '1', 'Size test, one iteration is sufficient')
582 stringParam('XUNIT_PERFORMANCE_MAX_ITERATION_INNER_SPECIFIED', '1', 'Size test, one iteration is sufficient')
585 def configuration = 'Release'
586 def runType = isPR ? 'private' : 'rolling'
587 def benchViewName = isPR ? 'CoreCLR-Scenarios private %BenchviewCommitName%' : 'CoreCLR-Scenarios rolling %GIT_BRANCH_WITHOUT_ORIGIN% %GIT_COMMIT%'
588 def uploadString = '-uploadToBenchview'
592 batchFile("powershell wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile \"%WORKSPACE%\\nuget.exe\"")
593 batchFile("if exist \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\" rmdir /s /q \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\"")
594 batchFile("\"%WORKSPACE%\\nuget.exe\" install Microsoft.BenchView.JSONFormat -Source http://benchviewtestfeed.azurewebsites.net/nuget -OutputDirectory \"%WORKSPACE%\" -Prerelease -ExcludeVersion")
596 //Do this here to remove the origin but at the front of the branch name as this is a problem for BenchView
597 //we have to do it all as one statement because cmd is called each time and we lose the set environment variable
598 batchFile("if \"%GIT_BRANCH:~0,7%\" == \"origin/\" (set \"GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH:origin/=%\") else (set \"GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH%\")\n" +
599 "set \"BENCHVIEWNAME=${benchViewName}\"\n" +
600 "set \"BENCHVIEWNAME=%BENCHVIEWNAME:\"=\"\"%\"\n" +
601 "py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\submission-metadata.py\" --name \"%BENCHVIEWNAME%\" --user-email \"dotnet-bot@microsoft.com\"\n" +
602 "py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\build.py\" git --branch %GIT_BRANCH_WITHOUT_ORIGIN% --type ${runType}")
603 batchFile("py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\machinedata.py\"")
604 batchFile("set __TestIntermediateDir=int&&build.cmd ${configuration} ${architecture}")
606 batchFile("tests\\runtest.cmd ${configuration} ${architecture} GenerateLayoutOnly")
608 def runXUnitPerfCommonArgs = "-arch ${arch} -configuration ${configuration} -generateBenchviewData \"%WORKSPACE%\\Microsoft.Benchview.JSONFormat\\tools\" ${uploadString} -runtype ${runType} ${testEnv} -optLevel ${opt_level} -jitName ${jit} -scenarioTest"
611 batchFile("tests\\scripts\\run-xunit-perf.cmd ${runXUnitPerfCommonArgs} -testBinLoc bin\\tests\\${os}.${architecture}.${configuration}\\performance\\Scenario\\JitBench -group CoreCLR-Scenarios")
612 batchFile("xcopy.exe /VYQK bin\\sandbox\\Logs\\Perf-*.* bin\\toArchive\\sandbox\\Logs\\Scenario\\JitBench\\Off\\")
615 if (opt_level != 'min_opt') {
616 batchFile("tests\\scripts\\run-xunit-perf.cmd ${runXUnitPerfCommonArgs} -testBinLoc bin\\tests\\${os}.${architecture}.${configuration}\\performance\\Scenario\\JitBench -group CoreCLR-Scenarios -collectionFlags BranchMispredictions+CacheMisses+InstructionRetired")
617 batchFile("xcopy.exe /VYQK bin\\sandbox\\Logs\\Perf-*.* bin\\toArchive\\sandbox\\Logs\\Scenario\\JitBench\\On\\")
622 def archiveSettings = new ArchivalSettings()
623 archiveSettings.addFiles('bin/toArchive/**')
624 archiveSettings.addFiles('machinedata.json')
626 Utilities.addArchival(newJob, archiveSettings)
627 Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
631 artifactDaysToKeep(30)
633 artifactNumToKeep(200)
645 if (opt_level == 'min_opt') {
646 opts = '\\W+min_opts'
649 if (jit != 'ryujit') {
653 TriggerBuilder builder = TriggerBuilder.triggerOnPullRequest()
654 builder.setGithubContext("${os} ${arch} ${opt_level} ${jit} Performance Scenarios Tests")
655 builder.triggerOnlyOnComment()
656 builder.setCustomTriggerPhrase("(?i).*test\\W+${os}\\W+${arch}${opts}${jitt}\\W+perf\\W+scenarios.*")
657 builder.triggerForBranch(branch)
658 builder.emitTrigger(newJob)
661 // Set a push trigger
662 TriggerBuilder builder = TriggerBuilder.triggerOnCommit()
663 builder.emitTrigger(newJob)
671 // Setup size-on-disk test
672 ['Windows_NT'].each { os ->
673 ['x64', 'x86'].each { arch ->
674 def architecture = arch
675 def newJob = job(Utilities.getFullJobName(project, "sizeondisk_${arch}", false)) {
679 string('BV_UPLOAD_SAS_TOKEN', 'CoreCLR Perf BenchView Sas')
683 def channel = 'master'
684 def configuration = 'Release'
685 def runType = 'rolling'
686 def benchViewName = 'Dotnet Size on Disk %DATE% %TIME%'
687 def testBin = "%WORKSPACE%\\bin\\tests\\${os}.${architecture}.${configuration}"
688 def coreRoot = "${testBin}\\Tests\\Core_Root"
689 def benchViewTools = "%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools"
692 // Install nuget and get BenchView tools
693 batchFile("powershell wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile \"%WORKSPACE%\\nuget.exe\"")
694 batchFile("if exist \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\" rmdir /s /q \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\"")
695 batchFile("\"%WORKSPACE%\\nuget.exe\" install Microsoft.BenchView.JSONFormat -Source http://benchviewtestfeed.azurewebsites.net/nuget -OutputDirectory \"%WORKSPACE%\" -Prerelease -ExcludeVersion")
697 // Generate submission metadata for BenchView
698 // Do this here to remove the origin but at the front of the branch name as this is a problem for BenchView
699 // we have to do it all as one statement because cmd is called each time and we lose the set environment variable
700 batchFile("if \"%GIT_BRANCH:~0,7%\" == \"origin/\" (set \"GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH:origin/=%\") else (set \"GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH%\")\n" +
701 "set \"BENCHVIEWNAME=${benchViewName}\"\n" +
702 "set \"BENCHVIEWNAME=%BENCHVIEWNAME:\"=\"\"%\"\n" +
703 "py \"${benchViewTools}\\submission-metadata.py\" --name \"%BENCHVIEWNAME%\" --user-email \"dotnet-bot@microsoft.com\"\n" +
704 "py \"${benchViewTools}\\build.py\" git --branch %GIT_BRANCH_WITHOUT_ORIGIN% --type ${runType}")
706 // Generate machine data from BenchView
707 batchFile("py \"${benchViewTools}\\machinedata.py\"")
709 // Build CoreCLR and gnerate test layout
710 batchFile("set __TestIntermediateDir=int&&build.cmd ${configuration} ${architecture}")
711 batchFile("tests\\runtest.cmd ${configuration} ${architecture} GenerateLayoutOnly")
713 // Run the size on disk benchmark
714 batchFile("\"${coreRoot}\\CoreRun.exe\" \"${testBin}\\sizeondisk\\sodbench\\SoDBench\\SoDBench.exe\" -o \"%WORKSPACE%\\sodbench.csv\" --architecture ${arch} --channel ${channel}")
716 // From sodbench.csv, create measurment.json, then submission.json
717 batchFile("py \"${benchViewTools}\\measurement.py\" csv \"%WORKSPACE%\\sodbench.csv\" --metric \"Size on Disk\" --unit \"bytes\" --better \"desc\"")
718 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}")
720 // If this is a PR, upload submission.json
721 batchFile("py \"${benchViewTools}\\upload.py\" submission.json --container coreclr")
725 Utilities.setMachineAffinity(newJob, "Windows_NT", '20170427-elevated')
727 def archiveSettings = new ArchivalSettings()
728 archiveSettings.addFiles('bin/toArchive/**')
729 archiveSettings.addFiles('machinedata.json')
731 Utilities.addArchival(newJob, archiveSettings)
732 Utilities.standardJobSetup(newJob, project, false, "*/${branch}")
734 // Set the cron job here. We run nightly on each flavor, regardless of code changes
735 Utilities.addPeriodicTrigger(newJob, "@daily", true /*always run*/)
739 artifactDaysToKeep(30)
741 artifactNumToKeep(200)
753 // Setup IlLink tests
754 [true, false].each { isPR ->
755 ['Windows_NT'].each { os ->
756 ['x64'].each { arch ->
757 ['ryujit'].each { jit ->
758 ['full_opt'].each { opt_level ->
759 def architecture = arch
760 def newJob = job(Utilities.getFullJobName(project, "perf_illink_${os}_${arch}_${opt_level}_${jit}", isPR)) {
765 string('BV_UPLOAD_SAS_TOKEN', 'CoreCLR Perf BenchView Sas')
771 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')
776 stringParam('XUNIT_PERFORMANCE_MAX_ITERATION', '1', 'Size test, one iteration is sufficient')
777 stringParam('XUNIT_PERFORMANCE_MAX_ITERATION_INNER_SPECIFIED', '1', 'Size test, one iteration is sufficient')
780 def configuration = 'Release'
781 def runType = isPR ? 'private' : 'rolling'
782 def benchViewName = isPR ? 'CoreCLR-Scenarios private %BenchviewCommitName%' : 'CoreCLR-Scenarios rolling %GIT_BRANCH_WITHOUT_ORIGIN% %GIT_COMMIT%'
783 def uploadString = '-uploadToBenchview'
787 batchFile("powershell wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile \"%WORKSPACE%\\nuget.exe\"")
788 batchFile("if exist \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\" rmdir /s /q \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\"")
789 batchFile("\"%WORKSPACE%\\nuget.exe\" install Microsoft.BenchView.JSONFormat -Source http://benchviewtestfeed.azurewebsites.net/nuget -OutputDirectory \"%WORKSPACE%\" -Prerelease -ExcludeVersion")
791 //Do this here to remove the origin but at the front of the branch name as this is a problem for BenchView
792 //we have to do it all as one statement because cmd is called each time and we lose the set environment variable
793 batchFile("if \"%GIT_BRANCH:~0,7%\" == \"origin/\" (set \"GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH:origin/=%\") else (set \"GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH%\")\n" +
794 "set \"BENCHVIEWNAME=${benchViewName}\"\n" +
795 "set \"BENCHVIEWNAME=%BENCHVIEWNAME:\"=\"\"%\"\n" +
796 "py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\submission-metadata.py\" --name \"%BENCHVIEWNAME%\" --user-email \"dotnet-bot@microsoft.com\"\n" +
797 "py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\build.py\" git --branch %GIT_BRANCH_WITHOUT_ORIGIN% --type ${runType}")
798 batchFile("py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\machinedata.py\"")
799 batchFile("set __TestIntermediateDir=int&&build.cmd ${configuration} ${architecture}")
801 batchFile("tests\\runtest.cmd ${configuration} ${architecture} GenerateLayoutOnly")
803 def runXUnitPerfCommonArgs = "-arch ${arch} -configuration ${configuration} -generateBenchviewData \"%WORKSPACE%\\Microsoft.Benchview.JSONFormat\\tools\" ${uploadString} -runtype ${runType} ${testEnv} -optLevel ${opt_level} -jitName ${jit} -scenarioTest"
806 batchFile("tests\\scripts\\run-xunit-perf.cmd ${runXUnitPerfCommonArgs} -testBinLoc bin\\tests\\${os}.${architecture}.${configuration}\\performance\\linkbench\\linkbench -group ILLink -nowarmup")
807 batchFile("xcopy.exe /VYQK bin\\sandbox\\Logs\\Perf-*.* bin\\toArchive\\sandbox\\Logs\\Scenario\\LinkBench\\")
811 def archiveSettings = new ArchivalSettings()
812 archiveSettings.addFiles('bin/toArchive/**')
813 archiveSettings.addFiles('machinedata.json')
815 // Set the label (currently we are only measuring size, therefore we are running on VM).
816 Utilities.setMachineAffinity(newJob, "Windows_NT", '20170427-elevated')
817 Utilities.addArchival(newJob, archiveSettings)
818 Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
822 artifactDaysToKeep(30)
824 artifactNumToKeep(200)
835 TriggerBuilder builder = TriggerBuilder.triggerOnPullRequest()
836 builder.setGithubContext("${os} ${arch} ${opt_level} ${jit} IlLink Tests")
837 builder.triggerOnlyOnComment()
838 builder.setCustomTriggerPhrase("(?i).*test\\W+${os}\\W+${arch}\\W+illink.*")
839 builder.triggerForBranch(branch)
840 builder.emitTrigger(newJob)
843 // Set a push trigger
844 TriggerBuilder builder = TriggerBuilder.triggerOnCommit()
845 builder.emitTrigger(newJob)
853 Utilities.createHelperJob(this, project, branch,
854 "Welcome to the ${project} Perf help",