• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4package gen_tasks_logic
5
6import (
7	"fmt"
8	"sort"
9
10	"go.skia.org/infra/task_scheduler/go/specs"
11)
12
13// nanobenchFlags generates flags to Nanobench based on the given task properties.
14func (b *taskBuilder) nanobenchFlags(doUpload bool) {
15	args := []string{
16		"nanobench",
17		"--pre_log",
18	}
19
20	if b.gpu() {
21		args = append(args, "--gpuStatsDump", "true")
22	}
23
24	args = append(args, "--scales", "1.0", "1.1")
25
26	configs := []string{}
27	if b.cpu() {
28		args = append(args, "--nogpu")
29		configs = append(configs, "8888", "nonrendering")
30
31		if b.extraConfig("BonusConfigs") {
32			configs = []string{
33				"f16",
34				"srgb-rgba",
35				"srgb-f16",
36				"narrow-rgba",
37				"narrow-f16",
38			}
39		}
40
41		if b.model("Nexus7") {
42			args = append(args, "--purgeBetweenBenches") // Debugging skia:8929
43		}
44
45	} else if b.gpu() {
46		args = append(args, "--nocpu")
47
48		glPrefix := "gl"
49		sampleCount := 8
50		if b.matchOs("Android") || b.os("iOS") {
51			sampleCount = 4
52			// The NVIDIA_Shield has a regular OpenGL implementation. We bench that
53			// instead of ES.
54			if !b.model("NVIDIA_Shield") {
55				glPrefix = "gles"
56			}
57			// iOS crashes with MSAA (skia:6399)
58			// Nexus7 (Tegra3) does not support MSAA.
59			// MSAA is disabled on Pixel3a (https://b.corp.google.com/issues/143074513).
60			// MSAA is disabled on Pixel5 (https://skbug.com/11152).
61			if b.os("iOS") || b.model("Nexus7", "Pixel3a", "Pixel5") {
62				sampleCount = 0
63			}
64		} else if b.matchGpu("AppleM1") {
65			sampleCount = 4
66		} else if b.matchGpu("Intel") {
67			// MSAA doesn't work well on Intel GPUs chromium:527565, chromium:983926
68			if b.gpu("IntelIrisXe") && b.matchOs("Win") && b.extraConfig("ANGLE") {
69				// Make an exception for newer GPUs + D3D
70				args = append(args, "--allowMSAAOnNewIntel", "true")
71			} else {
72				sampleCount = 0
73			}
74		} else if b.os("ChromeOS") {
75			glPrefix = "gles"
76		}
77
78		configs = append(configs, glPrefix, "srgb-"+glPrefix)
79
80		if b.os("Ubuntu18") && b.noExtraConfig() {
81			configs = append(configs, glPrefix+"reducedshaders")
82		}
83		// narrow-gl/gles tests the case of color converting *all* content
84		// It hangs on the AndroidOne (Mali400)  skia:10669
85		if !b.gpu("Mali400MP2") {
86			configs = append(configs, "narrow-"+glPrefix)
87		}
88
89		// skia:10644 The fake ES2 config is used to compare highest available ES version to
90		// when we're limited to ES2. We could consider adding a MSAA fake config as well.
91		if b.matchOs("Android") && glPrefix == "gles" {
92			// These only support ES2. No point in running twice.
93			if !b.gpu("Mali400MP2", "Tegra3") {
94				configs = append(configs, "glesfakev2")
95			}
96		}
97
98		if sampleCount > 0 {
99			configs = append(configs, fmt.Sprintf("%smsaa%d", glPrefix, sampleCount))
100			if b.gpu("QuadroP400", "MaliG77", "AppleM1") {
101				configs = append(configs, fmt.Sprintf("%sdmsaa", glPrefix))
102			}
103		}
104
105		// We want to test both the OpenGL config and the GLES config on Linux Intel:
106		// GL is used by Chrome, GLES is used by ChromeOS.
107		if b.matchGpu("Intel") && b.isLinux() {
108			configs = append(configs, "gles", "srgb-gles")
109		}
110
111		if b.extraConfig("Vulkan") {
112			configs = []string{"vk"}
113			if b.matchOs("Android") {
114				// skbug.com/9274
115				if !b.model("Pixel2XL") {
116					configs = append(configs, "vkmsaa4")
117				}
118			} else {
119				// MSAA doesn't work well on Intel GPUs chromium:527565, chromium:983926, skia:9023
120				if !b.matchGpu("Intel") {
121					configs = append(configs, "vkmsaa8")
122				}
123			}
124			if b.gpu("QuadroP400", "MaliG77") {
125				configs = append(configs, "vkdmsaa")
126			}
127		}
128		if b.extraConfig("Metal") && !b.extraConfig("Graphite") {
129			configs = []string{"mtl"}
130			if b.os("iOS") {
131				configs = append(configs, "mtlmsaa4")
132			} else {
133				configs = append(configs, "mtlmsaa8")
134			}
135			if b.model("iPhone11") {
136				configs = append(configs, "mtlreducedshaders")
137			}
138		}
139
140		if b.extraConfig("ANGLE") {
141			// Test only ANGLE configs.
142			configs = []string{"angle_d3d11_es2", "angle_d3d11_es3"}
143			if sampleCount > 0 {
144				configs = append(configs, fmt.Sprintf("angle_d3d11_es2_msaa%d", sampleCount))
145				configs = append(configs, fmt.Sprintf("angle_d3d11_es3_msaa%d", sampleCount))
146			}
147			if b.gpu("QuadroP400") {
148				// See skia:7823 and chromium:693090.
149				configs = append(configs, "angle_gl_es2")
150				configs = append(configs, "angle_gl_es3")
151				if sampleCount > 0 {
152					configs = append(configs, fmt.Sprintf("angle_gl_es2_msaa%d", sampleCount))
153					configs = append(configs, fmt.Sprintf("angle_gl_es3_msaa%d", sampleCount))
154				}
155			}
156		}
157
158		if b.extraConfig("Graphite") {
159			if b.extraConfig("Metal") {
160				configs = []string{"grmtl"}
161			}
162		}
163
164		if b.os("ChromeOS") {
165			// Just run GLES for now - maybe add gles_msaa4 in the future
166			configs = []string{"gles"}
167		}
168		if b.extraConfig("SwiftShader") {
169			configs = []string{"vk", "vkdmsaa"}
170		}
171	}
172
173	args = append(args, "--config")
174	args = append(args, configs...)
175
176	// Use 4 internal msaa samples on mobile and AppleM1, otherwise 8.
177	args = append(args, "--internalSamples")
178	if b.matchOs("Android") || b.os("iOS") || b.matchGpu("AppleM1") {
179		args = append(args, "4")
180	} else {
181		args = append(args, "8")
182	}
183
184	// By default, we test with GPU threading enabled, unless specifically
185	// disabled.
186	if b.extraConfig("NoGPUThreads") {
187		args = append(args, "--gpuThreads", "0")
188	}
189
190	if b.debug() || b.extraConfig("ASAN") || b.extraConfig("Valgrind") {
191		args = append(args, "--loops", "1")
192		args = append(args, "--samples", "1")
193		// Ensure that the bot framework does not think we have timed out.
194		args = append(args, "--keepAlive", "true")
195	}
196
197	// Some people don't like verbose output.
198	verbose := false
199
200	match := []string{}
201	if b.matchOs("Android") {
202		// Segfaults when run as GPU bench. Very large texture?
203		match = append(match, "~blurroundrect")
204		match = append(match, "~patch_grid") // skia:2847
205		match = append(match, "~desk_carsvg")
206	}
207	if b.matchModel("Nexus5") {
208		match = append(match, "~keymobi_shop_mobileweb_ebay_com.skp") // skia:5178
209	}
210	if b.os("iOS") {
211		match = append(match, "~blurroundrect")
212		match = append(match, "~patch_grid") // skia:2847
213		match = append(match, "~desk_carsvg")
214		match = append(match, "~keymobi")
215		match = append(match, "~path_hairline")
216		match = append(match, "~GLInstancedArraysBench") // skia:4714
217	}
218	if b.os("iOS") && b.extraConfig("Metal") && !b.extraConfig("Graphite") {
219		// skia:9799
220		match = append(match, "~compositing_images_tile_size")
221	}
222	if b.matchGpu("Intel") && b.isLinux() && !b.extraConfig("Vulkan") {
223		// TODO(dogben): Track down what's causing bots to die.
224		verbose = true
225	}
226	if b.gpu("IntelHD405") && b.isLinux() && b.extraConfig("Vulkan") {
227		// skia:7322
228		match = append(match, "~desk_carsvg.skp_1")
229		match = append(match, "~desk_googlehome.skp")
230		match = append(match, "~desk_tiger8svg.skp_1")
231		match = append(match, "~desk_wowwiki.skp")
232		match = append(match, "~desk_ynevsvg.skp_1.1")
233		match = append(match, "~desk_nostroke_tiger8svg.skp")
234		match = append(match, "~keymobi_booking_com.skp_1")
235		match = append(match, "~keymobi_cnn_article.skp_1")
236		match = append(match, "~keymobi_forecast_io.skp_1")
237		match = append(match, "~keymobi_sfgate.skp_1")
238		match = append(match, "~keymobi_techcrunch_com.skp_1.1")
239		match = append(match, "~keymobi_techcrunch.skp_1.1")
240		match = append(match, "~svgparse_Seal_of_California.svg_1.1")
241		match = append(match, "~svgparse_NewYork-StateSeal.svg_1.1")
242		match = append(match, "~svgparse_Vermont_state_seal.svg_1")
243		match = append(match, "~tabl_gamedeksiam.skp_1.1")
244		match = append(match, "~tabl_pravda.skp_1")
245		match = append(match, "~top25desk_ebay_com.skp_1.1")
246		match = append(match, "~top25desk_ebay.skp_1.1")
247	}
248	if b.extraConfig("Vulkan") && b.gpu("GTX660") {
249		// skia:8523 skia:9271
250		match = append(match, "~compositing_images")
251	}
252	if b.extraConfig("ASAN") && b.cpu() {
253		// floor2int_undef benches undefined behavior, so ASAN correctly complains.
254		match = append(match, "~^floor2int_undef$")
255	}
256	if b.model("AcerChromebook13_CB5_311") && b.gpu() {
257		// skia:7551
258		match = append(match, "~^shapes_rrect_inner_rrect_50_500x500$")
259	}
260	if b.model("Pixel3a") {
261		// skia:9413
262		match = append(match, "~^path_text$")
263		match = append(match, "~^path_text_clipped_uncached$")
264	}
265	if b.model("Pixel3") && b.extraConfig("Vulkan") {
266		// skia:9972
267		match = append(match, "~^path_text_clipped_uncached$")
268	}
269
270	if b.model("Wembley") {
271		// These tests spin forever on the Wembley.
272		match = append(match, "~^create_backend_texture")
273		match = append(match, "~^draw_coverage")
274		match = append(match, "~^compositing_images")
275	}
276
277	if b.model(DONT_REDUCE_OPS_TASK_SPLITTING_MODELS...) {
278		args = append(args, "--dontReduceOpsTaskSplitting", "true")
279	}
280	if b.model("NUC7i5BNK") {
281		args = append(args, "--gpuResourceCacheLimit", "16777216")
282	}
283
284	if b.extraConfig("DMSAAStats") {
285		// Render tiled, single-frame skps with an extremely tall canvas that hopefully allows for
286		// us to tile most or all of the content.
287		args = append(args,
288			"--sourceType", "skp", "--clip", "0,0,1600,16384", "--GPUbenchTileW", "1600",
289			"--GPUbenchTileH", "512", "--samples", "1", "--loops", "1", "--config", "gldmsaa",
290			"--dmsaaStatsDump")
291		// Don't collect stats on the skps generated from vector content. We want these to actually
292		// trigger dmsaa.
293		match = append(match, "~svg", "~chalkboard", "~motionmark")
294	}
295
296	// We do not need or want to benchmark the decodes of incomplete images.
297	// In fact, in nanobench we assert that the full image decode succeeds.
298	match = append(match, "~inc0.gif")
299	match = append(match, "~inc1.gif")
300	match = append(match, "~incInterlaced.gif")
301	match = append(match, "~inc0.jpg")
302	match = append(match, "~incGray.jpg")
303	match = append(match, "~inc0.wbmp")
304	match = append(match, "~inc1.wbmp")
305	match = append(match, "~inc0.webp")
306	match = append(match, "~inc1.webp")
307	match = append(match, "~inc0.ico")
308	match = append(match, "~inc1.ico")
309	match = append(match, "~inc0.png")
310	match = append(match, "~inc1.png")
311	match = append(match, "~inc2.png")
312	match = append(match, "~inc12.png")
313	match = append(match, "~inc13.png")
314	match = append(match, "~inc14.png")
315	match = append(match, "~inc0.webp")
316	match = append(match, "~inc1.webp")
317
318	if len(match) > 0 {
319		args = append(args, "--match")
320		args = append(args, match...)
321	}
322
323	if verbose {
324		args = append(args, "--verbose")
325	}
326
327	// Add properties indicating which assets the task should use.
328	b.recipeProp("do_upload", fmt.Sprintf("%t", doUpload))
329	if !b.gpu() {
330		b.asset("skimage")
331		b.recipeProp("images", "true")
332	}
333	b.recipeProp("resources", "true")
334	if !b.os("iOS") {
335		b.asset("skp")
336		b.recipeProp("skps", "true")
337	}
338	if !b.extraConfig("Valgrind") {
339		b.asset("svg")
340		b.recipeProp("svgs", "true")
341	}
342	if b.cpu() && b.matchOs("Android") {
343		// TODO(borenet): Where do these come from?
344		b.recipeProp("textTraces", "true")
345	}
346
347	// These properties are plumbed through nanobench and into Perf results.
348	nanoProps := map[string]string{
349		"gitHash":          specs.PLACEHOLDER_REVISION,
350		"issue":            specs.PLACEHOLDER_ISSUE,
351		"patchset":         specs.PLACEHOLDER_PATCHSET,
352		"patch_storage":    specs.PLACEHOLDER_PATCH_STORAGE,
353		"swarming_bot_id":  "${SWARMING_BOT_ID}",
354		"swarming_task_id": "${SWARMING_TASK_ID}",
355	}
356
357	if doUpload {
358		keysExclude := map[string]bool{
359			"role":        true,
360			"test_filter": true,
361		}
362		keys := make([]string, 0, len(b.parts))
363		for k := range b.parts {
364			keys = append(keys, k)
365		}
366		sort.Strings(keys)
367		args = append(args, "--key")
368		for _, k := range keys {
369			// We had not been adding this to our traces for a long time. We then started doing
370			// performance data on an "OptimizeForSize" build. We didn't want to disrupt the
371			// existing traces, so we skip the configuration for Release builds.
372			if k == "configuration" && b.parts[k] == "Release" {
373				continue
374			}
375			if !keysExclude[k] {
376				args = append(args, k, b.parts[k])
377			}
378		}
379	}
380
381	// Finalize the nanobench flags and properties.
382	b.recipeProp("nanobench_flags", marshalJson(args))
383	b.recipeProp("nanobench_properties", marshalJson(nanoProps))
384}
385