Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 5443bb3

Browse files
committed
[canvaskit] Start a generic puppeteer perfing system.
IMPORTANT LESSON: when bringing in node (and possibly other executables) via CIPD, add them to the path in gen_tasks_logic so the parent executable (the task driver itself) has the right PATH set. Otherwise, the subprocesses it spawns might grab the wrong version because of how golang handles environments of subprocesses. This is starting as a fork of Skottie WASM. I hope to have a more unified system for creating and running benchmarks. Overall overview: gen_tasks_logic.go creates a task in task.json that compiles CanvasKit and the task drivers and then executes our task (i.e. perf_puppeteer.go) perf_puppeteer runs a node program (perf-with-puppeteer.js) that uses puppeteer to execute benchmarking code on an html page (canvaskit-skottie-frames-load.html). I needed to update the node package so npm could be updated from 3.x to 6.14.4 so it knew about `npm ci`. This may not have been entirely necessary, given the problems of executing the correct npm (see important lesson above), but it hasn't broken things further, so more up-to-date is probably a good thing. Suggested Review Order: - canvaskit-skottie-frames-load.html (note it is similar to skottie-wasm-perf.html, but it waits for a button click to start animating and records times from the main JS thread itself) - perf-with-puppeteer.js (similar to skottie-wasm-perf.js, but has some things made optional [e.g. tracing]) - perf_puppeteer_test.go (shows the inputs/outputs of various steps) - perf_puppeteer.go - Everything else. Change-Id: I380e81b825f36682c257664d488267edaf36369e Reviewed-on: https://skia-review.googlesource.com/c/skia/+/285783 Commit-Queue: Kevin Lubick <[email protected]> Reviewed-by: Eric Boren <[email protected]>
1 parent e55e560 commit 5443bb3

File tree

16 files changed

+2621
-171
lines changed

16 files changed

+2621
-171
lines changed

infra/bots/assets/node/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2
1+
3

infra/bots/assets/node/create.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
import os
1414
import subprocess
1515

16-
NODE_URL = "https://nodejs.org/dist/v12.16.1/node-v12.16.1-linux-x64.tar.xz"
17-
NODE_EXTRACT_NAME = "node-v12.16.1-linux-x64"
16+
NODE_URL = "https://nodejs.org/dist/v12.16.3/node-v12.16.3-linux-x64.tar.xz"
17+
NODE_EXTRACT_NAME = "node-v12.16.3-linux-x64"
1818

1919
def create_asset(target_dir):
2020
"""Create the asset."""

infra/bots/gen_tasks_logic/gen_tasks_logic.go

