Skip to content

Commit

Permalink
Bazel,client: actually cache directory creations
Browse files Browse the repository at this point in the history
Commit f5043d6
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 #5444

Change-Id: I314bdc9337c9782a5ceaed7aac785a552b222b1f

Closes #5484.

Change-Id: I314bdc9337c9782a5ceaed7aac785a552b222b1f
PiperOrigin-RevId: 202314400
  • Loading branch information
laszlocsomor authored and Copybara-Service committed Jun 27, 2018
1 parent c2beee1 commit 49eaa8f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main/cpp/blaze.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit 49eaa8f

Please sign in to comment.