bzl: tune //client/web:test to run faster (#49897)

After a lot of trial and error, we found out that the following things
dramatically improved the duration of the `//client/web:test` duration.

Before: 600s 
After: 90s

- we fixed affinity issues that were scheduling stateless agents on the
bazel nodes and thus were affecting resources
- we set the `patch_node_fs` to false, because it's known to affect
speed (this dropped about 100s)
- we disable the sandbox for that particular test, because when
disabling the above setting, it doesn't really make sense as the fs can
escape the sandbox anyway.
- we use sharding, which dramatically improve the speed. We came up with
6 empirically.
- this required bumping the `rules_jest` dep to the latest commit which
fixes another bug preventing to use `shard_count` when running the
snapshots as well.

## Test plan

<!-- All pull requests REQUIRE a test plan:
https://docs.sourcegraph.com/dev/background-information/testing_principles
-->

See:
https://buildkite.com/sourcegraph/sourcegraph/builds/209604#01870e10-8639-445a-828b-3e79de22ac81/33-562

## App preview:

- [Web](https://sg-web-jh-bzl-bench-webtest.onrender.com/search)

Check out the [client app preview
documentation](https://docs.sourcegraph.com/dev/how-to/client_pr_previews)
to learn more.
This commit is contained in:
Jean-Hadrien Chabran 2023-03-23 12:18:10 +01:00 committed by GitHub
parent ecc63961b5
commit 0372a11e2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 4 deletions

View File

@ -36,9 +36,9 @@ http_archive(
http_archive(
name = "aspect_rules_jest",
sha256 = "11f6685db09c54d401e084ab588b2dbc77913627bb3cde98576fa4c1be183853",
strip_prefix = "rules_jest-e78c8113b83436973e53384e5339f994d1103959",
url = "https://github.com/aspect-build/rules_jest/archive/e78c8113b83436973e53384e5339f994d1103959.tar.gz",
sha256 = "bf8f4a4d2a833e4f96f866c686c38bcee69d3bdae8a827b1c9d2fdf92212bc0b",
strip_prefix = "rules_jest-95d8f1961a9c6f3aee2929881b1b74461652e775",
url = "https://github.com/aspect-build/rules_jest/archive/95d8f1961a9c6f3aee2929881b1b74461652e775.tar.gz"
)
http_archive(

11
client/web/BUILD.bazel generated
View File

@ -1216,6 +1216,8 @@ ts_project(
"src/repo/components/RepoHeaderActions/index.ts",
"src/repo/components/RepoRevision/RepoRevision.tsx",
"src/repo/components/RepoRevision/index.ts",
"src/repo/linkifiy/Linkified.tsx",
"src/repo/linkifiy/get-links.ts",
"src/repo/packages/isPackageServiceType.ts",
"src/repo/releases/RepositoryReleasesArea.tsx",
"src/repo/releases/RepositoryReleasesTagsPage.tsx",
@ -1646,6 +1648,7 @@ ts_project(
"//:node_modules/js-yaml",
"//:node_modules/jsonc-parser",
"//:node_modules/linguist-languages",
"//:node_modules/linkifyjs",
"//:node_modules/lodash",
"//:node_modules/lru-cache",
"//:node_modules/marked",
@ -1767,6 +1770,7 @@ ts_project(
"src/repo/blob/codemirror/utils.test.ts",
"src/repo/commit/CommitMessageWithLinks.test.tsx",
"src/repo/commits/GitCommitNodeByline.test.tsx",
"src/repo/linkifiy/get-links.test.ts",
"src/repo/releases/RepositoryReleasesTagsPage.test.tsx",
"src/search/Notepad.test.tsx",
"src/search/helpers.test.tsx",
@ -1848,10 +1852,15 @@ npm_package(
jest_test(
name = "test",
size = "enormous", # make sure bazel reserves enough RAM for this.
timeout = "long",
timeout = "moderate",
data = [
":web_tests",
],
patch_node_fs = False,
shard_count = 6, # this is has a large impact on the duration. We came to this number empirically.
tags = [
"no-sandbox", # we are disabling the patch_node_fs, so the sandbox isn't really useful anymore.
],
)
# webpack dev environment -------------------

View File

@ -3,6 +3,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "repo",
srcs = [
"document_ranks.go",
"handler.go",
"janitor.go",
"worker.go",
@ -18,10 +19,13 @@ go_library(
"//enterprise/internal/embeddings/embed",
"//enterprise/internal/embeddings/split",
"//internal/actor",
"//internal/api/internalapi",
"//internal/codeintel/types",
"//internal/conf",
"//internal/env",
"//internal/gitserver",
"//internal/goroutine",
"//internal/httpcli",
"//internal/observation",
"//internal/uploadstore",
"//internal/workerutil",

View File

@ -14,6 +14,7 @@ go_library(
"//enterprise/internal/embeddings/split",
"//internal/api",
"//internal/binary",
"//internal/codeintel/types",
"//internal/conf",
"//internal/httpcli",
"//lib/errors",
@ -29,6 +30,7 @@ go_test(
deps = [
"//enterprise/internal/embeddings/split",
"//internal/api",
"//internal/codeintel/types",
"//lib/errors",
"@com_github_stretchr_testify//require",
],