Lines changed: 130 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ func (b *jobBuilder) deriveCompileTaskName() string {
443443
"ReleaseAndAbandonGpuContext", "CCPR", "FSAA", "FAAA", "FDAA", "NativeFonts", "GDI",
444444
"NoGPUThreads", "ProcDump", "DDL1", "DDL3", "T8888", "DDLTotal", "DDLRecord", "9x9",
445445
"BonusConfigs", "SkottieTracing", "SkottieWASM", "GpuTess", "NonNVPR", "Mskp",
446-
"Docker", "PDF", "SkVM"}
446+
"Docker", "PDF", "SkVM", "Puppeteer", "SkottieFrames"}
447447
keep := make([]string, 0, len(ec))
448448
for _, part := range ec {
449449
if !In(part, ignore) {
@@ -488,7 +488,7 @@ func (b *jobBuilder) deriveCompileTaskName() string {
488488
if b.extraConfig("PathKit") {
489489
ec = []string{"PathKit"}
490490
}
491-
if b.extraConfig("CanvasKit", "SkottieWASM") {
491+
if b.extraConfig("CanvasKit", "SkottieWASM", "Puppeteer") {
492492
if b.cpu() {
493493
ec = []string{"CanvasKit_CPU"}
494494
} else {
@@ -1271,7 +1271,7 @@ func (b *taskBuilder) commonTestPerfAssets() {
12711271
}
12721272
}
12731273

1274-
// test generates a Test task.
1274+
// dm generates a Test task using dm.
12751275
func (b *jobBuilder) dm() {
12761276
compileTaskName := ""
12771277
// LottieWeb doesn't require anything in Skia to be compiled.
@@ -1391,6 +1391,69 @@ func (b *jobBuilder) fm() {
13911391
})
13921392
}
13931393

1394+
// puppeteer generates a task that uses TaskDrivers combined with a node script and puppeteer to
1395+
// benchmark something using Chromium (e.g. CanvasKit, LottieWeb).
1396+
func (b *jobBuilder) puppeteer() {
1397+
compileTaskName := b.compile()
1398+
b.addTask(b.Name, func(b *taskBuilder) {
1399+
b.defaultSwarmDimensions()
1400+
b.isolate("perf_puppeteer.isolate")
1401+
b.cmd(
1402+
"./perf_puppeteer_skottie_frames",
1403+
"--project_id", "skia-swarming-bots",
1404+
"--git_hash", specs.PLACEHOLDER_REVISION,
1405+
"--task_id", specs.PLACEHOLDER_TASK_ID,
1406+
"--task_name", b.Name,
1407+
"--canvaskit_bin_path", "./build",
1408+
"--lotties_path", "./lotties_with_assets",
1409+
"--node_bin_path", "./node/node/bin",
1410+
"--benchmark_path", "./tools/perf-canvaskit-puppeteer",
1411+
"--output_path", OUTPUT_PERF,
1412+
"--os_trace", b.parts["os"],
1413+
"--model_trace", b.parts["model"],
1414+
"--cpu_or_gpu_trace", b.parts["cpu_or_gpu"],
1415+
"--cpu_or_gpu_value_trace", b.parts["cpu_or_gpu_value"],
1416+
"--alsologtostderr",
1417+
)
1418+
b.serviceAccount(b.cfg.ServiceAccountCompile)
1419+
// This CIPD package was made by hand with the following invocation:
1420+
// cipd create -name skia/internal/lotties_with_assets -in ./lotties/ -tag version:0
1421+
// cipd acl-edit skia/internal/lotties_with_assets -reader group:project-skia-external-task-accounts
1422+
// cipd acl-edit skia/internal/lotties_with_assets -reader user:[email protected]
1423+
// Where lotties is a hand-selected set of lottie animations and (optionally) assets used in
1424+
// them (e.g. fonts, images).
1425+
b.cipd(&specs.CipdPackage{
1426+
Name: "skia/internal/lotties_with_assets",
1427+
Path: "lotties_with_assets",
1428+
Version: "version:0",
1429+
})
1430+
b.usesNode()
1431+
b.cipd(CIPD_PKG_LUCI_AUTH)
1432+
b.dep(b.buildTaskDrivers(), compileTaskName)
1433+
b.output(OUTPUT_PERF)
1434+
b.timeout(20 * time.Minute)
1435+
})
1436+
1437+
// Upload results to Perf after.
1438+
// TODO(kjlubick,borenet) deduplicate this with the logic in perf().
1439+
uploadName := fmt.Sprintf("%s%s%s", PREFIX_UPLOAD, b.jobNameSchema.Sep, b.Name)
1440+
depName := b.Name
1441+
b.addTask(uploadName, func(b *taskBuilder) {
1442+
b.recipeProp("gs_bucket", b.cfg.GsBucketNano)
1443+
b.recipeProps(EXTRA_PROPS)
1444+
// TODO(borenet): I'm not sure why the upload task is
1445+
// using the Perf task name, but I've done this to
1446+
// maintain existing behavior.
1447+
b.Name = depName
1448+
b.kitchenTask("upload_nano_results", OUTPUT_NONE)
1449+
b.Name = uploadName
1450+
b.serviceAccount(b.cfg.ServiceAccountUploadNano)
1451+
b.linuxGceDimensions(MACHINE_TYPE_SMALL)
1452+
b.cipd(specs.CIPD_PKGS_GSUTIL...)
1453+
b.dep(depName)
1454+
})
1455+
}
1456+
13941457
// perf generates a Perf task.
13951458
func (b *jobBuilder) perf() {
13961459
compileTaskName := ""
@@ -1399,92 +1462,72 @@ func (b *jobBuilder) perf() {
13991462
compileTaskName = b.compile()
14001463
}
14011464
doUpload := b.release() && b.doUpload()
1402-
if b.extraConfig("TaskDriver") {
1403-
doUpload = false
1404-
b.addTask(b.Name, func(b *taskBuilder) {
1405-
b.linuxGceDimensions(MACHINE_TYPE_SMALL)
1406-
b.isolate("skottie_wasm.isolate")
1407-
b.cmd(
1408-
"./perf_skottie_wasm",
1409-
"--project_id", "skia-swarming-bots",
1410-
"--task_id", specs.PLACEHOLDER_TASK_ID,
1411-
"--task_name", b.Name,
1412-
"--workdir", ".",
1413-
"--alsologtostderr",
1414-
)
1415-
b.serviceAccount(b.cfg.ServiceAccountCompile)
1416-
b.cipd(CIPD_PKG_LUCI_AUTH)
1417-
b.dep(b.buildTaskDrivers(), compileTaskName)
1418-
b.timeout(20 * time.Minute)
1419-
})
1420-
} else {
1421-
b.addTask(b.Name, func(b *taskBuilder) {
1422-
recipe := "perf"
1423-
isolate := "perf_skia_bundled.isolate"
1424-
if b.extraConfig("Skpbench") {
1425-
recipe = "skpbench"
1426-
isolate = "skpbench_skia_bundled.isolate"
1427-
} else if b.extraConfig("PathKit") {
1428-
isolate = "pathkit.isolate"
1429-
recipe = "perf_pathkit"
1430-
} else if b.extraConfig("CanvasKit") {
1431-
isolate = "canvaskit.isolate"
1432-
recipe = "perf_canvaskit"
1433-
} else if b.extraConfig("SkottieTracing") {
1434-
recipe = "perf_skottietrace"
1435-
} else if b.extraConfig("SkottieWASM") {
1436-
recipe = "perf_skottiewasm_lottieweb"
1437-
isolate = "skottie_wasm.isolate"
1438-
} else if b.extraConfig("LottieWeb") {
1439-
recipe = "perf_skottiewasm_lottieweb"
1440-
isolate = "lottie_web.isolate"
1441-
}
1442-
b.recipeProps(EXTRA_PROPS)
1443-
if recipe == "perf" {
1444-
b.nanobenchFlags(doUpload)
1445-
}
1446-
b.kitchenTask(recipe, OUTPUT_PERF)
1447-
b.isolate(isolate)
1448-
b.swarmDimensions()
1449-
if b.extraConfig("CanvasKit", "Docker", "PathKit") {
1450-
b.usesDocker()
1451-
}
1452-
if compileTaskName != "" {
1453-
b.dep(compileTaskName)
1454-
}
1455-
b.commonTestPerfAssets()
1456-
b.expiration(20 * time.Hour)
1457-
b.timeout(4 * time.Hour)
1458-
1459-
if b.extraConfig("Valgrind") {
1460-
b.timeout(9 * time.Hour)
1461-
b.expiration(48 * time.Hour)
1462-
b.asset("valgrind")
1463-
// Since Valgrind runs on the same bots as the CQ, we restrict Valgrind to a subset of the bots
1464-
// to ensure there are always bots free for CQ tasks.
1465-
b.dimension("valgrind:1")
1466-
} else if b.extraConfig("MSAN") {
1467-
b.timeout(9 * time.Hour)
1468-
} else if b.parts["arch"] == "x86" && b.parts["configuration"] == "Debug" {
1469-
// skia:6737
1470-
b.timeout(6 * time.Hour)
1471-
} else if b.extraConfig("LottieWeb", "SkottieWASM") {
1472-
b.asset("node", "lottie-samples")
1473-
} else if b.matchExtraConfig("Skottie") {
1474-
b.asset("lottie-samples")
1475-
}
1465+
b.addTask(b.Name, func(b *taskBuilder) {
1466+
recipe := "perf"
1467+
isolate := "perf_skia_bundled.isolate"
1468+
if b.extraConfig("Skpbench") {
1469+
recipe = "skpbench"
1470+
isolate = "skpbench_skia_bundled.isolate"
1471+
} else if b.extraConfig("PathKit") {
1472+
isolate = "pathkit.isolate"
1473+
recipe = "perf_pathkit"
1474+
} else if b.extraConfig("CanvasKit") {
1475+
isolate = "canvaskit.isolate"
1476+
recipe = "perf_canvaskit"
1477+
} else if b.extraConfig("SkottieTracing") {
1478+
recipe = "perf_skottietrace"
1479+
} else if b.extraConfig("SkottieWASM") {
1480+
recipe = "perf_skottiewasm_lottieweb"
1481+
isolate = "skottie_wasm.isolate"
1482+
} else if b.extraConfig("LottieWeb") {
1483+
recipe = "perf_skottiewasm_lottieweb"
1484+
isolate = "lottie_web.isolate"
1485+
}
1486+
b.recipeProps(EXTRA_PROPS)
1487+
if recipe == "perf" {
1488+
b.nanobenchFlags(doUpload)
1489+
}
1490+
b.kitchenTask(recipe, OUTPUT_PERF)
1491+
b.isolate(isolate)
1492+
b.swarmDimensions()
1493+
if b.extraConfig("CanvasKit", "Docker", "PathKit") {
1494+
b.usesDocker()
1495+
}
1496+
if compileTaskName != "" {
1497+
b.dep(compileTaskName)
1498+
}
1499+
b.commonTestPerfAssets()
1500+
b.expiration(20 * time.Hour)
1501+
b.timeout(4 * time.Hour)
14761502

1477-
if b.os("Android") && b.cpu() {
1478-
b.asset("text_blob_traces")
1479-
}
1480-
b.maybeAddIosDevImage()
1503+
if b.extraConfig("Valgrind") {
1504+
b.timeout(9 * time.Hour)
1505+
b.expiration(48 * time.Hour)
1506+
b.asset("valgrind")
1507+
// Since Valgrind runs on the same bots as the CQ, we restrict Valgrind to a subset of the bots
1508+
// to ensure there are always bots free for CQ tasks.
1509+
b.dimension("valgrind:1")
1510+
} else if b.extraConfig("MSAN") {
1511+
b.timeout(9 * time.Hour)
1512+
} else if b.parts["arch"] == "x86" && b.parts["configuration"] == "Debug" {
1513+
// skia:6737
1514+
b.timeout(6 * time.Hour)
1515+
} else if b.extraConfig("LottieWeb", "SkottieWASM") {
1516+
b.asset("node", "lottie-samples")
1517+
} else if b.matchExtraConfig("Skottie") {
1518+
b.asset("lottie-samples")
1519+
}
14811520

1482-
iid := b.internalHardwareLabel()
1483-
if iid != nil {
1484-
b.Spec.Command = append(b.Spec.Command, fmt.Sprintf("internal_hardware_label=%d", *iid))
1485-
}
1486-
})
1487-
}
1521+
if b.os("Android") && b.cpu() {
1522+
b.asset("text_blob_traces")
1523+
}
1524+
b.maybeAddIosDevImage()
1525+
1526+
iid := b.internalHardwareLabel()
1527+
if iid != nil {
1528+
b.Spec.Command = append(b.Spec.Command, fmt.Sprintf("internal_hardware_label=%d", *iid))
1529+
}
1530+
})
14881531

14891532
// Upload results if necessary.
14901533
if doUpload {

infra/bots/gen_tasks_logic/job_builder.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,12 @@ func (b *jobBuilder) genTasksForJob() {
188188
return
189189
}
190190

191+
if b.extraConfig("Puppeteer") {
192+
// TODO(kjlubick) make this a new role
193+
b.puppeteer()
194+
return
195+
}
196+
191197
// Perf bots.
192198
if b.role("Perf") {
193199
b.perf()

infra/bots/gen_tasks_logic/task_builder.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,3 +274,10 @@ func (b *taskBuilder) usesPython() {
274274
})
275275
b.env("VPYTHON_VIRTUALENV_ROOT", "cache/vpython")
276276
}
277+
278+
func (b *taskBuilder) usesNode() {
279+
// It is very important when including node via CIPD to also add it to the PATH of the
280+
// taskdriver or mysterious things can happen when subprocesses try to resolve node/npm.
281+
b.asset("node")
282+
b.addToPATH("node/node/bin")
283+
}

infra/bots/jobs.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@
230230
"Perf-Debian10-EMCC-GCE-CPU-AVX2-wasm-Release-All-CanvasKit",
231231
"Perf-Debian10-EMCC-GCE-CPU-AVX2-wasm-Release-All-PathKit",
232232
"Perf-Debian10-EMCC-GCE-CPU-AVX2-wasm-Release-All-SkottieWASM",
233-
"Perf-Debian10-EMCC-GCE-CPU-AVX2-wasm-Release-All-SkottieWASM_TaskDriver",
233+
"Perf-Debian10-EMCC-GCE-CPU-AVX2-wasm-Release-All-Puppeteer_SkottieFrames",
234234
"Perf-Debian10-EMCC-GCE-GPU-AVX2-wasm-Release-All-CanvasKit",
235235
"Perf-Debian10-none-GCE-CPU-AVX2-x86_64-Release-All-LottieWeb",
236236
"Perf-Mac10.13-Clang-MacBook10.1-GPU-IntelHD615-x86_64-Release-All",
@@ -252,6 +252,7 @@
252252
"Perf-Ubuntu18-Clang-Golo-GPU-QuadroP400-x86_64-Release-All-Valgrind_SK_CPU_LIMIT_SSE41",
253253
"Perf-Ubuntu18-Clang-Golo-GPU-QuadroP400-x86_64-Release-All-Vulkan",
254254
"Perf-Ubuntu18-EMCC-Golo-GPU-QuadroP400-wasm-Release-All-SkottieWASM",
255+
"Perf-Ubuntu18-EMCC-Golo-GPU-QuadroP400-wasm-Release-All-Puppeteer_SkottieFrames",
255256
"Perf-Ubuntu18-none-Golo-GPU-QuadroP400-x86_64-Release-All-LottieWeb",
256257
"Perf-Win10-Clang-AlphaR2-GPU-RadeonR9M470X-x86_64-Release-All",
257258
"Perf-Win10-Clang-AlphaR2-GPU-RadeonR9M470X-x86_64-Release-All-ANGLE",

infra/bots/perf_puppeteer.isolate

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
'variables': {
3+
'files': [
4+
'../../tools/perf-canvaskit-puppeteer/',
5+
],
6+
},
7+
}

0 commit comments

Comments
 (0)