Skip to content

Commit 96c2eb6

Browse files
erock2112Skia Commit-Bot
authored and
Skia Commit-Bot
committed
[recipes] Move nanobench flags logic into gen_tasks_logic/nanobench_flags.go
Change-Id: Ie00a12db04350ab0f8c754b3674eaa5a0a556b63 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/274596 Commit-Queue: Eric Boren <[email protected]> Reviewed-by: Ben Wagner aka dogben <[email protected]>
1 parent 0c2f61e commit 96c2eb6

File tree

3 files changed

+307
-319
lines changed

3 files changed

+307
-319
lines changed

infra/bots/gen_tasks_logic/gen_tasks_logic.go

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@ package gen_tasks_logic
99
*/
1010

1111
import (
12-
"bytes"
1312
"encoding/json"
1413
"fmt"
1514
"io/ioutil"
1615
"os"
17-
"os/exec"
1816
"path"
1917
"path/filepath"
2018
"regexp"
@@ -1527,32 +1525,9 @@ func (b *builder) perf(name string, parts map[string]string, compileTaskName str
15271525
extraProps[k] = v
15281526
}
15291527
if recipe == "perf" {
1530-
nanoFlagsScript := filepath.Join(CheckoutRoot(), "infra", "bots", "recipe_modules", "vars", "resources", "nanobench_flags.py")
1531-
args := []string{
1532-
nanoFlagsScript,
1533-
"--bot", name,
1534-
"--parts", marshalJson(parts),
1535-
"--revision", specs.PLACEHOLDER_REVISION,
1536-
"--issue", specs.PLACEHOLDER_ISSUE,
1537-
"--patchset", specs.PLACEHOLDER_PATCHSET,
1538-
"--patch_storage", specs.PLACEHOLDER_PATCH_STORAGE,
1539-
}
1540-
if doUpload {
1541-
args = append(args, "--do_upload")
1542-
}
1543-
out, err := exec.Command("python", args...).CombinedOutput()
1544-
if err != nil {
1545-
glog.Fatal(err)
1546-
}
1547-
var res struct {
1548-
NanoFlags []string `json:"nanobench_flags"`
1549-
NanoProps map[string]string `json:"nanobench_properties"`
1550-
}
1551-
if err := json.NewDecoder(bytes.NewBuffer(out)).Decode(&res); err != nil {
1552-
glog.Fatal(err)
1553-
}
1554-
extraProps["nanobench_flags"] = marshalJson(res.NanoFlags)
1555-
extraProps["nanobench_properties"] = marshalJson(res.NanoProps)
1528+
flags, props := nanobenchFlags(name, parts, doUpload)
1529+
extraProps["nanobench_flags"] = marshalJson(flags)
1530+
extraProps["nanobench_properties"] = marshalJson(props)
15561531
}
15571532
task := b.kitchenTask(name, recipe, isolate, "", b.swarmDimensions(parts), extraProps, OUTPUT_PERF)
15581533
task.CipdPackages = append(task.CipdPackages, pkgs...)
Lines changed: 304 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,304 @@
1+
// Copyright 2020 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
package gen_tasks_logic
5+
6+
import (
7+
"fmt"
8+
"sort"
9+
"strings"
10+
11+
"go.skia.org/infra/task_scheduler/go/specs"
12+
)
13+
14+
// nanobenchFlags generates flags to Nanobench based on the given task properties.
15+
func nanobenchFlags(bot string, parts map[string]string, doUpload bool) ([]string, map[string]string) {
16+
has := func(keyword string) bool {
17+
return strings.Contains(bot, keyword)
18+
}
19+
20+
// TODO(borenet): This duplicates code in recipes_modules/vars/api.py and will
21+
// be removed soon.
22+
isLinux := has("Ubuntu") || has("Debian") || has("Housekeeper")
23+
24+
args := []string{
25+
"nanobench",
26+
"--pre_log",
27+
}
28+
29+
if has("GPU") {
30+
args = append(args, "--images")
31+
args = append(args, "--gpuStatsDump", "true")
32+
}
33+
34+
args = append(args, "--scales", "1.0", "1.1")
35+
36+
if has("iOS") {
37+
args = append(args, "--skps", "ignore_skps")
38+
}
39+
40+
configs := []string{}
41+
if parts["cpu_or_gpu"] == "CPU" {
42+
args = append(args, "--nogpu")
43+
configs = append(configs, "8888", "nonrendering")
44+
45+
if has("BonusConfigs") {
46+
configs = []string{
47+
"f16",
48+
"srgb",
49+
"esrgb",
50+
"narrow",
51+
"enarrow",
52+
}
53+
}
54+
55+
if has("Nexus7") {
56+
args = append(args, "--purgeBetweenBenches") // Debugging skia:8929
57+
}
58+
59+
} else if parts["cpu_or_gpu"] == "GPU" {
60+
args = append(args, "--nocpu")
61+
62+
glPrefix := "gl"
63+
sampleCount := 8
64+
if has("Android") || has("iOS") {
65+
sampleCount = 4
66+
// The NVIDIA_Shield has a regular OpenGL implementation. We bench that
67+
// instead of ES.
68+
if !has("NVIDIA_Shield") {
69+
glPrefix = "gles"
70+
}
71+
// iOS crashes with MSAA (skia:6399)
72+
// Nexus7 (Tegra3) does not support MSAA.
73+
// MSAA is disabled on Pixel3a (https://b.corp.google.com/issues/143074513).
74+
if has("iOS") || has("Nexus7") || has("Pixel3a") {
75+
sampleCount = 0
76+
}
77+
} else if has("Intel") {
78+
// MSAA doesn't work well on Intel GPUs chromium:527565, chromium:983926
79+
sampleCount = 0
80+
} else if has("ChromeOS") {
81+
glPrefix = "gles"
82+
}
83+
84+
configs = append(configs, glPrefix, glPrefix+"srgb")
85+
if sampleCount > 0 {
86+
configs = append(configs, fmt.Sprintf("%smsaa%d", glPrefix, sampleCount))
87+
}
88+
89+
// We want to test both the OpenGL config and the GLES config on Linux Intel:
90+
// GL is used by Chrome, GLES is used by ChromeOS.
91+
if has("Intel") && isLinux {
92+
configs = append(configs, "gles", "glessrgb")
93+
}
94+
95+
if has("CommandBuffer") {
96+
configs = []string{"commandbuffer"}
97+
}
98+
99+
if has("Vulkan") {
100+
configs = []string{"vk"}
101+
if has("Android") {
102+
// skbug.com/9274
103+
if !has("Pixel2XL") {
104+
configs = append(configs, "vkmsaa4")
105+
}
106+
} else {
107+
// MSAA doesn't work well on Intel GPUs chromium:527565, chromium:983926, skia:9023
108+
if !has("Intel") {
109+
configs = append(configs, "vkmsaa8")
110+
}
111+
}
112+
}
113+
if has("Metal") {
114+
configs = []string{"mtl"}
115+
if has("iOS") {
116+
configs = append(configs, "mtlmsaa4")
117+
} else {
118+
configs = append(configs, "mtlmsaa8")
119+
}
120+
}
121+
122+
if has("ANGLE") {
123+
// Test only ANGLE configs.
124+
configs = []string{"angle_d3d11_es2"}
125+
if sampleCount > 0 {
126+
configs = append(configs, fmt.Sprintf("angle_d3d11_es2_msaa%d", sampleCount))
127+
}
128+
if has("QuadroP400") {
129+
// See skia:7823 and chromium:693090.
130+
configs = append(configs, "angle_gl_es2")
131+
if sampleCount > 0 {
132+
configs = append(configs, fmt.Sprintf("angle_gl_es2_msaa%d", sampleCount))
133+
}
134+
}
135+
}
136+
if has("ChromeOS") {
137+
// Just run GLES for now - maybe add gles_msaa4 in the future
138+
configs = []string{"gles"}
139+
}
140+
}
141+
142+
args = append(args, "--config")
143+
args = append(args, configs...)
144+
145+
// By default, we test with GPU threading enabled, unless specifically
146+
// disabled.
147+
if has("NoGPUThreads") {
148+
args = append(args, "--gpuThreads", "0")
149+
}
150+
151+
if has("Debug") || has("ASAN") || has("Valgrind") {
152+
args = append(args, "--loops", "1")
153+
args = append(args, "--samples", "1")
154+
// Ensure that the bot framework does not think we have timed out.
155+
args = append(args, "--keepAlive", "true")
156+
}
157+
158+
// skia:9036
159+
if has("NVIDIA_Shield") {
160+
args = append(args, "--dontReduceOpsTaskSplitting")
161+
}
162+
163+
// Some people don't like verbose output.
164+
verbose := false
165+
166+
match := []string{}
167+
if has("Android") {
168+
// Segfaults when run as GPU bench. Very large texture?
169+
match = append(match, "~blurroundrect")
170+
match = append(match, "~patch_grid") // skia:2847
171+
match = append(match, "~desk_carsvg")
172+
}
173+
if has("Nexus5") {
174+
match = append(match, "~keymobi_shop_mobileweb_ebay_com.skp") // skia:5178
175+
}
176+
if has("iOS") {
177+
match = append(match, "~blurroundrect")
178+
match = append(match, "~patch_grid") // skia:2847
179+
match = append(match, "~desk_carsvg")
180+
match = append(match, "~keymobi")
181+
match = append(match, "~path_hairline")
182+
match = append(match, "~GLInstancedArraysBench") // skia:4714
183+
}
184+
if has("iOS") && has("Metal") {
185+
// skia:9799
186+
match = append(match, "~compositing_images_tile_size")
187+
}
188+
if has("Intel") && isLinux && !has("Vulkan") {
189+
// TODO(dogben): Track down what's causing bots to die.
190+
verbose = true
191+
}
192+
if has("IntelHD405") && isLinux && has("Vulkan") {
193+
// skia:7322
194+
match = append(match, "~desk_carsvg.skp_1")
195+
match = append(match, "~desk_googlehome.skp")
196+
match = append(match, "~desk_tiger8svg.skp_1")
197+
match = append(match, "~desk_wowwiki.skp")
198+
match = append(match, "~desk_ynevsvg.skp_1.1")
199+
match = append(match, "~desk_nostroke_tiger8svg.skp")
200+
match = append(match, "~keymobi_booking_com.skp_1")
201+
match = append(match, "~keymobi_booking_com.skp_1_mpd")
202+
match = append(match, "~keymobi_cnn_article.skp_1")
203+
match = append(match, "~keymobi_cnn_article.skp_1_mpd")
204+
match = append(match, "~keymobi_forecast_io.skp_1")
205+
match = append(match, "~keymobi_forecast_io.skp_1_mpd")
206+
match = append(match, "~keymobi_sfgate.skp_1")
207+
match = append(match, "~keymobi_techcrunch_com.skp_1.1")
208+
match = append(match, "~keymobi_techcrunch.skp_1.1")
209+
match = append(match, "~keymobi_techcrunch.skp_1.1_mpd")
210+
match = append(match, "~svgparse_Seal_of_California.svg_1.1")
211+
match = append(match, "~svgparse_NewYork-StateSeal.svg_1.1")
212+
match = append(match, "~svgparse_Vermont_state_seal.svg_1")
213+
match = append(match, "~tabl_gamedeksiam.skp_1.1")
214+
match = append(match, "~tabl_pravda.skp_1")
215+
match = append(match, "~top25desk_ebay_com.skp_1.1")
216+
match = append(match, "~top25desk_ebay.skp_1.1")
217+
match = append(match, "~top25desk_ebay.skp_1.1_mpd")
218+
}
219+
if has("Vulkan") && has("GTX660") {
220+
// skia:8523 skia:9271
221+
match = append(match, "~compositing_images")
222+
}
223+
if has("MacBook10.1") && has("CommandBuffer") {
224+
match = append(match, "~^desk_micrographygirlsvg.skp_1.1$")
225+
}
226+
if has("ASAN") && has("CPU") {
227+
// floor2int_undef benches undefined behavior, so ASAN correctly complains.
228+
match = append(match, "~^floor2int_undef$")
229+
}
230+
if has("AcerChromebook13_CB5_311-GPU-TegraK1") {
231+
// skia:7551
232+
match = append(match, "~^shapes_rrect_inner_rrect_50_500x500$")
233+
}
234+
if has("Perf-Android-Clang-Pixel3a-GPU-Adreno615-arm64-Release-All-Android") {
235+
// skia:9413
236+
match = append(match, "~^path_text$")
237+
match = append(match, "~^path_text_clipped_uncached$")
238+
}
239+
if has("Perf-Android-Clang-Pixel3-GPU-Adreno630-arm64-Release-All-Android_Vulkan") {
240+
// skia:9972
241+
match = append(match, "~^path_text_clipped_uncached$")
242+
}
243+
244+
// We do not need or want to benchmark the decodes of incomplete images.
245+
// In fact, in nanobench we assert that the full image decode succeeds.
246+
match = append(match, "~inc0.gif")
247+
match = append(match, "~inc1.gif")
248+
match = append(match, "~incInterlaced.gif")
249+
match = append(match, "~inc0.jpg")
250+
match = append(match, "~incGray.jpg")
251+
match = append(match, "~inc0.wbmp")
252+
match = append(match, "~inc1.wbmp")
253+
match = append(match, "~inc0.webp")
254+
match = append(match, "~inc1.webp")
255+
match = append(match, "~inc0.ico")
256+
match = append(match, "~inc1.ico")
257+
match = append(match, "~inc0.png")
258+
match = append(match, "~inc1.png")
259+
match = append(match, "~inc2.png")
260+
match = append(match, "~inc12.png")
261+
match = append(match, "~inc13.png")
262+
match = append(match, "~inc14.png")
263+
match = append(match, "~inc0.webp")
264+
match = append(match, "~inc1.webp")
265+
266+
if len(match) > 0 {
267+
args = append(args, "--match")
268+
args = append(args, match...)
269+
}
270+
271+
if verbose {
272+
args = append(args, "--verbose")
273+
}
274+
275+
props := map[string]string{
276+
"gitHash": specs.PLACEHOLDER_REVISION,
277+
"issue": specs.PLACEHOLDER_ISSUE,
278+
"patchset": specs.PLACEHOLDER_PATCHSET,
279+
"patch_storage": specs.PLACEHOLDER_PATCH_STORAGE,
280+
"swarming_bot_id": "${SWARMING_BOT_ID}",
281+
"swarming_task_id": "${SWARMING_TASK_ID}",
282+
}
283+
284+
if doUpload {
285+
keysBlacklist := map[string]bool{
286+
"configuration": true,
287+
"role": true,
288+
"test_filter": true,
289+
}
290+
keys := make([]string, 0, len(parts))
291+
for k := range parts {
292+
keys = append(keys, k)
293+
}
294+
sort.Strings(keys)
295+
args = append(args, "--key")
296+
for _, k := range keys {
297+
if !keysBlacklist[k] {
298+
args = append(args, k, parts[k])
299+
}
300+
}
301+
}
302+
303+
return args, props
304+
}

0 commit comments

Comments
 (0)