-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bazel: low cache utilization between builds and tests #71857
Comments
Unfortunately the build and tests are compiled with disjoint |
We could add some |
I've been playing with this locally recently and I think explicitly setting |
I guess I would expect that Bazel would keep separate caches for each configuration of the gotags, is that not how things work? |
A slack thread about the bazel in-use space here. |
Using an explicit --disk_cache seems to have helped in that build artifacts for |
Instead of using a build tag (which necessarily generates non-shareable artifacts), I wonder if we can get away with using an init time envvar check instead. Downside: we'd have to compile test-only code for regular builds (will it be much slower?). Upside: we'd be able to re-use artifacts across |
In a couple different places in-tree we use the build tags `crdb_test` and `crdb_test_off` to support conditional compilation. Unfortunately, this results in low cache utilization when swapping between builds and tests, since recompiling with different `gotags` causes Bazel to recompile EVERYTHING, including the entire standard library, with these different tags. This means that you can't build `cockroach` and then run a quick test using cached build artifacts, for example. Fix this by adding a new configuration, `//build/toolchains:crdb_test`. We use `x_defs` in `pkg/util/BUILD.bazel` to pass in a different string to the linker in test scenarios and set `CrdbTestBuild` accordingly. For the remaining few files that directly use `crdb_test` as a build constraint in `pkg/sql/opt`, we just directly port the conditional compilation logic to Bazel using `select`. When the changeover to Bazel is finalized, we can omit the build constraints entirely in the source files. Also add logic to `build/bazelutil/check.sh` to detect new uses of these build constraints and warn people that the logic also needs to be Bazelfied. Closes cockroachdb#71857. Release note: None
In a couple different places in-tree we use the build tags `crdb_test` and `crdb_test_off` to support conditional compilation. Unfortunately, this results in low cache utilization when swapping between builds and tests, since recompiling with different `gotags` causes Bazel to recompile EVERYTHING, including the entire standard library, with these different tags. This means that you can't build `cockroach` and then run a quick test using cached build artifacts, for example. Fix this by adding a new configuration, `//build/toolchains:crdb_test`. We use `x_defs` in `pkg/util/BUILD.bazel` to pass in a different string to the linker in test scenarios and set `CrdbTestBuild` accordingly. For the remaining few files that directly use `crdb_test` as a build constraint in `pkg/sql/opt`, we just directly port the conditional compilation logic to Bazel using `select`. When the changeover to Bazel is finalized, we can omit the build constraints entirely in the source files. Also add logic to `build/bazelutil/check.sh` to detect new uses of these build constraints and warn people that the logic also needs to be Bazelfied. Closes cockroachdb#71857. Release note: None
In a couple different places in-tree we use the build tags `crdb_test` and `crdb_test_off` to support conditional compilation. Unfortunately, this results in low cache utilization when swapping between builds and tests, since recompiling with different `gotags` causes Bazel to recompile EVERYTHING, including the entire standard library, with these different tags. This means that you can't build `cockroach` and then run a quick test using cached build artifacts, for example. Fix this by adding a new configuration, `//build/toolchains:crdb_test`. We use `select()` in `pkg/util/buildutil/BUILD.bazel` to choose between `crdb_test_on.go` and `crdb_test_off.go` accordingly. Also add logic to `build/bazelutil/check.sh` to detect new uses of these build constraints and warn people that the logic also needs to be Bazelfied. Closes cockroachdb#71857. Release note: None
In a couple different places in-tree we use the build tags `crdb_test` and `crdb_test_off` to support conditional compilation. Unfortunately, this results in low cache utilization when swapping between builds and tests, since recompiling with different `gotags` causes Bazel to recompile EVERYTHING, including the entire standard library, with these different tags. This means that you can't build `cockroach` and then run a quick test using cached build artifacts, for example. Fix this by adding a new configuration, `//build/toolchains:crdb_test`. We use `select()` in `pkg/util/buildutil/BUILD.bazel` to choose between `crdb_test_on.go` and `crdb_test_off.go` accordingly. Also add logic to `build/bazelutil/check.sh` to detect new uses of these build constraints and warn people that the logic also needs to be Bazelfied. Closes cockroachdb#71857. Release note: None
In a couple different places in-tree we use the build tags `crdb_test` and `crdb_test_off` to support conditional compilation. Unfortunately, this results in low cache utilization when swapping between builds and tests, since recompiling with different `gotags` causes Bazel to recompile EVERYTHING, including the entire standard library, with these different tags. This means that you can't build `cockroach` and then run a quick test using cached build artifacts, for example. Fix this by adding a new configuration, `//build/toolchains:crdb_test`. We use `select()` in `pkg/util/buildutil/BUILD.bazel` to choose between `crdb_test_on.go` and `crdb_test_off.go` accordingly. Also add logic to `build/bazelutil/check.sh` to detect new uses of these build constraints and warn people that the logic also needs to be Bazelfied. Closes cockroachdb#71857. Release note: None
In a couple different places in-tree we use the build tags `crdb_test` and `crdb_test_off` to support conditional compilation. Unfortunately, this results in low cache utilization when swapping between builds and tests, since recompiling with different `gotags` causes Bazel to recompile EVERYTHING, including the entire standard library, with these different tags. This means that you can't build `cockroach` and then run a quick test using cached build artifacts, for example. Fix this by adding a new configuration, `//build/toolchains:crdb_test`. We use `select()` in `pkg/util/buildutil/BUILD.bazel` to choose between `crdb_test_on.go` and `crdb_test_off.go` accordingly. Also add logic to `build/bazelutil/check.sh` to detect new uses of these build constraints and warn people that the logic also needs to be Bazelfied. Closes cockroachdb#71857. Release note: None
72838: bazel: don't use different `gotags` for test and non-test scenarios r=RaduBerinde a=rickystewart In a couple different places in-tree we use the build tags `crdb_test` and `crdb_test_off` to support conditional compilation. Unfortunately, this results in low cache utilization when swapping between builds and tests, since recompiling with different `gotags` causes Bazel to recompile EVERYTHING, including the entire standard library, with these different tags. This means that you can't build `cockroach` and then run a quick test using cached build artifacts, for example. Fix this by adding a new configuration, `//build/toolchains:crdb_test`. We use `select()` in `pkg/util/buildutil/BUILD.bazel` to choose between `crdb_test_on.go` and `crdb_test_off.go` accordingly. Also add logic to `build/bazelutil/check.sh` to detect new uses of these build constraints and warn people that the logic also needs to be Bazelfied. Closes #71857. Release note: None 72882: ui: save sort on cache for Transaction page r=maryliag a=maryliag Previously, a sort selection was not maintained when the page change (e.g. coming back from Transaction details). This commits saves the selected value to be used. Partially adresses #68199 Release note: None 72915: build/README: add more info about how to authenticate for mirroring r=rail a=rickystewart Release note: None Co-authored-by: Ricky Stewart <[email protected]> Co-authored-by: Marylia Gutierrez <[email protected]>
Describe the problem
I'm observing that the build artifacts from a
{dev,bazel} build
are not being used by{dev,bazel} test
and vice-versa. When going from building the full cockroach-short binary to running a specific test, the build cache is trampled upon by each command with the results no longer usable by the other or by itself afterwards. This is surprising, is it because of the differing.bazelrc
configs between the two? Something else?To Reproduce
Some numbers from my machine, I'm seeing each step start the build from scratch(-ish) without achieving much cache utilization.
Here are two profiles (open using chrome://tracing), they show that we're pretty much starting from scratch each time.
Expected behavior
Build artifacts from a
dev build cockroach-short
should be re-usable for tests and vice-versa.Epic CRDB-8036
The text was updated successfully, but these errors were encountered: