diff options
author | Laszlo Csomor <laszlocsomor@google.com> | 2018-06-27 08:37:49 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-06-27 08:40:22 -0700 |
commit | 49eaa8f01065ee12e4726d818e24a8c594878e10 (patch) | |
tree | bfcdb2749c3889880b43b8dac125f050c5ee7043 /src/main/cpp | |
parent | c2beee142c75cf74e6aec51b3ce80a893b25995b (diff) |
Bazel,client: actually cache directory creations
Commit https://github.com/bazelbuild/bazel/commit/f5043d6831ea1c266104363b4e8911eb97f96fbc
was incorrect in that it cached the file names,
not the directory names.
This commit fixes that. I verified that the number
of calls to ExtractBlazeZipProcessor::Process is
greater than the calls to MakeDirectories within
(1038 vs. 172 on Linux).
See https://github.com/bazelbuild/bazel/issues/5444
Change-Id: I314bdc9337c9782a5ceaed7aac785a552b222b1f
Closes #5484.
Change-Id: I314bdc9337c9782a5ceaed7aac785a552b222b1f
PiperOrigin-RevId: 202314400
Diffstat (limited to 'src/main/cpp')
-rw-r--r-- | src/main/cpp/blaze.cc | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/main/cpp/blaze.cc b/src/main/cpp/blaze.cc index eb72cb5263..d4393e2165 100644 --- a/src/main/cpp/blaze.cc +++ b/src/main/cpp/blaze.cc @@ -893,12 +893,13 @@ class ExtractBlazeZipProcessor : public PureZipExtractorProcessor { void Process(const char *filename, const devtools_ijar::u4 attr, const devtools_ijar::u1 *data, const size_t size) override { string path = blaze_util::JoinPath(embedded_binaries_, filename); + string dirname = blaze_util::Dirname(path); // Performance optimization: memoize the paths we already created a // directory for, to spare a stat in attempting to recreate an already // existing directory. This optimization alone shaves off seconds from the // extraction time on Windows. - if (created_directories_.insert(path).second) { - if (!blaze_util::MakeDirectories(blaze_util::Dirname(path), 0777)) { + if (created_directories_.insert(dirname).second) { + if (!blaze_util::MakeDirectories(dirname, 0777)) { BAZEL_DIE(blaze_exit_code::INTERNAL_ERROR) << "couldn't create '" << path << "': " << GetLastErrorString(); } |