Call GetCanonicalPath only if needed to avoid FS overhead#494
Call GetCanonicalPath only if needed to avoid FS overhead#494thelvis4 wants to merge 3 commits intobazelbuild:mainfrom
Conversation
f037a38 to
3a26df6
Compare
|
this change makes sense but instead of using a static variable here can you pass it down how apple_support/crosstool/cc_toolchain_config.bzl Lines 1406 to 1436 in 9e5f2d5 |
3a26df6 to
112b30d
Compare
@keith updated the PR, please check if it's inline with what you had in mind |
After updating to apple_support 2.0.0, we noticed a significant (~40%) regression in compilation times.
For a large application (~45k clang compilations + few thousands swift module compilations), the overall build time increased from 38 min to 54 min.
The regression is rooted in changes in 2c64f60, where
GetCanonicalPathis called for each argument, regardless if the replacement is needed (ie when code coverage is enabled) or not.The overhead might vary, but it becomes significant and noticeable for compilation actions with lots of arguments.
This PR changes the logic for replacing
__BAZEL_EXECUTION_ROOT_CANONICAL__to avoid the overhead:coverage_prefix_map_absolute_sources_non_hermetic_private_featuresetsCOVERAGE_PREFIX_MAP_USE_ABSOLUTE_CWD_PATH=1envGetCanonicalPathis called only if the environment variable is set (ie if the feature is requested) and its value is assigned tocanonical_cwdcanonical_cwdis passed down as a parameter andProcessArgumentperforms the replacement if the parameter is non-empty