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 [true, false].each { isSmoketest ->
33 def architecture = arch
34 def jobName = isSmoketest ? "perf_perflab_${os}_${arch}_smoketest" : "perf_perflab_${os}_${arch}"
36 if (arch == 'x86jit32')
39 testEnv = '-testEnv %WORKSPACE%\\tests\\x86\\compatjit_x86_testenv.cmd'
41 else if (arch == 'x86')
43 testEnv = '-testEnv %WORKSPACE%\\tests\\x86\\ryujit_x86_testenv.cmd'
46 def newJob = job(Utilities.getFullJobName(project, jobName, isPR)) {
48 label('windows_clr_perf')
51 string('BV_UPLOAD_SAS_TOKEN', 'CoreCLR Perf BenchView Sas')
59 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')
66 stringParam('XUNIT_PERFORMANCE_MAX_ITERATION', '2', 'Sets the number of iterations to two. We want to do this so that we can run as fast as possible as this is just for smoke testing')
67 stringParam('XUNIT_PERFORMANCE_MAX_ITERATION_INNER_SPECIFIED', '2', 'Sets the number of iterations to two. We want to do this so that we can run as fast as possible as this is just for smoke testing')
74 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 enought to get a good sample')
75 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 enought to get a good sample')
78 def configuration = 'Release'
79 def runType = isPR ? 'private' : 'rolling'
80 def benchViewName = isPR ? 'coreclr private %BenchviewCommitName%' : 'coreclr rolling %GIT_BRANCH_WITHOUT_ORIGIN% %GIT_COMMIT%'
81 def uploadString = isSmoketest ? '' : '-uploadToBenchview'
86 batchFile("powershell wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile \"%WORKSPACE%\\nuget.exe\"")
87 batchFile("if exist \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\" rmdir /s /q \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\"")
88 batchFile("\"%WORKSPACE%\\nuget.exe\" install Microsoft.BenchView.JSONFormat -Source http://benchviewtestfeed.azurewebsites.net/nuget -OutputDirectory \"%WORKSPACE%\" -Prerelease -ExcludeVersion")
89 //Do this here to remove the origin but at the front of the branch name as this is a problem for BenchView
90 //we have to do it all as one statement because cmd is called each time and we lose the set environment variable
91 batchFile("if \"%GIT_BRANCH:~0,7%\" == \"origin/\" (set \"GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH:origin/=%\") else (set \"GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH%\")\n" +
92 "set \"BENCHVIEWNAME=${benchViewName}\"\n" +
93 "set \"BENCHVIEWNAME=%BENCHVIEWNAME:\"=%\"\n" +
94 "py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\submission-metadata.py\" --name \"%BENCHVIEWNAME%\" --user \"dotnet-bot@microsoft.com\"\n" +
95 "py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\build.py\" git --branch %GIT_BRANCH_WITHOUT_ORIGIN% --type ${runType}")
96 batchFile("py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\machinedata.py\"")
97 batchFile("set __TestIntermediateDir=int&&build.cmd ${configuration} ${architecture}")
99 if (arch == 'x86jit32')
101 // Download package and copy compatjit into Core_Root
102 batchFile("C:\\Tools\\nuget.exe install runtime.win7-${architecture}.Microsoft.NETCore.Jit -Source https://dotnet.myget.org/F/dotnet-core -OutputDirectory \"%WORKSPACE%\" -Prerelease -ExcludeVersion\n" +
103 "xcopy \"%WORKSPACE%\\runtime.win7-x86.Microsoft.NETCore.Jit\\runtimes\\win7-x86\\native\\compatjit.dll\" \"%WORKSPACE%\\bin\\Product\\${os}.${architecture}.${configuration}\" /Y")
106 batchFile("tests\\runtest.cmd ${configuration} ${architecture} GenerateLayoutOnly")
108 // Run with just stopwatch: Profile=Off
109 batchFile("tests\\scripts\\run-xunit-perf.cmd -arch ${arch} -configuration ${configuration} -testBinLoc bin\\tests\\${os}.${architecture}.${configuration}\\performance\\perflab\\Perflab -library -generateBenchviewData \"%WORKSPACE%\\Microsoft.Benchview.JSONFormat\\tools\" ${uploadString} -runtype ${runType} -stabilityPrefix \"START \"CORECLR_PERF_RUN\" /B /WAIT /HIGH /AFFINITY 0x2\"")
110 batchFile("tests\\scripts\\run-xunit-perf.cmd -arch ${arch} -configuration ${configuration} -testBinLoc bin\\tests\\${os}.${architecture}.${configuration}\\Jit\\Performance\\CodeQuality -generateBenchviewData \"%WORKSPACE%\\Microsoft.Benchview.JSONFormat\\tools\" ${uploadString} -runtype ${runType} -stabilityPrefix \"START \"CORECLR_PERF_RUN\" /B /WAIT /HIGH /AFFINITY 0x2\"")
111 batchFile("tests\\scripts\\run-xunit-perf.cmd -arch ${arch} -configuration ${configuration} -testBinLoc bin\\tests\\${os}.${architecture}.${configuration}\\performance\\linkbench\\linkbench -generateBenchviewData \"%WORKSPACE%\\Microsoft.Benchview.JSONFormat\\tools\" ${uploadString} -nowarmup -runtype ${runType} -scenarioTest -group ILLink")
113 // Run with the full set of counters enabled: Profile=On
114 batchFile("tests\\scripts\\run-xunit-perf.cmd -arch ${arch} -configuration ${configuration} -testBinLoc bin\\tests\\${os}.${architecture}.${configuration}\\performance\\perflab\\Perflab -library -generateBenchviewData \"%WORKSPACE%\\Microsoft.Benchview.JSONFormat\\tools\" ${uploadString} -runtype ${runType} -collectionFlags default+BranchMispredictions+CacheMisses+InstructionRetired+gcapi -stabilityPrefix \"START \"CORECLR_PERF_RUN\" /B /WAIT /HIGH /AFFINITY 0x2\"")
115 batchFile("tests\\scripts\\run-xunit-perf.cmd -arch ${arch} -configuration ${configuration} -testBinLoc bin\\tests\\${os}.${architecture}.${configuration}\\Jit\\Performance\\CodeQuality -generateBenchviewData \"%WORKSPACE%\\Microsoft.Benchview.JSONFormat\\tools\" ${uploadString} -runtype ${runType} -collectionFlags default+BranchMispredictions+CacheMisses+InstructionRetired+gcapi -stabilityPrefix \"START \"CORECLR_PERF_RUN\" /B /WAIT /HIGH /AFFINITY 0x2\"")
121 Utilities.setMachineAffinity(newJob, "Windows_NT", '20170427-elevated')
123 // Save machinedata.json to /artifact/bin/ Jenkins dir
124 def archiveSettings = new ArchivalSettings()
125 archiveSettings.addFiles('Perf-*.xml')
126 archiveSettings.addFiles('Perf-*.etl')
127 archiveSettings.addFiles('Perf-*.log')
128 archiveSettings.addFiles('machinedata.json')
129 Utilities.addArchival(newJob, archiveSettings)
131 Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
142 TriggerBuilder builder = TriggerBuilder.triggerOnPullRequest()
145 builder.setGithubContext("${os} ${arch} CoreCLR Perf Tests Correctness")
149 builder.setGithubContext("${os} ${arch} CoreCLR Perf Tests")
150 builder.triggerOnlyOnComment()
151 builder.setCustomTriggerPhrase("(?i).*test\\W+${os}\\W+${arch}\\W+perf.*")
153 builder.triggerForBranch(branch)
154 builder.emitTrigger(newJob)
157 // Set a push trigger
158 TriggerBuilder builder = TriggerBuilder.triggerOnCommit()
159 builder.emitTrigger(newJob)
166 // Setup throughput perflab tests runs
167 [true, false].each { isPR ->
168 ['Windows_NT'].each { os ->
169 ['x64', 'x86'].each { arch ->
170 def architecture = arch
172 def newJob = job(Utilities.getFullJobName(project, "perf_throughput_perflab_${os}_${arch}", isPR)) {
174 label('windows_clr_perf')
177 string('BV_UPLOAD_SAS_TOKEN', 'CoreCLR Perf BenchView Sas')
185 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')
188 def configuration = 'Release'
189 def runType = isPR ? 'private' : 'rolling'
190 def benchViewName = isPR ? 'coreclr-throughput private %BenchviewCommitName%' : 'coreclr-throughput rolling %GIT_BRANCH_WITHOUT_ORIGIN% %GIT_COMMIT%'
195 batchFile("if exist \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\" rmdir /s /q \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\"")
196 batchFile("if exist \"%WORKSPACE%\\Microsoft.BenchView.ThroughputBenchmarks.${architecture}.${os}\" rmdir /s /q \"%WORKSPACE%\\Microsoft.BenchView.ThroughputBenchmarks.${architecture}.${os}\"")
197 batchFile("C:\\Tools\\nuget.exe install Microsoft.BenchView.JSONFormat -Source http://benchviewtestfeed.azurewebsites.net/nuget -OutputDirectory \"%WORKSPACE%\" -Prerelease -ExcludeVersion")
198 batchFile("C:\\Tools\\nuget.exe install Microsoft.BenchView.ThroughputBenchmarks.${architecture}.${os} -Source https://dotnet.myget.org/F/dotnet-core -OutputDirectory \"%WORKSPACE%\" -Prerelease -ExcludeVersion")
199 //Do this here to remove the origin but at the front of the branch name as this is a problem for BenchView
200 //we have to do it all as one statement because cmd is called each time and we lose the set environment variable
201 batchFile("if \"%GIT_BRANCH:~0,7%\" == \"origin/\" (set \"GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH:origin/=%\") else (set \"GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH%\")\n" +
202 "set \"BENCHVIEWNAME=${benchViewName}\"\n" +
203 "set \"BENCHVIEWNAME=%BENCHVIEWNAME:\"=%\"\n" +
204 "py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\submission-metadata.py\" --name \"${benchViewName}\" --user \"dotnet-bot@microsoft.com\"\n" +
205 "py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\build.py\" git --branch %GIT_BRANCH_WITHOUT_ORIGIN% --type ${runType}")
206 batchFile("py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\machinedata.py\"")
207 batchFile("set __TestIntermediateDir=int&&build.cmd ${configuration} ${architecture} skiptests")
208 batchFile("tests\\runtest.cmd ${configuration} ${architecture} GenerateLayoutOnly")
209 batchFile("py -u tests\\scripts\\run-throughput-perf.py -arch ${arch} -os ${os} -configuration ${configuration} -clr_root \"%WORKSPACE%\" -assembly_root \"%WORKSPACE%\\Microsoft.BenchView.ThroughputBenchmarks.${architecture}.${os}\\lib\" -benchview_path \"%WORKSPACE%\\Microsoft.Benchview.JSONFormat\\tools\" -run_type ${runType}")
213 // Save machinedata.json to /artifact/bin/ Jenkins dir
214 def archiveSettings = new ArchivalSettings()
215 archiveSettings.addFiles('throughput-*.csv')
216 Utilities.addArchival(newJob, archiveSettings)
218 Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
221 TriggerBuilder builder = TriggerBuilder.triggerOnPullRequest()
222 builder.setGithubContext("${os} ${arch} CoreCLR Throughput Perf Tests")
223 builder.triggerOnlyOnComment()
224 builder.setCustomTriggerPhrase("(?i).*test\\W+${os}\\W+${arch}\\W+throughput.*")
225 builder.triggerForBranch(branch)
226 builder.emitTrigger(newJob)
229 // Set a push trigger
230 TriggerBuilder builder = TriggerBuilder.triggerOnCommit()
231 builder.emitTrigger(newJob)
237 // Create the Linux/OSX/CentOS coreclr test leg for debug and release and each scenario
238 [true, false].each { isPR ->
239 ['Ubuntu14.04'].each { os ->
240 def newJob = job(Utilities.getFullJobName(project, "perf_${os}", isPR)) {
242 label('linux_clr_perf')
245 string('BV_UPLOAD_SAS_TOKEN', 'CoreCLR Perf BenchView Sas')
253 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')
257 // Cap the maximum number of iterations to 21.
259 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 enought to get a good sample')
260 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 enought to get a good sample')
263 def osGroup = getOSGroup(os)
264 def architecture = 'x64'
265 def configuration = 'Release'
266 def runType = isPR ? 'private' : 'rolling'
267 def benchViewName = isPR ? 'coreclr private \$BenchviewCommitName' : 'coreclr rolling \$GIT_BRANCH_WITHOUT_ORIGIN \$GIT_COMMIT'
270 shell("./tests/scripts/perf-prep.sh")
271 shell("./init-tools.sh")
272 shell("./build.sh ${architecture} ${configuration}")
273 shell("GIT_BRANCH_WITHOUT_ORIGIN=\$(echo \$GIT_BRANCH | sed \"s/[^/]*\\/\\(.*\\)/\\1 /\")\n" +
274 "python3.5 \"\${WORKSPACE}/tests/scripts/Microsoft.BenchView.JSONFormat/tools/submission-metadata.py\" --name \" ${benchViewName} \" --user \"dotnet-bot@microsoft.com\"\n" +
275 "python3.5 \"\${WORKSPACE}/tests/scripts/Microsoft.BenchView.JSONFormat/tools/build.py\" git --branch \$GIT_BRANCH_WITHOUT_ORIGIN --type ${runType}")
276 shell("""./tests/scripts/run-xunit-perf.sh \\
277 --testRootDir=\"\${WORKSPACE}/bin/tests/Windows_NT.${architecture}.${configuration}\" \\
278 --testNativeBinDir=\"\${WORKSPACE}/bin/obj/${osGroup}.${architecture}.${configuration}/tests\" \\
279 --coreClrBinDir=\"\${WORKSPACE}/bin/Product/${osGroup}.${architecture}.${configuration}\" \\
280 --mscorlibDir=\"\${WORKSPACE}/bin/Product/${osGroup}.${architecture}.${configuration}\" \\
281 --coreFxBinDir=\"\${WORKSPACE}/corefx\" \\
282 --runType=\"${runType}\" \\
283 --benchViewOS=\"${os}\" \\
284 --generatebenchviewdata=\"\${WORKSPACE}/tests/scripts/Microsoft.BenchView.JSONFormat/tools\" \\
285 --stabilityPrefix=\"taskset 0x00000002 nice --adjustment=-10\" \\
286 --uploadToBenchview""")
290 // Save machinedata.json to /artifact/bin/ Jenkins dir
291 def archiveSettings = new ArchivalSettings()
292 archiveSettings.addFiles('Perf-*.log')
293 archiveSettings.addFiles('Perf-*.xml')
294 archiveSettings.addFiles('machinedata.json')
295 Utilities.addArchival(newJob, archiveSettings)
297 Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
299 // For perf, we need to keep the run results longer
301 // Enable the log rotator
303 artifactDaysToKeep(7)
305 artifactNumToKeep(25)
310 TriggerBuilder builder = TriggerBuilder.triggerOnPullRequest()
311 builder.setGithubContext("${os} Perf Tests")
312 builder.triggerOnlyOnComment()
313 builder.setCustomTriggerPhrase("(?i).*test\\W+${os}\\W+perf.*")
314 builder.triggerForBranch(branch)
315 builder.emitTrigger(newJob)
318 // Set a push trigger
319 TriggerBuilder builder = TriggerBuilder.triggerOnCommit()
320 builder.emitTrigger(newJob)
325 // Create the Linux/OSX/CentOS coreclr test leg for debug and release and each scenario
326 [true, false].each { isPR ->
327 ['Ubuntu14.04'].each { os ->
328 def newJob = job(Utilities.getFullJobName(project, "perf_throughput_${os}", isPR)) {
330 label('linux_clr_perf')
333 string('BV_UPLOAD_SAS_TOKEN', 'CoreCLR Perf BenchView Sas')
341 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')
344 def osGroup = getOSGroup(os)
345 def architecture = 'x64'
346 def configuration = 'Release'
347 def runType = isPR ? 'private' : 'rolling'
348 def benchViewName = isPR ? 'coreclr private \$BenchviewCommitName' : 'coreclr rolling \$GIT_BRANCH_WITHOUT_ORIGIN \$GIT_COMMIT'
351 shell("bash ./tests/scripts/perf-prep.sh --throughput")
352 shell("./init-tools.sh")
353 shell("./build.sh ${architecture} ${configuration}")
354 shell("GIT_BRANCH_WITHOUT_ORIGIN=\$(echo \$GIT_BRANCH | sed \"s/[^/]*\\/\\(.*\\)/\\1 /\")\n" +
355 "python3.5 \"\${WORKSPACE}/tests/scripts/Microsoft.BenchView.JSONFormat/tools/submission-metadata.py\" --name \" ${benchViewName} \" --user \"dotnet-bot@microsoft.com\"\n" +
356 "python3.5 \"\${WORKSPACE}/tests/scripts/Microsoft.BenchView.JSONFormat/tools/build.py\" git --branch \$GIT_BRANCH_WITHOUT_ORIGIN --type ${runType}")
357 shell("""sudo -E python3.5 ./tests/scripts/run-throughput-perf.py \\
358 -arch \"${architecture}\" \\
360 -configuration \"${configuration}\" \\
361 -clr_root \"\${WORKSPACE}\" \\
362 -assembly_root \"\${WORKSPACE}/_/fx/bin/runtime/netcoreapp-${osGroup}-${configuration}-${architecture}\" \\
363 -run_type \"${runType}\" \\
364 -benchview_path \"\${WORKSPACE}/tests/scripts/Microsoft.BenchView.JSONFormat/tools\"""")
368 // Save machinedata.json to /artifact/bin/ Jenkins dir
369 def archiveSettings = new ArchivalSettings()
370 archiveSettings.addFiles('throughput-*.csv')
371 archiveSettings.addFiles('machinedata.json')
372 Utilities.addArchival(newJob, archiveSettings)
374 Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
376 // For perf, we need to keep the run results longer
378 // Enable the log rotator
380 artifactDaysToKeep(7)
382 artifactNumToKeep(25)
387 TriggerBuilder builder = TriggerBuilder.triggerOnPullRequest()
388 builder.setGithubContext("${os} Throughput Perf Tests")
389 builder.triggerOnlyOnComment()
390 builder.setCustomTriggerPhrase("(?i).*test\\W+${os}\\W+throughput.*")
391 builder.triggerForBranch(branch)
392 builder.emitTrigger(newJob)
395 // Set a push trigger
396 TriggerBuilder builder = TriggerBuilder.triggerOnCommit()
397 builder.emitTrigger(newJob)