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}"
27 // Setup perflab tests runs
28 [true, false].each { isPR ->
29 ['Windows_NT'].each { os ->
30 ['x64', 'x86'].each { arch ->
31 [true, false].each { isSmoketest ->
32 def architecture = arch
33 def jobName = isSmoketest ? "perf_perflab_${os}_${arch}_smoketest" : "perf_perflab_${os}_${arch}"
35 if (arch == 'x86jit32')
38 testEnv = '-testEnv %WORKSPACE%\\tests\\x86\\compatjit_x86_testenv.cmd'
40 else if (arch == 'x86')
42 testEnv = '-testEnv %WORKSPACE%\\tests\\x86\\ryujit_x86_testenv.cmd'
45 def newJob = job(Utilities.getFullJobName(project, jobName, isPR)) {
47 label('windows_clr_perf')
50 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')
65 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')
66 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')
73 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')
74 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')
77 def configuration = 'Release'
78 def runType = isPR ? 'private' : 'rolling'
79 def benchViewName = isPR ? 'coreclr private %BenchviewCommitName%' : 'coreclr rolling %GIT_BRANCH_WITHOUT_ORIGIN% %GIT_COMMIT%'
80 def uploadString = isSmoketest ? '' : '-uploadToBenchview'
85 batchFile("powershell wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile \"%WORKSPACE%\\nuget.exe\"")
86 batchFile("if exist \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\" rmdir /s /q \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\"")
87 batchFile("\"%WORKSPACE%\\nuget.exe\" install Microsoft.BenchView.JSONFormat -Source http://benchviewtestfeed.azurewebsites.net/nuget -OutputDirectory \"%WORKSPACE%\" -Prerelease -ExcludeVersion")
88 //Do this here to remove the origin but at the front of the branch name as this is a problem for BenchView
89 //we have to do it all as one statement because cmd is called each time and we lose the set environment variable
90 batchFile("if [%GIT_BRANCH:~0,7%] == [origin/] (set GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH:origin/=%) else (set GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH%)\n" +
91 "set BENCHVIEWNAME=${benchViewName}\n" +
92 "set BENCHVIEWNAME=%BENCHVIEWNAME:\"=%\n" +
93 "py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\submission-metadata.py\" --name \"%BENCHVIEWNAME%\" --user \"dotnet-bot@microsoft.com\"\n" +
94 "py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\build.py\" git --branch %GIT_BRANCH_WITHOUT_ORIGIN% --type ${runType}")
95 batchFile("py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\machinedata.py\"")
96 batchFile("set __TestIntermediateDir=int&&build.cmd ${configuration} ${architecture}")
98 if (arch == 'x86jit32')
100 // Download package and copy compatjit into Core_Root
101 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" +
102 "xcopy \"%WORKSPACE%\\runtime.win7-x86.Microsoft.NETCore.Jit\\runtimes\\win7-x86\\native\\compatjit.dll\" \"%WORKSPACE%\\bin\\Product\\${os}.${architecture}.${configuration}\" /Y")
105 batchFile("tests\\runtest.cmd ${configuration} ${architecture} GenerateLayoutOnly")
107 // Run with just stopwatch
108 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\"")
109 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\"")
110 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")
112 // Run with the full set of counters enabled
113 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\"")
114 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\"")
120 Utilities.setMachineAffinity(newJob, "Windows_NT", '20170427-elevated')
122 // Save machinedata.json to /artifact/bin/ Jenkins dir
123 def archiveSettings = new ArchivalSettings()
124 archiveSettings.addFiles('Perf-*.xml')
125 archiveSettings.addFiles('Perf-*.etl')
126 Utilities.addArchival(newJob, archiveSettings)
128 Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
139 TriggerBuilder builder = TriggerBuilder.triggerOnPullRequest()
142 builder.setGithubContext("${os} ${arch} CoreCLR Perf Tests Correctness")
143 builder.triggerOnlyOnComment()
144 builder.setCustomTriggerPhrase("(?i).*test\\W+${os}\\W+${arch}\\W+perf correctness.*")
148 builder.setGithubContext("${os} ${arch} CoreCLR Perf Tests")
149 builder.triggerOnlyOnComment()
150 builder.setCustomTriggerPhrase("(?i).*test\\W+${os}\\W+${arch}\\W+perf.*")
152 builder.triggerForBranch(branch)
153 builder.emitTrigger(newJob)
156 // Set a push trigger
157 TriggerBuilder builder = TriggerBuilder.triggerOnCommit()
158 builder.emitTrigger(newJob)
165 // Setup throughput perflab tests runs
166 [true, false].each { isPR ->
167 ['Windows_NT'].each { os ->
168 ['x64', 'x86'].each { arch ->
169 def architecture = arch
171 def newJob = job(Utilities.getFullJobName(project, "perf_throughput_perflab_${os}_${arch}", isPR)) {
173 label('windows_clr_perf')
176 string('BV_UPLOAD_SAS_TOKEN', 'CoreCLR Perf BenchView Sas')
184 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')
187 def configuration = 'Release'
188 def runType = isPR ? 'private' : 'rolling'
189 def benchViewName = isPR ? 'coreclr-throughput private %BenchviewCommitName%' : 'coreclr-throughput rolling %GIT_BRANCH_WITHOUT_ORIGIN% %GIT_COMMIT%'
194 batchFile("if exist \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\" rmdir /s /q \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\"")
195 batchFile("if exist \"%WORKSPACE%\\Microsoft.BenchView.ThroughputBenchmarks.${architecture}.${os}\" rmdir /s /q \"%WORKSPACE%\\Microsoft.BenchView.ThroughputBenchmarks.${architecture}.${os}\"")
196 batchFile("C:\\Tools\\nuget.exe install Microsoft.BenchView.JSONFormat -Source http://benchviewtestfeed.azurewebsites.net/nuget -OutputDirectory \"%WORKSPACE%\" -Prerelease -ExcludeVersion")
197 batchFile("C:\\Tools\\nuget.exe install Microsoft.BenchView.ThroughputBenchmarks.${architecture}.${os} -Source https://dotnet.myget.org/F/dotnet-core -OutputDirectory \"%WORKSPACE%\" -Prerelease -ExcludeVersion")
198 //Do this here to remove the origin but at the front of the branch name as this is a problem for BenchView
199 //we have to do it all as one statement because cmd is called each time and we lose the set environment variable
200 batchFile("if [%GIT_BRANCH:~0,7%] == [origin/] (set GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH:origin/=%) else (set GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH%)\n" +
201 "set BENCHVIEWNAME=${benchViewName}\n" +
202 "set BENCHVIEWNAME=%BENCHVIEWNAME:\"=%\n" +
203 "py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\submission-metadata.py\" --name \"${benchViewName}\" --user \"dotnet-bot@microsoft.com\"\n" +
204 "py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\build.py\" git --branch %GIT_BRANCH_WITHOUT_ORIGIN% --type ${runType}")
205 batchFile("py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\machinedata.py\"")
206 batchFile("set __TestIntermediateDir=int&&build.cmd ${configuration} ${architecture} skiptests")
207 batchFile("tests\\runtest.cmd ${configuration} ${architecture} GenerateLayoutOnly")
208 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}")
212 // Save machinedata.json to /artifact/bin/ Jenkins dir
213 def archiveSettings = new ArchivalSettings()
214 archiveSettings.addFiles('throughput-*.csv')
215 Utilities.addArchival(newJob, archiveSettings)
217 Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
220 TriggerBuilder builder = TriggerBuilder.triggerOnPullRequest()
221 builder.setGithubContext("${os} ${arch} CoreCLR Throughput Perf Tests")
222 builder.triggerOnlyOnComment()
223 builder.setCustomTriggerPhrase("(?i).*test\\W+${os}\\W+${arch}\\W+throughput.*")
224 builder.triggerForBranch(branch)
225 builder.emitTrigger(newJob)
228 // Set a push trigger
229 TriggerBuilder builder = TriggerBuilder.triggerOnCommit()
230 builder.emitTrigger(newJob)
236 // Create the Linux/OSX/CentOS coreclr test leg for debug and release and each scenario
237 [true, false].each { isPR ->
238 ['Ubuntu14.04'].each { os ->
239 def newJob = job(Utilities.getFullJobName(project, "perf_${os}", isPR)) {
241 label('linux_clr_perf')
244 string('BV_UPLOAD_SAS_TOKEN', 'CoreCLR Perf BenchView Sas')
252 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')
255 def osGroup = getOSGroup(os)
256 def architecture = 'x64'
257 def configuration = 'Release'
258 def runType = isPR ? 'private' : 'rolling'
259 def benchViewName = isPR ? 'coreclr private \$BenchviewCommitName' : 'coreclr rolling \$GIT_BRANCH_WITHOUT_ORIGIN \$GIT_COMMIT'
262 shell("bash ./tests/scripts/perf-prep.sh")
263 shell("./init-tools.sh")
264 shell("./build.sh ${architecture} ${configuration}")
265 shell("GIT_BRANCH_WITHOUT_ORIGIN=\$(echo \$GIT_BRANCH | sed \"s/[^/]*\\/\\(.*\\)/\\1 /\")\n" +
266 "python3.5 \"\${WORKSPACE}/tests/scripts/Microsoft.BenchView.JSONFormat/tools/submission-metadata.py\" --name \" ${benchViewName} \" --user \"dotnet-bot@microsoft.com\"\n" +
267 "python3.5 \"\${WORKSPACE}/tests/scripts/Microsoft.BenchView.JSONFormat/tools/build.py\" git --branch \$GIT_BRANCH_WITHOUT_ORIGIN --type ${runType}")
268 shell("""sudo -E bash ./tests/scripts/run-xunit-perf.sh \\
269 --testRootDir=\"\${WORKSPACE}/bin/tests/Windows_NT.${architecture}.${configuration}\" \\
270 --testNativeBinDir=\"\${WORKSPACE}/bin/obj/${osGroup}.${architecture}.${configuration}/tests\" \\
271 --coreClrBinDir=\"\${WORKSPACE}/bin/Product/${osGroup}.${architecture}.${configuration}\" \\
272 --mscorlibDir=\"\${WORKSPACE}/bin/Product/${osGroup}.${architecture}.${configuration}\" \\
273 --coreFxBinDir=\"\${WORKSPACE}/corefx\" \\
274 --runType=\"${runType}\" \\
275 --benchViewOS=\"${os}\" \\
276 --uploadToBenchview""")
280 // Save machinedata.json to /artifact/bin/ Jenkins dir
281 def archiveSettings = new ArchivalSettings()
282 archiveSettings.addFiles('sandbox/perf-*.xml')
283 archiveSettings.addFiles('machinedata.json')
284 Utilities.addArchival(newJob, archiveSettings)
286 Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
288 // For perf, we need to keep the run results longer
290 // Enable the log rotator
292 artifactDaysToKeep(7)
294 artifactNumToKeep(25)
299 TriggerBuilder builder = TriggerBuilder.triggerOnPullRequest()
300 builder.setGithubContext("${os} Perf Tests")
301 builder.triggerOnlyOnComment()
302 builder.setCustomTriggerPhrase("(?i).*test\\W+${os}\\W+perf.*")
303 builder.triggerForBranch(branch)
304 builder.emitTrigger(newJob)
307 // Set a push trigger
308 TriggerBuilder builder = TriggerBuilder.triggerOnCommit()
309 builder.emitTrigger(newJob)
314 // Create the Linux/OSX/CentOS coreclr test leg for debug and release and each scenario
315 [true, false].each { isPR ->
316 ['Ubuntu14.04'].each { os ->
317 def newJob = job(Utilities.getFullJobName(project, "perf_throughput_${os}", isPR)) {
319 label('linux_clr_perf')
322 string('BV_UPLOAD_SAS_TOKEN', 'CoreCLR Perf BenchView Sas')
330 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')
333 def osGroup = getOSGroup(os)
334 def architecture = 'x64'
335 def configuration = 'Release'
336 def runType = isPR ? 'private' : 'rolling'
337 def benchViewName = isPR ? 'coreclr private \$BenchviewCommitName' : 'coreclr rolling \$GIT_BRANCH_WITHOUT_ORIGIN \$GIT_COMMIT'
340 shell("bash ./tests/scripts/perf-prep.sh --throughput")
341 shell("./init-tools.sh")
342 shell("./build.sh ${architecture} ${configuration}")
343 shell("GIT_BRANCH_WITHOUT_ORIGIN=\$(echo \$GIT_BRANCH | sed \"s/[^/]*\\/\\(.*\\)/\\1 /\")\n" +
344 "python3.5 \"\${WORKSPACE}/tests/scripts/Microsoft.BenchView.JSONFormat/tools/submission-metadata.py\" --name \" ${benchViewName} \" --user \"dotnet-bot@microsoft.com\"\n" +
345 "python3.5 \"\${WORKSPACE}/tests/scripts/Microsoft.BenchView.JSONFormat/tools/build.py\" git --branch \$GIT_BRANCH_WITHOUT_ORIGIN --type ${runType}")
346 shell("""sudo -E python3.5 ./tests/scripts/run-throughput-perf.py \\
347 -arch \"${architecture}\" \\
349 -configuration \"${configuration}\" \\
350 -clr_root \"\${WORKSPACE}\" \\
351 -assembly_root \"\${WORKSPACE}/_/fx/bin/runtime/netcoreapp-${osGroup}-${configuration}-${architecture}\" \\
352 -run_type \"${runType}\" \\
353 -benchview_path \"\${WORKSPACE}/tests/scripts/Microsoft.BenchView.JSONFormat/tools\"""")
357 // Save machinedata.json to /artifact/bin/ Jenkins dir
358 def archiveSettings = new ArchivalSettings()
359 archiveSettings.addFiles('throughput-*.csv')
360 archiveSettings.addFiles('machinedata.json')
361 Utilities.addArchival(newJob, archiveSettings)
363 Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
365 // For perf, we need to keep the run results longer
367 // Enable the log rotator
369 artifactDaysToKeep(7)
371 artifactNumToKeep(25)
376 TriggerBuilder builder = TriggerBuilder.triggerOnPullRequest()
377 builder.setGithubContext("${os} Throughput Perf Tests")
378 builder.triggerOnlyOnComment()
379 builder.setCustomTriggerPhrase("(?i).*test\\W+${os}\\W+throughput.*")
380 builder.triggerForBranch(branch)
381 builder.emitTrigger(newJob)
384 // Set a push trigger
385 TriggerBuilder builder = TriggerBuilder.triggerOnCommit()
386 builder.emitTrigger(newJob)