Skip to content
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

Speed up build by avoiding build config duplication #753

Merged
merged 1 commit into from
Jun 15, 2023

Conversation

fhanau
Copy link
Collaborator

@fhanau fhanau commented Jun 8, 2023

Compile substantially all of workerd in the bazel 'target' configuration
instead of 'exec', which allows us to avoid compiling major components
twice.
This should offer a large performance improvement, especially when
rebuilding after a V8 update or building all targets and drive down the
worst-case CI build time significantly.
Bazel supports an exec configuration for building code that needs to run
on the host machine during the build, e.g. tools used to generate source
files or type definitions. When not cross-compiling exec and target will
be the same, but bazel does not offer a flag to use just one configuration
when the configurations are identical (bazelbuild/bazel#14848),
making manual changes necessary.
Bazel appears to offer no way to detect if exec and host are the same, so
this feature is implemented through an opt-in command line flag enabled in
.bazelrc, which makes it possible to easily disable the change when
cross-compilation support is needed.

Some of the V8 changes are extensive; fortunately they largely affect bazel code and not the list of source files, which is expected to change infrequently. I will try to upstream at least the torque-related changes.

Note: This does not affect the upstream build, no upstream PR is needed.

@fhanau fhanau force-pushed the felix/bazel-cfg-speedup branch 2 times, most recently from ac29e67 to f048183 Compare June 11, 2023 17:22
build/i-love-bazel.bzl Outdated Show resolved Hide resolved
@fhanau fhanau changed the title [PoC] Speed up build by avoiding build config duplication Speed up build by avoiding build config duplication Jun 13, 2023
@fhanau fhanau force-pushed the felix/bazel-cfg-speedup branch 6 times, most recently from 80aef6d to feed276 Compare June 14, 2023 22:22
@fhanau fhanau marked this pull request as ready for review June 14, 2023 23:04
+ },
+)
--
2.39.2 (Apple Git-143)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JFYI, the v8-updates.md doc suggests using "git format-patch --full-index -k --no-signature".

Copy link
Contributor

@ohodson ohodson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Felix, I feel I've missed this PR transitioning from draft to ready so apologies if you've been held up.

From experience of updating V8 in workerd, the top-level BUILD.bazel is one of the places that takes time to deal with. So additional changes there come with some mild concerns, but we'll figure it out.

Compile substantially all of workerd in the bazel 'target' configuration
instead of 'exec', which allows us to avoid compiling major components
twice.
This should offer a large performance improvement, especially when
rebuilding after a V8 update or building all targets and drive down the
worst-case CI build time significantly.
Bazel supports an exec configuration for building code that needs to run
on the host machine during the build, e.g. tools used to generate source
files or type definitions. When not cross-compiling exec and target will
be the same, but bazel does not offer a flag to use just one configuration
when the configurations are identical (bazelbuild/bazel#14848),
making manual changes necessary.
Bazel makes it very difficult to set the config for a target at build
time, so default to using cfg "target" globally for now.
@fhanau fhanau force-pushed the felix/bazel-cfg-speedup branch from feed276 to e4dda9a Compare June 15, 2023 19:43
@fhanau fhanau merged commit 9a3a102 into main Jun 15, 2023
@fhanau fhanau deleted the felix/bazel-cfg-speedup branch June 15, 2023 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants