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', 'x86jit32'].each { arch ->
31 def architecture = arch
34 if (arch == 'x86jit32')
37 testEnv = '-testEnv %WORKSPACE%\\tests\\x86\\compatjit_x86_testenv.cmd'
39 else if (arch == 'x86')
41 testEnv = '-testEnv %WORKSPACE%\\tests\\x86\\ryujit_x86_testenv.cmd'
44 def newJob = job(Utilities.getFullJobName(project, "perf_perflab_${os}_${arch}", isPR)) {
46 label('windows_clr_perf')
49 string('BV_UPLOAD_SAS_TOKEN', 'CoreCLR Perf BenchView Sas')
57 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')
60 def configuration = 'Release'
61 def runType = isPR ? 'private' : 'rolling'
62 def benchViewName = isPR ? 'coreclr private %BenchviewCommitName%' : 'coreclr rolling %GIT_BRANCH_WITHOUT_ORIGIN% %GIT_COMMIT%'
67 batchFile("if exist \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\" rmdir /s /q \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\"")
68 batchFile("C:\\Tools\\nuget.exe install Microsoft.BenchView.JSONFormat -Source http://benchviewtestfeed.azurewebsites.net/nuget -OutputDirectory \"%WORKSPACE%\" -Prerelease -ExcludeVersion")
69 //Do this here to remove the origin but at the front of the branch name as this is a problem for BenchView
70 //we have to do it all as one statement because cmd is called each time and we lose the set environment variable
71 batchFile("if [%GIT_BRANCH:~0,7%] == [origin/] (set GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH:origin/=%) else (set GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH%)\n" +
72 "py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\submission-metadata.py\" --name \"${benchViewName}\" --user \"dotnet-bot@microsoft.com\"\n" +
73 "py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\build.py\" git --branch %GIT_BRANCH_WITHOUT_ORIGIN% --type ${runType}")
74 batchFile("py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\machinedata.py\"")
75 batchFile("set __TestIntermediateDir=int&&build.cmd ${configuration} ${architecture}")
76 batchFile("tests\\runtest.cmd ${configuration} ${architecture} GenerateLayoutOnly")
78 if (arch == 'x86jit32')
80 // Download package and copy compatjit into Core_Root
81 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" +
82 "xcopy \"%WORKSPACE%\\runtime.win7-x86.Microsoft.NETCore.Jit\\runtimes\\win7-x86\\native\\compatjit.dll\" \"%WORKSPACE%\\bin\\tests\\${os}.${architecture}.${configuration}\\Tests\\Core_Root\" /Y")
85 batchFile("tests\\scripts\\run-xunit-perf.cmd -arch ${arch} -configuration ${configuration} ${testEnv} -testBinLoc bin\\tests\\${os}.${architecture}.${configuration}\\performance\\perflab\\Perflab -library -uploadToBenchview \"%WORKSPACE%\\Microsoft.Benchview.JSONFormat\\tools\" -runtype ${runType}")
86 batchFile("tests\\scripts\\run-xunit-perf.cmd -arch ${arch} -configuration ${configuration} ${testEnv} -testBinLoc bin\\tests\\${os}.${architecture}.${configuration}\\Jit\\Performance\\CodeQuality -uploadToBenchview \"%WORKSPACE%\\Microsoft.Benchview.JSONFormat\\tools\" -runtype ${runType}")
90 // Save machinedata.json to /artifact/bin/ Jenkins dir
91 def archiveSettings = new ArchivalSettings()
92 archiveSettings.addFiles('perf-*.xml')
93 archiveSettings.addFiles('perf-*.etl')
94 Utilities.addArchival(newJob, archiveSettings)
96 Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
99 TriggerBuilder builder = TriggerBuilder.triggerOnPullRequest()
100 builder.setGithubContext("${os} ${arch} CoreCLR Perf Tests")
101 builder.triggerOnlyOnComment()
102 builder.setCustomTriggerPhrase("(?i).*test\\W+${os}\\W+${arch}\\W+perf.*")
103 builder.triggerForBranch(branch)
104 builder.emitTrigger(newJob)
107 // Set a push trigger
108 TriggerBuilder builder = TriggerBuilder.triggerOnCommit()
109 builder.emitTrigger(newJob)
115 // Setup throughput perflab tests runs
116 [true, false].each { isPR ->
117 ['Windows_NT'].each { os ->
118 ['x64', 'x86', 'x86jit32'].each { arch ->
119 def architecture = arch
121 if (arch == 'x86jit32')
126 def newJob = job(Utilities.getFullJobName(project, "perf_throughput_perflab_${os}_${arch}", isPR)) {
128 label('windows_clr_perf')
131 string('BV_UPLOAD_SAS_TOKEN', 'CoreCLR Perf BenchView Sas')
139 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')
142 def configuration = 'Release'
143 def runType = isPR ? 'private' : 'rolling'
144 def benchViewName = isPR ? 'coreclr-throughput private %BenchviewCommitName%' : 'coreclr-throughput rolling %GIT_BRANCH_WITHOUT_ORIGIN% %GIT_COMMIT%'
149 batchFile("if exist \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\" rmdir /s /q \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\"")
150 batchFile("if exist \"%WORKSPACE%\\Microsoft.BenchView.ThroughputBenchmarks.${architecture}.${os}\" rmdir /s /q \"%WORKSPACE%\\Microsoft.BenchView.ThroughputBenchmarks.${architecture}.${os}\"")
151 batchFile("C:\\Tools\\nuget.exe install Microsoft.BenchView.JSONFormat -Source http://benchviewtestfeed.azurewebsites.net/nuget -OutputDirectory \"%WORKSPACE%\" -Prerelease -ExcludeVersion")
152 batchFile("C:\\Tools\\nuget.exe install Microsoft.BenchView.ThroughputBenchmarks.${architecture}.${os} -Source https://dotnet.myget.org/F/dotnet-core -OutputDirectory \"%WORKSPACE%\" -Prerelease -ExcludeVersion")
153 //Do this here to remove the origin but at the front of the branch name as this is a problem for BenchView
154 //we have to do it all as one statement because cmd is called each time and we lose the set environment variable
155 batchFile("if [%GIT_BRANCH:~0,7%] == [origin/] (set GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH:origin/=%) else (set GIT_BRANCH_WITHOUT_ORIGIN=%GIT_BRANCH%)\n" +
156 "py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\submission-metadata.py\" --name \"${benchViewName}\" --user \"dotnet-bot@microsoft.com\"\n" +
157 "py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\build.py\" git --branch %GIT_BRANCH_WITHOUT_ORIGIN% --type ${runType}")
158 batchFile("py \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\\tools\\machinedata.py\"")
159 batchFile("set __TestIntermediateDir=int&&build.cmd ${configuration} ${architecture} skiptests")
160 batchFile("tests\\runtest.cmd ${configuration} ${architecture} GenerateLayoutOnly")
161 if (arch == 'x86jit32')
163 // Download package and copy compatjit into Core_Root
164 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" +
165 "xcopy \"%WORKSPACE%\\runtime.win7-x86.Microsoft.NETCore.Jit\\runtimes\\win7-x86\\native\\compatjit.dll\" \"%WORKSPACE%\\bin\\tests\\${os}.${architecture}.${configuration}\\Tests\\Core_Root\" /Y")
167 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}")
171 // Save machinedata.json to /artifact/bin/ Jenkins dir
172 def archiveSettings = new ArchivalSettings()
173 archiveSettings.addFiles('throughput-*.csv')
174 Utilities.addArchival(newJob, archiveSettings)
176 Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
179 TriggerBuilder builder = TriggerBuilder.triggerOnPullRequest()
180 builder.setGithubContext("${os} ${arch} CoreCLR Throughput Perf Tests")
181 builder.triggerOnlyOnComment()
182 builder.setCustomTriggerPhrase("(?i).*test\\W+${os}\\W+${arch}\\W+throughput.*")
183 builder.triggerForBranch(branch)
184 builder.emitTrigger(newJob)
187 // Set a push trigger
188 TriggerBuilder builder = TriggerBuilder.triggerOnCommit()
189 builder.emitTrigger(newJob)
195 // Create the Linux/OSX/CentOS coreclr test leg for debug and release and each scenario
196 [true, false].each { isPR ->
197 ['Ubuntu14.04'].each { os ->
198 def newJob = job(Utilities.getFullJobName(project, "perf_${os}", isPR)) {
200 label('linux_clr_perf')
203 string('BV_UPLOAD_SAS_TOKEN', 'CoreCLR Perf BenchView Sas')
211 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')
214 def osGroup = getOSGroup(os)
215 def architecture = 'x64'
216 def configuration = 'Release'
217 def runType = isPR ? 'private' : 'rolling'
218 def benchViewName = isPR ? 'coreclr private \$BenchviewCommitName' : 'coreclr rolling \$GIT_BRANCH_WITHOUT_ORIGIN \$GIT_COMMIT'
221 shell("bash ./tests/scripts/perf-prep.sh")
222 shell("./init-tools.sh")
223 shell("./build.sh ${architecture} ${configuration}")
224 shell("GIT_BRANCH_WITHOUT_ORIGIN=\$(echo \$GIT_BRANCH | sed \"s/[^/]*\\/\\(.*\\)/\\1 /\")\n" +
225 "python3.5 \"\${WORKSPACE}/tests/scripts/Microsoft.BenchView.JSONFormat/tools/submission-metadata.py\" --name " + "\"" + benchViewName + "\"" + " --user " + "\"dotnet-bot@microsoft.com\"\n" +
226 "python3.5 \"\${WORKSPACE}/tests/scripts/Microsoft.BenchView.JSONFormat/tools/build.py\" git --branch \$GIT_BRANCH_WITHOUT_ORIGIN --type " + runType)
227 shell("""sudo -E bash ./tests/scripts/run-xunit-perf.sh \\
228 --testRootDir=\"\${WORKSPACE}/bin/tests/Windows_NT.${architecture}.${configuration}\" \\
229 --testNativeBinDir=\"\${WORKSPACE}/bin/obj/${osGroup}.${architecture}.${configuration}/tests\" \\
230 --coreClrBinDir=\"\${WORKSPACE}/bin/Product/${osGroup}.${architecture}.${configuration}\" \\
231 --mscorlibDir=\"\${WORKSPACE}/bin/Product/${osGroup}.${architecture}.${configuration}\" \\
232 --coreFxBinDir=\"\${WORKSPACE}/corefx\" \\
233 --runType=\"${runType}\" \\
234 --benchViewOS=\"${os}\" \\
235 --uploadToBenchview""")
239 // Save machinedata.json to /artifact/bin/ Jenkins dir
240 def archiveSettings = new ArchivalSettings()
241 archiveSettings.addFiles('sandbox/perf-*.xml')
242 archiveSettings.addFiles('machinedata.json')
243 Utilities.addArchival(newJob, archiveSettings)
245 Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
247 // For perf, we need to keep the run results longer
249 // Enable the log rotator
251 artifactDaysToKeep(7)
253 artifactNumToKeep(25)
258 TriggerBuilder builder = TriggerBuilder.triggerOnPullRequest()
259 builder.setGithubContext("${os} Perf Tests")
260 builder.triggerOnlyOnComment()
261 builder.setCustomTriggerPhrase("(?i).*test\\W+${os}\\W+perf.*")
262 builder.triggerForBranch(branch)
263 builder.emitTrigger(newJob)
266 // Set a push trigger
267 TriggerBuilder builder = TriggerBuilder.triggerOnCommit()
268 builder.emitTrigger(newJob)