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