From eae12ea63d2d79e328a53cc36e9251865cdb255a Mon Sep 17 00:00:00 2001 From: Felix Hanau Date: Wed, 23 Oct 2024 13:26:09 -0400 Subject: [PATCH] [build] Disable WebGPU for Windows non-release builds The Windows build is currently much slower than the macOS/Linux builds on CI, especially on mostly cached builds. Based on profiling on #2981, this is caused by the repo mapping stage for dawn taking several minutes of Windows. Disable the experimental WebGPU feature on Windows to better meet compile time constraints. Release builds remain unaffected. Fetching WPT also contributes here. Only fetch/use WPT on Unix and only configure targets based on globs as we start using them, Bazel configures 90,000 targets for it otherwise. --- .bazelrc | 29 ++++++++++++-------- .github/workflows/_bazel.yml | 27 +----------------- .github/workflows/npm-types.yml | 10 +------ .github/workflows/npm.yml | 10 +------ .github/workflows/release-python-runtime.yml | 2 +- .github/workflows/release.yml | 10 +------ build/BUILD.wpt | 15 ++++------ build/ci.bazelrc | 9 ++++-- build/wpt_test.bzl | 9 ++++++ src/wpt/BUILD.bazel | 3 +- 10 files changed, 44 insertions(+), 80 deletions(-) diff --git a/.bazelrc b/.bazelrc index 90988b77da23..a6cac592ff2c 100644 --- a/.bazelrc +++ b/.bazelrc @@ -26,8 +26,13 @@ import %workspace%/build/ci.bazelrc import %workspace%/build/lint.bazelrc -# Enable webgpu -build --//src/workerd/io:enable_experimental_webgpu=True +# Enable webgpu. Merely fetching the required Dawn library and computing the repo mapping based on +# it slows down the Windows build significantly, so only enable this on Unix and for Windows release +# builds. This is mostly motivated by compile time constraints, we hope to lift this limitation +# again if this Windows performance bottleneck gets fixed within Bazel. +build:unix --config=webgpu +build:release_windows --config=webgpu +build:webgpu --//src/workerd/io:enable_experimental_webgpu=True # Avoid generating duplicate runfile trees. This will become the default in a future bazel version. build --nolegacy_external_runfiles @@ -38,16 +43,16 @@ build --incompatible_disallow_empty_glob # Prevents bazel cache invalidation when switching terminals build --incompatible_strict_action_env -# Dawn tint build flags -build --@dawn//src/tint:tint_build_glsl_writer=False -build --@dawn//src/tint:tint_build_glsl_validator=False -build --@dawn//src/tint:tint_build_hlsl_writer=True -build --@dawn//src/tint:tint_build_ir=False -build --@dawn//src/tint:tint_build_msl_writer=True -build --@dawn//src/tint:tint_build_spv_reader=False -build --@dawn//src/tint:tint_build_spv_writer=True -build --@dawn//src/tint:tint_build_wgsl_reader=True -build --@dawn//src/tint:tint_build_wgsl_writer=True +# Dawn tint build flags. Only enable when building with webgpu support +build:webgpu --@dawn//src/tint:tint_build_glsl_writer=False +build:webgpu --@dawn//src/tint:tint_build_glsl_validator=False +build:webgpu --@dawn//src/tint:tint_build_hlsl_writer=True +build:webgpu --@dawn//src/tint:tint_build_ir=False +build:webgpu --@dawn//src/tint:tint_build_msl_writer=True +build:webgpu --@dawn//src/tint:tint_build_spv_reader=False +build:webgpu --@dawn//src/tint:tint_build_spv_writer=True +build:webgpu --@dawn//src/tint:tint_build_wgsl_reader=True +build:webgpu --@dawn//src/tint:tint_build_wgsl_writer=True # Our dependencies (ICU, zlib, etc.) produce a lot of these warnings, so we disable them. Depending # on the clang version, zlib either produces warnings for -Wdeprecated-non-prototype or does not diff --git a/.github/workflows/_bazel.yml b/.github/workflows/_bazel.yml index 9e9c70b19f93..669aafa37f9c 100644 --- a/.github/workflows/_bazel.yml +++ b/.github/workflows/_bazel.yml @@ -35,15 +35,6 @@ jobs: - uses: actions/checkout@v4 with: show-progress: false - - name: Cache - id: cache - uses: actions/cache@v4 - with: - path: ~/bazel-disk-cache - key: bazel-disk-cache-${{ inputs.os_name }}-${{ runner.arch }}${{ inputs.suffix }}-${{ hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE') }} - # Intentionally not reusing an older cache entry using a key prefix, bazel frequently - # ends up with a larger cache at the end when starting with an available cache entry, - # resulting in a snowballing cache size and cache download/upload times. - name: Setup Linux if: inputs.os_name == 'linux' # Install dependencies, including clang through the LLVM APT repository. We drop the @@ -94,27 +85,11 @@ jobs: BAZEL_OUTPUT_BASE=$(bazel info output_base) BAZEL_REPOSITORY_CACHE=$(bazel info repository_cache) echo "Bazel cache usage statistics" - du -ms -t 1 ~/bazel-disk-cache/* $BAZEL_REPOSITORY_CACHE + du -ms -t 1 $BAZEL_REPOSITORY_CACHE echo "Bazel output usage statistics" du -ms -t 1 $BAZEL_OUTPUT_BASE echo "Workspace usage statistics" du -ms -t 1 $GITHUB_WORKSPACE - - name: Drop large Bazel cache files - if: always() - # Github has a nominal 10GB of storage for all cached builds associated with a project. - # Drop large files (>100MB) in our cache to improve shared build cache efficiency. This is - # particularly helpful for asan and debug builds that produce larger executables. Also - # the process of saving the Bazel disk cache generates a tarball on the runners disk, and - # it is possible to run out of storage in that process (does not fail the workflow). - shell: bash - run: | - if [ -d ~/bazel-disk-cache ]; then - find ~/bazel-disk-cache -size +100M -type f -exec rm {} \; - echo "Trimmed Bazel cache usage statistics" - du -ms -t 1 ~/bazel-disk-cache/* - else - echo "Disk cache does not exist: ~/bazel-disk-cache" - fi - name: Bazel shutdown # Check that there are no .bazelrc issues that prevent shutdown. run: bazel shutdown diff --git a/.github/workflows/npm-types.yml b/.github/workflows/npm-types.yml index 66fb622622a5..a507cd306260 100644 --- a/.github/workflows/npm-types.yml +++ b/.github/workflows/npm-types.yml @@ -36,14 +36,6 @@ jobs: - uses: actions/checkout@v4 with: show-progress: false - - name: Cache - id: cache - uses: actions/cache@v4 - # Use same cache and build configuration as release build, this allows us to keep download - # sizes small and generate types with optimization enabled, should be slightly faster. - with: - path: ~/bazel-disk-cache - key: bazel-disk-cache-release-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE') }} - name: Setup Linux run: | export DEBIAN_FRONTEND=noninteractive @@ -56,7 +48,7 @@ jobs: echo "build:linux --host_action_env=CC=/usr/lib/llvm-16/bin/clang --host_action_env=CXX=/usr/lib/llvm-16/bin/clang++" >> .bazelrc - name: build types run: | - bazel build --disk_cache=~/bazel-disk-cache --strip=always --remote_cache=https://bazel:${{ secrets.BAZEL_CACHE_KEY }}@bazel-remote-cache.devprod.cloudflare.dev --config=ci --config=release_linux //types:types + bazel build --strip=always --remote_cache=https://bazel:${{ secrets.BAZEL_CACHE_KEY }}@bazel-remote-cache.devprod.cloudflare.dev --config=ci --config=release_linux //types:types - name: Build package run: node npm/scripts/build-types-package.mjs env: diff --git a/.github/workflows/npm.yml b/.github/workflows/npm.yml index c7fdcaf83c3d..e6acfca50933 100644 --- a/.github/workflows/npm.yml +++ b/.github/workflows/npm.yml @@ -87,14 +87,6 @@ jobs: with: node-version: 18 - - name: Cache - id: cache - uses: actions/cache@v4 - # Use same cache and build configuration as release build, this allows us to keep download - # sizes small and generate types with optimization enabled, should be slightly faster. - with: - path: ~/bazel-disk-cache - key: bazel-disk-cache-release-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE') }} - name: Setup Linux run: | export DEBIAN_FRONTEND=noninteractive @@ -107,7 +99,7 @@ jobs: echo "build:linux --host_action_env=CC=/usr/lib/llvm-16/bin/clang --host_action_env=CXX=/usr/lib/llvm-16/bin/clang++" >> .bazelrc - name: Build type generating Worker run: | - bazel build --disk_cache=~/bazel-disk-cache --strip=always --remote_cache=https://bazel:${{ secrets.BAZEL_CACHE_KEY }}@bazel-remote-cache.devprod.cloudflare.dev --config=ci --config=release_linux //types:types_worker + bazel build --strip=always --remote_cache=https://bazel:${{ secrets.BAZEL_CACHE_KEY }}@bazel-remote-cache.devprod.cloudflare.dev --config=ci --config=release_linux //types:types_worker - name: Modify package.json version run: node npm/scripts/bump-version.mjs npm/workerd/package.json diff --git a/.github/workflows/release-python-runtime.yml b/.github/workflows/release-python-runtime.yml index 41c0df8b6d5a..26461d864424 100644 --- a/.github/workflows/release-python-runtime.yml +++ b/.github/workflows/release-python-runtime.yml @@ -38,7 +38,7 @@ jobs: fi - name: Bazel build run: | - bazel build //src/pyodide:pyodide.capnp.bin@rule --disk_cache=~/bazel-disk-cache --strip=always --remote_cache=https://bazel:${{ secrets.BAZEL_CACHE_KEY }}@bazel-remote-cache.devprod.cloudflare.dev --config=ci --config=release_linux + bazel build //src/pyodide:pyodide.capnp.bin@rule --strip=always --remote_cache=https://bazel:${{ secrets.BAZEL_CACHE_KEY }}@bazel-remote-cache.devprod.cloudflare.dev --config=ci --config=release_linux cp bazel-bin/src/pyodide/pyodide.capnp.bin . - name: Upload Pyodide capnproto bundle env: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index da7c0663ed96..c97087108eb7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -78,14 +78,6 @@ jobs: - uses: actions/checkout@v4 with: show-progress: false - - name: Cache - id: cache - uses: actions/cache@v4 - with: - path: ~/bazel-disk-cache - # Use a different cache key than for tests here, otherwise the release cache could end up - # being used for test builds, where it provides little benefit. - key: bazel-disk-cache-release-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE') }} - name: Setup Linux if: runner.os == 'Linux' run: | @@ -127,7 +119,7 @@ jobs: # static libraries, for example the Rust STL. This is equivalent to the -Wl,-S linker # option, symbols will not be removed. run: | - bazel build --disk_cache=~/bazel-disk-cache --strip=always --remote_cache=https://bazel:${{ secrets.BAZEL_CACHE_KEY }}@bazel-remote-cache.devprod.cloudflare.dev --config=ci --config=${{ matrix.bazel-config }} //src/workerd/server:workerd + bazel build --strip=always --remote_cache=https://bazel:${{ secrets.BAZEL_CACHE_KEY }}@bazel-remote-cache.devprod.cloudflare.dev --config=ci --config=${{ matrix.bazel-config }} //src/workerd/server:workerd - name: Upload binary uses: actions/upload-artifact@v4 with: diff --git a/build/BUILD.wpt b/build/BUILD.wpt index 757b227041c7..b6fecfff69d2 100644 --- a/build/BUILD.wpt +++ b/build/BUILD.wpt @@ -2,16 +2,11 @@ # Licensed under the Apache 2.0 license found in the LICENSE file or at: # https://opensource.org/licenses/Apache-2.0 -directories = glob( - ["*"], - exclude = glob( - ["*"], - exclude_directories = 1, - ) + [ - ".*", - ], - exclude_directories = 0, -) +# successively enable wpt targets +directories = [ + "url", + "urlpattern", +] [filegroup( name = dir, diff --git a/build/ci.bazelrc b/build/ci.bazelrc index 71d8f68d0121..e6ff7d0e931f 100644 --- a/build/ci.bazelrc +++ b/build/ci.bazelrc @@ -9,7 +9,7 @@ build:ci --verbose_failures # increasing this closer towards the suggested value of 200. Note the number of maximum build jobs # is controlled by the --local_resources=cpu flag and still limited to the number of cores by # default. -build:ci --jobs=32 +build:ci --jobs=48 # Do not check for changes in external repository files, should speed up bazel invocations after the first one build:ci --noexperimental_check_external_repository_files # Rate limit progress updates for smaller logs, default is 0.2 which leads to very frequent updates. @@ -19,9 +19,14 @@ build:ci --color=yes # Indicate support for more terminal columns, 100 is the line length recommended by KJ style. build:ci --terminal_columns=100 +# Only build runfile trees when needed/lazily, so that they are not built for disabled tests +build:ci --nobuild_runfile_links +# Speeds up CI build by making action output uploads non-blocking so Bazel can e.g. run a test +# before it finishes uploading the test binary. On-by-default in Bazel 8. +build:ci --experimental_remote_cache_async + build:ci --config=v8-codegen-opt test:ci --test_output=errors -build:ci --disk_cache=~/bazel-disk-cache # test CI jobs don't need any top-level artifacts and just verify things build:ci-test --remote_download_outputs=minimal diff --git a/build/wpt_test.bzl b/build/wpt_test.bzl index 35bff703d29f..8cebac33210c 100644 --- a/build/wpt_test.bzl +++ b/build/wpt_test.bzl @@ -16,6 +16,10 @@ def wpt_test(name, wpt_directory, test_js): test_name = name, wpt_directory = wpt_directory, test_js = test_js, + target_compatible_with = select({ + "@platforms//os:windows": ["@platforms//:incompatible"], + "//conditions:default": [], + }), ) wd_test( @@ -28,6 +32,11 @@ def wpt_test(name, wpt_directory, test_js): wpt_directory, "//src/workerd/io:trimmed-supported-compatibility-date.txt", ], + # Even generating WPT tests is prohibitively expensive on Windows, disable it there + target_compatible_with = select({ + "@platforms//os:windows": ["@platforms//:incompatible"], + "//conditions:default": [], + }), ) def _wpt_test_gen_impl(ctx): diff --git a/src/wpt/BUILD.bazel b/src/wpt/BUILD.bazel index 4eda7837a58b..f8ad536a57f8 100644 --- a/src/wpt/BUILD.bazel +++ b/src/wpt/BUILD.bazel @@ -1,8 +1,7 @@ filegroup( name = "wpt-test-harness", srcs = glob( - include = ["**/*"], - allow_empty = True, + include = ["*.js"], ), visibility = ["//visibility:public"], )