aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/cpp/blaze.cc
diff options
context:
space:
mode:
authorGravatar Laszlo Csomor <laszlocsomor@google.com>2018-06-25 01:10:26 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-06-25 01:12:27 -0700
commitda91730760ac9078183c236cb9ab95f38a5fd3b8 (patch)
treebc83357596371d3d3b284d5775492f806e38ffb3 /src/main/cpp/blaze.cc
parent88d1caeef07533429468515f63b3d4e2cb9a7a80 (diff)
Windows,Bazel client: check embedded tools faster
The Bazel client on Windows is now 50% faster to check the embedded tools than it was before. Results: - Linux: 20 ms -> 6 ms - Windows: 294 ms -> 133 ms Measurements were done with n=10 runs and a hot server, using blaze::GetMillisecondsMonotonic(). Previously the client performed the same tasks multiple times while trying to determine if a path was a good extracted binary. (E.g. converted the path to Windows format multiple times, checked if it was a directory twice, opened the path twice.) Now the client performes these tasks only once, e.g. it converts path once and stats only once. See https://github.com/bazelbuild/bazel/issues/5444 Closes #5445. PiperOrigin-RevId: 201913758
Diffstat (limited to 'src/main/cpp/blaze.cc')
-rw-r--r--src/main/cpp/blaze.cc28
1 files changed, 4 insertions, 24 deletions
diff --git a/src/main/cpp/blaze.cc b/src/main/cpp/blaze.cc
index a8987eb2b2..5073fe513c 100644
--- a/src/main/cpp/blaze.cc
+++ b/src/main/cpp/blaze.cc
@@ -1052,7 +1052,7 @@ static void ExtractData(const string &self_path) {
} else {
if (!blaze_util::IsDirectory(globals->options->install_base)) {
BAZEL_DIE(blaze_exit_code::LOCAL_ENVIRONMENTAL_ERROR)
- << "Install base directory '" << globals->options->install_base
+ << "install base directory '" << globals->options->install_base
<< "' could not be created. It exists but is not a directory.";
}
@@ -1062,31 +1062,11 @@ static void ExtractData(const string &self_path) {
globals->options->install_base, "_embedded_binaries");
for (const auto &it : globals->extracted_binaries) {
string path = blaze_util::JoinPath(real_install_dir, it);
- // Check that the file exists and is readable.
- if (blaze_util::IsDirectory(path)) {
- continue;
- }
- if (!blaze_util::CanReadFile(path)) {
+ if (!mtime->IsUntampered(path)) {
BAZEL_DIE(blaze_exit_code::LOCAL_ENVIRONMENTAL_ERROR)
<< "corrupt installation: file '" << path
- << "' missing. Please remove '" << globals->options->install_base
- << "' and try again.";
- }
- // Check that the timestamp is in the future. A past timestamp would
- // indicate that the file has been tampered with.
- // See ActuallyExtractData().
- bool is_in_future = false;
- if (!mtime.get()->GetIfInDistantFuture(path, &is_in_future)) {
- BAZEL_DIE(blaze_exit_code::LOCAL_ENVIRONMENTAL_ERROR)
- << "Error: could not retrieve mtime of file '" << path
- << "'. Please remove '" << globals->options->install_base
- << "' and try again.";
- }
- if (!is_in_future) {
- BAZEL_DIE(blaze_exit_code::LOCAL_ENVIRONMENTAL_ERROR)
- << "Error: corrupt installation: file '" << path
- << "' modified. Please remove '" << globals->options->install_base
- << "' and try again.";
+ << "' is missing or modified. Please remove '"
+ << globals->options->install_base << "' and try again.";
}
}
}