Description of the bug:
We have had a curious regression in compile speed for the last 3 weeks. Whilst previously our compiles loaded 40 local cpus to 100%, after the regression cpus were only working at ~25% and compile times increased by 5x (3h to 15h)
I have spent ages trying to figure this out. Tried multiple windows machines, msvc and clang-cl, profiled the build, tested the filesystem, tried a ramdisk, multiple bazel versions...
I've finally narrowed it down to a reproducible example. It happened when I converted all our C++ external repos from workspace to module via use_repo_rule. I think it may be due to the tilde's (~) in the include paths. Perhaps it's an MSVC bug, but it also impacts clang-cl builds which is curious. When I run the Maybe it is a windows bug?
I can't share the code, but can share what we changed and the performance characteristics. This is a tiny example of low level code so only shows a 40% degradation. With 50 repos in lower level code the impact is much larger.
With workspace repo (30s)

The flat peak is the time when the compiles are all happening and cpus are loaded 100%
With one repo defined with use_repo_rule in MODULE.bazel (44s):

The CPUs never load at 100%
Build file, same in before and after:
cc_import(
name = "OurTools",
interface_library = "ourtools.lib",
shared_library = "ourtools.dll",
deps = [
":headers",
],
)
cc_library(
name = "headers",
hdrs = glob([
"include/**/*.h",
"include/**/*.hpp",
"include/**/*.c"]),
includes = [
"include",
"include/sub1/common",
"include/sub2/include"],
)
Before: OurTools declared with a rule that calls download_and_extract in WORKSPACE
load("@our_toolchain//:tools/artifact_rules.bzl", "our_artifact_with_plat")
def define_OurTools_repo():
our_artifact_with_plat(
name = "OurTools",
version = "2.1.0",
build_file = "//src/repo/bazel/toolbox/build_files/wntx64:OurTools_BUILD.bazel",
sha256 = "021fb717579ec6c3cc2f9eb8bacd8285801ac116e827ca7f430c0960fd0a2378",
)
After: this is in MODULE.bazel:
our_artifact_with_plat = use_repo_rule("@our_toolchain//:tools/artifact_rules.bzl", "our_artifact_with_plat")
our_artifact_with_plat(
name = "OurTools",
version = "2.1.0",
build_file = "//src/repo/bazel/toolbox/build_files/wntx64:OurTools_BUILD.bazel",
sha256 = "021fb717579ec6c3cc2f9eb8bacd8285801ac116e827ca7f430c0960fd0a2378",
)
The reason this may cause a compile time difference is the include path. We use params files, the relevant differences are:
Workspace
/Iexternal/OurTools
/Ibazel-out/x64_windows-opt/bin/external/OurTools
/Iexternal/OurTools/include
/Ibazel-out/x64_windows-opt/bin/external/OurTools/include
/Iexternal/OurTools/include/icu/common
/Ibazel-out/x64_windows-opt/bin/external/OurTools/include/sub1/common
/Iexternal/OurTools/include/xalanc/include
/Ibazel-out/x64_windows-opt/bin/external/OurTools/include/sub2/include
Module & use_repo_rule:
/Iexternal/_main~_repo_rules~OurTools
/Ibazel-out/x64_windows-opt/bin/external/_main~_repo_rules~OurTools
/Iexternal/_main~_repo_rules~OurTools/include
/Ibazel-out/x64_windows-opt/bin/external/_main~_repo_rules~OurTools/include
/Iexternal/_main~_repo_rules~OurTools/include/icu/common
/Ibazel-out/x64_windows-opt/bin/external/_main~_repo_rules~OurTools/include/sub1/common
/Iexternal/_main~_repo_rules~OurTools/include/xalanc/include
/Ibazel-out/x64_windows-opt/bin/external/_main~_repo_rules~OurTools/include/sub2/include
Which category does this issue belong to?
C++ Rules, External Dependency
What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
I can't share my reproducer as it is proprietary.
Which operating system are you running Bazel on?
Windows 10
What is the output of bazel info release?
7.2.0
If bazel info release returns development version or (@non-git), tell us how you built Bazel.
No response
What's the output of git remote get-url origin; git rev-parse HEAD ?
No response
If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.
This is not a regression
Have you found anything relevant by searching the web?
No response
Any other information, logs, or outputs that you want to share?
No response
Description of the bug:
We have had a curious regression in compile speed for the last 3 weeks. Whilst previously our compiles loaded 40 local cpus to 100%, after the regression cpus were only working at ~25% and compile times increased by 5x (3h to 15h)
I have spent ages trying to figure this out. Tried multiple windows machines, msvc and clang-cl, profiled the build, tested the filesystem, tried a ramdisk, multiple bazel versions...
I've finally narrowed it down to a reproducible example. It happened when I converted all our C++ external repos from workspace to module via use_repo_rule. I think it may be due to the tilde's (~) in the include paths. Perhaps it's an MSVC bug, but it also impacts clang-cl builds which is curious. When I run the Maybe it is a windows bug?
I can't share the code, but can share what we changed and the performance characteristics. This is a tiny example of low level code so only shows a 40% degradation. With 50 repos in lower level code the impact is much larger.
With workspace repo (30s)

The flat peak is the time when the compiles are all happening and cpus are loaded 100%
With one repo defined with use_repo_rule in MODULE.bazel (44s):

The CPUs never load at 100%
Build file, same in before and after:
Before: OurTools declared with a rule that calls download_and_extract in WORKSPACE
After: this is in MODULE.bazel:
The reason this may cause a compile time difference is the include path. We use params files, the relevant differences are:
Workspace
Module & use_repo_rule:
Which category does this issue belong to?
C++ Rules, External Dependency
What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
I can't share my reproducer as it is proprietary.
Which operating system are you running Bazel on?
Windows 10
What is the output of
bazel info release?7.2.0
If
bazel info releasereturnsdevelopment versionor(@non-git), tell us how you built Bazel.No response
What's the output of
git remote get-url origin; git rev-parse HEAD?No response
If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.
This is not a regression
Have you found anything relevant by searching the web?
No response
Any other information, logs, or outputs that you want to share?
No response