Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(826)

Side by Side Diff: ct/go/worker_scripts/run_chromium_perf/main.go

Issue 1411423003: [CT] Add ability to run unlanded benchmarks on Chromium Perf (Closed) Base URL: https://skia.googlesource.com/buildbot@master
Patch Set: Fix errcheck Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ct/go/poller/main.go ('k') | ct/py/csv_comparer.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // run_chromium_perf is an application that runs the specified benchmark over CT 's 1 // run_chromium_perf is an application that runs the specified benchmark over CT 's
2 // webpage archives. 2 // webpage archives.
3 package main 3 package main
4 4
5 import ( 5 import (
6 "bytes"
6 "encoding/csv" 7 "encoding/csv"
7 "flag" 8 "flag"
8 "fmt" 9 "fmt"
9 "io/ioutil" 10 "io/ioutil"
10 "os" 11 "os"
11 "path/filepath" 12 "path/filepath"
12 "runtime" 13 "runtime"
13 "sync" 14 "sync"
14 "time" 15 "time"
15 16
(...skipping 11 matching lines...) Expand all
27 const ( 28 const (
28 // The number of goroutines that will run in parallel to run benchmarks. 29 // The number of goroutines that will run in parallel to run benchmarks.
29 WORKER_POOL_SIZE = 10 30 WORKER_POOL_SIZE = 10
30 ) 31 )
31 32
32 var ( 33 var (
33 workerNum = flag.Int("worker_num", 1, "The number of thi s CT worker. It will be in the {1..100} range.") 34 workerNum = flag.Int("worker_num", 1, "The number of thi s CT worker. It will be in the {1..100} range.")
34 pagesetType = flag.String("pageset_type", util.PAGESET_TYP E_MOBILE_10k, "The type of pagesets to create from the Alexa CSV list. Eg: 10k, Mobile10k, All.") 35 pagesetType = flag.String("pageset_type", util.PAGESET_TYP E_MOBILE_10k, "The type of pagesets to create from the Alexa CSV list. Eg: 10k, Mobile10k, All.")
35 chromiumBuildNoPatch = flag.String("chromium_build_nopatch", "", "T he chromium build to use for the nopatch run.") 36 chromiumBuildNoPatch = flag.String("chromium_build_nopatch", "", "T he chromium build to use for the nopatch run.")
36 chromiumBuildWithPatch = flag.String("chromium_build_withpatch", "", "The chromium build to use for the withpatch run.") 37 chromiumBuildWithPatch = flag.String("chromium_build_withpatch", "", "The chromium build to use for the withpatch run.")
38 runID = flag.String("run_id", "", "The unique run id (typically requester + timestamp).")
37 runIDNoPatch = flag.String("run_id_nopatch", "", "The uniqu e run id (typically requester + timestamp) for the nopatch run.") 39 runIDNoPatch = flag.String("run_id_nopatch", "", "The uniqu e run id (typically requester + timestamp) for the nopatch run.")
38 runIDWithPatch = flag.String("run_id_withpatch", "", "The uni que run id (typically requester + timestamp) for the withpatch run.") 40 runIDWithPatch = flag.String("run_id_withpatch", "", "The uni que run id (typically requester + timestamp) for the withpatch run.")
39 benchmarkName = flag.String("benchmark_name", "", "The telem etry benchmark to run on this worker.") 41 benchmarkName = flag.String("benchmark_name", "", "The telem etry benchmark to run on this worker.")
40 benchmarkExtraArgs = flag.String("benchmark_extra_args", "", "The extra arguments that are passed to the specified benchmark.") 42 benchmarkExtraArgs = flag.String("benchmark_extra_args", "", "The extra arguments that are passed to the specified benchmark.")
41 browserExtraArgsNoPatch = flag.String("browser_extra_args_nopatch", "" , "The extra arguments that are passed to the browser while running the benchmar k during the nopatch run.") 43 browserExtraArgsNoPatch = flag.String("browser_extra_args_nopatch", "" , "The extra arguments that are passed to the browser while running the benchmar k during the nopatch run.")
42 browserExtraArgsWithPatch = flag.String("browser_extra_args_withpatch", "", "The extra arguments that are passed to the browser while running the benchm ark during the withpatch run.") 44 browserExtraArgsWithPatch = flag.String("browser_extra_args_withpatch", "", "The extra arguments that are passed to the browser while running the benchm ark during the withpatch run.")
43 repeatBenchmark = flag.Int("repeat_benchmark", 3, "The number of times the benchmark should be repeated. For skpicture_printer benchmark this value is always 1.") 45 repeatBenchmark = flag.Int("repeat_benchmark", 3, "The number of times the benchmark should be repeated. For skpicture_printer benchmark this value is always 1.")
44 runInParallel = flag.Bool("run_in_parallel", false, "Run the benchmark by bringing up multiple chrome instances in parallel.") 46 runInParallel = flag.Bool("run_in_parallel", false, "Run the benchmark by bringing up multiple chrome instances in parallel.")
45 targetPlatform = flag.String("target_platform", util.PLATFORM _ANDROID, "The platform the benchmark will run on (Android / Linux).") 47 targetPlatform = flag.String("target_platform", util.PLATFORM _ANDROID, "The platform the benchmark will run on (Android / Linux).")
46 chromeCleanerTimer = flag.Duration("cleaner_timer", 15*time.Minut e, "How often all chrome processes will be killed on this slave.") 48 chromeCleanerTimer = flag.Duration("cleaner_timer", 15*time.Minut e, "How often all chrome processes will be killed on this slave.")
(...skipping 10 matching lines...) Expand all
57 59
58 // Validate required arguments. 60 // Validate required arguments.
59 if *chromiumBuildNoPatch == "" { 61 if *chromiumBuildNoPatch == "" {
60 glog.Error("Must specify --chromium_build_nopatch") 62 glog.Error("Must specify --chromium_build_nopatch")
61 return 63 return
62 } 64 }
63 if *chromiumBuildWithPatch == "" { 65 if *chromiumBuildWithPatch == "" {
64 glog.Error("Must specify --chromium_build_withpatch") 66 glog.Error("Must specify --chromium_build_withpatch")
65 return 67 return
66 } 68 }
69 if *runID == "" {
70 glog.Error("Must specify --run_id")
71 return
72 }
67 if *runIDNoPatch == "" { 73 if *runIDNoPatch == "" {
68 glog.Error("Must specify --run_id_nopatch") 74 glog.Error("Must specify --run_id_nopatch")
69 return 75 return
70 } 76 }
71 if *runIDWithPatch == "" { 77 if *runIDWithPatch == "" {
72 glog.Error("Must specify --run_id_withpatch") 78 glog.Error("Must specify --run_id_withpatch")
73 return 79 return
74 } 80 }
75 if *benchmarkName == "" { 81 if *benchmarkName == "" {
76 glog.Error("Must specify --benchmark_name") 82 glog.Error("Must specify --benchmark_name")
(...skipping 29 matching lines...) Expand all
106 util.ADB_ROOT_TIMEOUT, nil, nil)) 112 util.ADB_ROOT_TIMEOUT, nil, nil))
107 } 113 }
108 114
109 // Instantiate GsUtil object. 115 // Instantiate GsUtil object.
110 gs, err := util.NewGsUtil(nil) 116 gs, err := util.NewGsUtil(nil)
111 if err != nil { 117 if err != nil {
112 glog.Error(err) 118 glog.Error(err)
113 return 119 return
114 } 120 }
115 121
122 // Download the benchmark patch for this run from Google storage.
123 benchmarkPatchName := *runID + ".benchmark.patch"
124 benchmarkPatchLocalPath := filepath.Join(os.TempDir(), benchmarkPatchNam e)
125 remoteDir := filepath.Join(util.ChromiumPerfRunsDir, *runID)
126 benchmarkPatchRemotePath := filepath.Join(remoteDir, benchmarkPatchName)
127 respBody, err := gs.GetRemoteFileContents(benchmarkPatchRemotePath)
128 if err != nil {
129 glog.Errorf("Could not fetch %s: %s", benchmarkPatchRemotePath, err)
130 return
131 }
132 defer skutil.Close(respBody)
133 buf := new(bytes.Buffer)
134 if _, err := buf.ReadFrom(respBody); err != nil {
135 glog.Errorf("Could not read from %s: %s", benchmarkPatchRemotePa th, err)
136 return
137 }
138 if err := ioutil.WriteFile(benchmarkPatchLocalPath, buf.Bytes(), 0666); err != nil {
139 glog.Errorf("Unable to create file %s: %s", benchmarkPatchLocalP ath, err)
140 return
141 }
142 defer skutil.Remove(benchmarkPatchLocalPath)
143 // Apply benchmark patch to the local chromium checkout.
144 if buf.Len() > 10 {
145 if err := util.ApplyPatch(benchmarkPatchLocalPath, util.Chromium SrcDir); err != nil {
146 glog.Errorf("Could not apply Telemetry's patch in %s: %s ", util.ChromiumSrcDir, err)
147 return
148 }
149 }
150
116 // Download the specified chromium builds. 151 // Download the specified chromium builds.
117 for _, chromiumBuild := range []string{*chromiumBuildNoPatch, *chromiumB uildWithPatch} { 152 for _, chromiumBuild := range []string{*chromiumBuildNoPatch, *chromiumB uildWithPatch} {
118 if err := gs.DownloadChromiumBuild(chromiumBuild); err != nil { 153 if err := gs.DownloadChromiumBuild(chromiumBuild); err != nil {
119 glog.Error(err) 154 glog.Error(err)
120 return 155 return
121 } 156 }
122 //Delete the chromium build to save space when we are done. 157 //Delete the chromium build to save space when we are done.
123 defer skutil.RemoveAll(filepath.Join(util.ChromiumBuildsDir, chr omiumBuild)) 158 defer skutil.RemoveAll(filepath.Join(util.ChromiumBuildsDir, chr omiumBuild))
124 } 159 }
125 160
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 281
247 // Read the pageset. 282 // Read the pageset.
248 pagesetName := strings.TrimSuffix(pagesetBaseName, filepath.Ext(pagesetB aseName)) 283 pagesetName := strings.TrimSuffix(pagesetBaseName, filepath.Ext(pagesetB aseName))
249 pagesetPath := filepath.Join(pathToPagesets, fileInfoName) 284 pagesetPath := filepath.Join(pathToPagesets, fileInfoName)
250 decodedPageset, err := util.ReadPageset(pagesetPath) 285 decodedPageset, err := util.ReadPageset(pagesetPath)
251 if err != nil { 286 if err != nil {
252 return fmt.Errorf("Could not read %s: %s", pagesetPath, err) 287 return fmt.Errorf("Could not read %s: %s", pagesetPath, err)
253 } 288 }
254 289
255 glog.Infof("===== Processing %s for %s =====", pagesetPath, runID) 290 glog.Infof("===== Processing %s for %s =====", pagesetPath, runID)
291 pagesetName, present := util.BenchmarksToPagesetName[*benchmarkName]
292 if !present {
293 // If it is custom benchmark use the entered benchmark name.
294 pagesetName = *benchmarkName
295 }
256 args := []string{ 296 args := []string{
257 filepath.Join(util.TelemetryBinariesDir, util.BINARY_RUN_BENCHMA RK), 297 filepath.Join(util.TelemetryBinariesDir, util.BINARY_RUN_BENCHMA RK),
258 » » util.BenchmarksToPagesetName[*benchmarkName], 298 » » pagesetName,
259 "--also-run-disabled-tests", 299 "--also-run-disabled-tests",
260 "--user-agent=" + decodedPageset.UserAgent, 300 "--user-agent=" + decodedPageset.UserAgent,
261 "--urls-list=" + decodedPageset.UrlsList, 301 "--urls-list=" + decodedPageset.UrlsList,
262 "--archive-data-file=" + decodedPageset.ArchiveDataFile, 302 "--archive-data-file=" + decodedPageset.ArchiveDataFile,
263 } 303 }
264 304
265 // Need to capture output for all benchmarks. 305 // Need to capture output for all benchmarks.
266 outputDirArgValue := filepath.Join(localOutputDir, pagesetName) 306 outputDirArgValue := filepath.Join(localOutputDir, pagesetName)
267 args = append(args, "--output-dir="+outputDirArgValue) 307 args = append(args, "--output-dir="+outputDirArgValue)
268 // Figure out which browser should be used. 308 // Figure out which browser should be used.
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 return fmt.Errorf("Could not write to %s: %s", csvPath, err) 425 return fmt.Errorf("Could not write to %s: %s", csvPath, err)
386 } 426 }
387 // Write all values. 427 // Write all values.
388 for _, row := range values { 428 for _, row := range values {
389 if err := writer.Write(row); err != nil { 429 if err := writer.Write(row); err != nil {
390 return fmt.Errorf("Could not write to %s: %s", csvPath, err) 430 return fmt.Errorf("Could not write to %s: %s", csvPath, err)
391 } 431 }
392 } 432 }
393 return nil 433 return nil
394 } 434 }
OLDNEW
« no previous file with comments | « ct/go/poller/main.go ('k') | ct/py/csv_comparer.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698