[bazel] Use pre-built taskdriver for faster BazelBuild jobs
With a hot Bazel cache, https://task-scheduler.skia.org/job/4XhwJfG1wR38Hp3dF1pI took 59 seconds and did not have to wait 1-2 minutes for TaskScheduler to schedule a prerequisite task and Swarming to deduplicate said task, which is the best case scenario for "all hot caches". Change-Id: Ic86599e0b886ecded836641cceb19b623065a91e Bug: skia:12541 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/546136 Reviewed-by: Eric Boren <borenet@google.com>
This commit is contained in:
parent
cb8e5b28f0
commit
f64f211283
1
infra/bots/assets/bazel_build_task_driver/VERSION
Executable file
1
infra/bots/assets/bazel_build_task_driver/VERSION
Executable file
@ -0,0 +1 @@
|
||||
0
|
46
infra/bots/assets/bazel_build_task_driver/create.py
Executable file
46
infra/bots/assets/bazel_build_task_driver/create.py
Executable file
@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright 2022 Google LLC
|
||||
#
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
|
||||
"""
|
||||
Create bazel_build task_driver. This should rarely need to change, so by putting it into
|
||||
CIPD, we should reduce build latency by removing the need for the BuildTaskDrivers job.
|
||||
That job *is* idempotent, so Swarming does eventually deduplicate it sometimes (but not
|
||||
after a usually unrelated change to something in //bazel), but skipping the step is faster.
|
||||
"""
|
||||
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
|
||||
FILE_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
SKIA_ROOT_DIR = os.path.realpath(os.path.join(FILE_DIR, os.pardir, os.pardir, os.pardir, os.pardir))
|
||||
|
||||
def create_asset(target_dir):
|
||||
"""Compiles the task driver using bazel, which is presumed to be on PATH """
|
||||
out = subprocess.check_output([
|
||||
"bazel", "build", "//infra/bots/task_drivers/bazel_build",
|
||||
"--platforms=@io_bazel_rules_go//go/toolchain:linux_amd64",
|
||||
], encoding='utf-8')
|
||||
print(out)
|
||||
path_to_binary = os.path.join(SKIA_ROOT_DIR, 'bazel-bin', 'infra', 'bots', 'task_drivers',
|
||||
'bazel_build', 'bazel_build_', 'bazel_build')
|
||||
shutil.copy(path_to_binary, target_dir)
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--target_dir', '-t', required=True)
|
||||
args = parser.parse_args()
|
||||
create_asset(args.target_dir)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
@ -2114,12 +2114,13 @@ func (b *jobBuilder) bazelBuild() {
|
||||
panic("unsupported Bazel label shorthand " + shorthand)
|
||||
}
|
||||
b.addTask(b.Name, func(b *taskBuilder) {
|
||||
cmd := []string{"./bazel_build",
|
||||
cmd := []string{"bazel_build_task_driver/bazel_build",
|
||||
"--project_id=skia-swarming-bots",
|
||||
"--task_id=" + specs.PLACEHOLDER_TASK_ID,
|
||||
"--task_name=" + b.Name,
|
||||
"--label=" + label,
|
||||
"--config=" + config,
|
||||
"--workdir=.",
|
||||
}
|
||||
if cross != "" {
|
||||
// The cross (and host) platform is expected to be defined in
|
||||
@ -2129,7 +2130,13 @@ func (b *jobBuilder) bazelBuild() {
|
||||
}
|
||||
if host == "linux_x64" {
|
||||
b.linuxGceDimensions(MACHINE_TYPE_MEDIUM)
|
||||
b.dep(b.buildTaskDrivers("linux", "amd64"))
|
||||
// Use a built task_driver from CIPD instead of building it from scratch. The
|
||||
// task_driver should not need to change often, so using a CIPD version should reduce
|
||||
// build latency.
|
||||
// TODO(kjlubick) For now, this only has the linux version. We could build the task
|
||||
// driver for all hosts that we support running Bazel from in this CIPD package
|
||||
// if/when needed.
|
||||
b.cipd(b.MustGetCipdPackageFromAsset("bazel_build_task_driver"))
|
||||
|
||||
// We want all Linux Bazel Builds to use RBE
|
||||
cmd = append(cmd, "--bazel_arg=--config=linux_rbe")
|
||||
|
@ -3218,6 +3218,11 @@
|
||||
"BazelBuild-example_hello_world_dawn-release-linux_x64": {
|
||||
"casSpec": "compile",
|
||||
"cipd_packages": [
|
||||
{
|
||||
"name": "skia/bots/bazel_build_task_driver",
|
||||
"path": "bazel_build_task_driver",
|
||||
"version": "version:0"
|
||||
},
|
||||
{
|
||||
"name": "skia/bots/bazelisk",
|
||||
"path": "bazelisk",
|
||||
@ -3225,19 +3230,17 @@
|
||||
}
|
||||
],
|
||||
"command": [
|
||||
"./bazel_build",
|
||||
"bazel_build_task_driver/bazel_build",
|
||||
"--project_id=skia-swarming-bots",
|
||||
"--task_id=<(TASK_ID)",
|
||||
"--task_name=BazelBuild-example_hello_world_dawn-release-linux_x64",
|
||||
"--label=//example:hello_world_dawn",
|
||||
"--config=release",
|
||||
"--workdir=.",
|
||||
"--bazel_arg=--config=linux_rbe",
|
||||
"--bazel_arg=--jobs=100",
|
||||
"--bazel_arg=--remote_download_minimal"
|
||||
],
|
||||
"dependencies": [
|
||||
"Housekeeper-PerCommit-BuildTaskDrivers_linux_amd64"
|
||||
],
|
||||
"dimensions": [
|
||||
"cpu:x86-64-Haswell_GCE",
|
||||
"gpu:none",
|
||||
@ -3257,6 +3260,11 @@
|
||||
"BazelBuild-example_hello_world_gl-release-linux_x64": {
|
||||
"casSpec": "compile",
|
||||
"cipd_packages": [
|
||||
{
|
||||
"name": "skia/bots/bazel_build_task_driver",
|
||||
"path": "bazel_build_task_driver",
|
||||
"version": "version:0"
|
||||
},
|
||||
{
|
||||
"name": "skia/bots/bazelisk",
|
||||
"path": "bazelisk",
|
||||
@ -3264,19 +3272,17 @@
|
||||
}
|
||||
],
|
||||
"command": [
|
||||
"./bazel_build",
|
||||
"bazel_build_task_driver/bazel_build",
|
||||
"--project_id=skia-swarming-bots",
|
||||
"--task_id=<(TASK_ID)",
|
||||
"--task_name=BazelBuild-example_hello_world_gl-release-linux_x64",
|
||||
"--label=//example:hello_world_gl",
|
||||
"--config=release",
|
||||
"--workdir=.",
|
||||
"--bazel_arg=--config=linux_rbe",
|
||||
"--bazel_arg=--jobs=100",
|
||||
"--bazel_arg=--remote_download_minimal"
|
||||
],
|
||||
"dependencies": [
|
||||
"Housekeeper-PerCommit-BuildTaskDrivers_linux_amd64"
|
||||
],
|
||||
"dimensions": [
|
||||
"cpu:x86-64-Haswell_GCE",
|
||||
"gpu:none",
|
||||
@ -3296,6 +3302,11 @@
|
||||
"BazelBuild-example_hello_world_vulkan-release-linux_x64": {
|
||||
"casSpec": "compile",
|
||||
"cipd_packages": [
|
||||
{
|
||||
"name": "skia/bots/bazel_build_task_driver",
|
||||
"path": "bazel_build_task_driver",
|
||||
"version": "version:0"
|
||||
},
|
||||
{
|
||||
"name": "skia/bots/bazelisk",
|
||||
"path": "bazelisk",
|
||||
@ -3303,19 +3314,17 @@
|
||||
}
|
||||
],
|
||||
"command": [
|
||||
"./bazel_build",
|
||||
"bazel_build_task_driver/bazel_build",
|
||||
"--project_id=skia-swarming-bots",
|
||||
"--task_id=<(TASK_ID)",
|
||||
"--task_name=BazelBuild-example_hello_world_vulkan-release-linux_x64",
|
||||
"--label=//example:hello_world_vulkan",
|
||||
"--config=release",
|
||||
"--workdir=.",
|
||||
"--bazel_arg=--config=linux_rbe",
|
||||
"--bazel_arg=--jobs=100",
|
||||
"--bazel_arg=--remote_download_minimal"
|
||||
],
|
||||
"dependencies": [
|
||||
"Housekeeper-PerCommit-BuildTaskDrivers_linux_amd64"
|
||||
],
|
||||
"dimensions": [
|
||||
"cpu:x86-64-Haswell_GCE",
|
||||
"gpu:none",
|
||||
@ -3335,6 +3344,11 @@
|
||||
"BazelBuild-modules_canvaskit_canvaskit_wasm-debug-linux_x64": {
|
||||
"casSpec": "compile",
|
||||
"cipd_packages": [
|
||||
{
|
||||
"name": "skia/bots/bazel_build_task_driver",
|
||||
"path": "bazel_build_task_driver",
|
||||
"version": "version:0"
|
||||
},
|
||||
{
|
||||
"name": "skia/bots/bazelisk",
|
||||
"path": "bazelisk",
|
||||
@ -3342,19 +3356,17 @@
|
||||
}
|
||||
],
|
||||
"command": [
|
||||
"./bazel_build",
|
||||
"bazel_build_task_driver/bazel_build",
|
||||
"--project_id=skia-swarming-bots",
|
||||
"--task_id=<(TASK_ID)",
|
||||
"--task_name=BazelBuild-modules_canvaskit_canvaskit_wasm-debug-linux_x64",
|
||||
"--label=//modules/canvaskit:canvaskit_wasm",
|
||||
"--config=debug",
|
||||
"--workdir=.",
|
||||
"--bazel_arg=--config=linux_rbe",
|
||||
"--bazel_arg=--jobs=100",
|
||||
"--bazel_arg=--remote_download_minimal"
|
||||
],
|
||||
"dependencies": [
|
||||
"Housekeeper-PerCommit-BuildTaskDrivers_linux_amd64"
|
||||
],
|
||||
"dimensions": [
|
||||
"cpu:x86-64-Haswell_GCE",
|
||||
"gpu:none",
|
||||
|
Loading…
Reference in New Issue
Block a user