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