-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Windows,client: extract embedded binaries faster #5448
Conversation
src/main/cpp/blaze.cc
Outdated
if (!blaze_util::MakeDirectories(blaze_util::Dirname(path), 0777)) { | ||
BAZEL_DIE(blaze_exit_code::INTERNAL_ERROR) | ||
<< "couldn't create '" << path << "': " << GetLastErrorString(); | ||
if (created_directories_.insert(path).second) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not obvious why this is here, I would add a comment here explaining that you do this to prevent duplicate work for performance reasons. Otherwise, I could imagine someone accidentally removing this without testing the performance implications.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
src/test/cpp/util/file_test.cc
Outdated
ASSERT_TRUE(mtime.get()->GetIfInDistantFuture(tempdir, &actual)); | ||
ASSERT_FALSE(actual); | ||
|
||
// Assert that a directory is always a good embedded embedded binary. (We do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
embedded embedded
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
src/main/cpp/util/file_platform.h
Outdated
// embedded binary that Bazel extracted from a previous run and it hasn't | ||
// been tampered with (its mtime is unchanged), or it's a directory. | ||
// Returns false otherwise, or if querying the information failed. | ||
virtual bool IsValidEmbeddedBinary(const std::string &path) = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I hear you on not wanting to move this to blaze_util_platform. Maybe you can make this name more general then, though? IsUntamperedFile() keeps it more neutral.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that idea! Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also added a TODO with my own name to move the function.
@@ -34,6 +34,9 @@ | |||
#error("This test should only be run on Windows") | |||
#endif // !defined(_WIN32) && !defined(__CYGWIN__) | |||
|
|||
#define _T(x) #x |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two macros look quite odd to me. I also don't see why you want to use LINE as a way to distinguish between targets. You could just give a random number, no? Is there any point to use the line number from the file?
If you do need this, I don't think you need to split it into two definitions, the single one should be enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also don't see why you want to use __LINE__ as a way to distinguish between targets.
Because it is guaranteed to be unique among all other tests. For a while there was no cleanup code that deleted temp files that tests created. Now there is, at least in some tests (the test framework won't do it automatically), but I still use this practice to avoid tests clobbering each other's files.
If you do need this, I don't think you need to split it into two definitions, the single one should be enough.
Indeed! Done.
When extracting embedded binaries, the client now caches which directories it has already created and won't attempt creating them again. This saves some time on Windows: from 16.3 sec on average down to 13.2 sec. (n=10 runs, always starting Bazel with a new --output_user_root and shutting down afterwards.) On Linux I see only a marginal speedup, not significant enough to claim credit for it. :) See bazelbuild#5444
bee1005
to
1fe97d6
Compare
I addressed all comments, rebased this PR on top of Sorry for the confusion and for the confusing-looking commit history. Now it should look cleaner. |
Add a simple profiler that can measure function call counts and durations, and report statistics by printing to stdout. Motivation: I recently needed a profiler for PR bazelbuild#5445 and PR bazelbuild#5448, so I'm adding the polished code now. Usage: 1. depend on //src/main/cpp/util:profiler 2. use PrintingStopWatch, PrintingStats, and ScopeProfiler objects, as shown in profiler.h's class documentation See bazelbuild#5444 Change-Id: I43f0afd124b486c694f451e8455a66ffca8137b6
Add a simple profiler that can measure function call counts and durations, and report statistics by printing to stdout. Motivation: I recently needed a profiler for PR bazelbuild#5445 and PR bazelbuild#5448, so I'm adding the polished code now. Usage: 1. depend on //src/main/cpp/util:profiler 2. use PrintingStopWatch, PrintingStats, and ScopeProfiler objects, as shown in profiler.h's class documentation See bazelbuild#5444 Change-Id: I43f0afd124b486c694f451e8455a66ffca8137b6
Add a simple profiler that can measure function call counts and durations, and report statistics by printing to stdout. Motivation: I recently needed a profiler for PR bazelbuild#5445 and PR bazelbuild#5448, so I'm adding the polished code now. Usage: 1. depend on //src/main/cpp/util:profiler 2. use PrintingStopWatch, PrintingStats, and ScopeProfiler objects, as shown in profiler.h's class documentation See bazelbuild#5444 Change-Id: I43f0afd124b486c694f451e8455a66ffca8137b6
Add a simple profiler that can measure function call counts and durations, and report statistics by printing to stdout. Motivation: I recently needed a profiler for PR bazelbuild#5445 and PR bazelbuild#5448, so I'm adding the polished code now. Usage: 1. depend on //src/main/cpp/util:profiler 2. use PrintingStopWatch, PrintingStats, and ScopeProfiler objects, as shown in profiler.h's class documentation See bazelbuild#5444 Change-Id: I43f0afd124b486c694f451e8455a66ffca8137b6
Add a simple profiler that can measure function call counts and durations, and report statistics by printing to stdout. Motivation: I recently needed a profiler for PR bazelbuild#5445 and PR bazelbuild#5448, so I'm adding the polished code now. Usage: 1. depend on //src/main/cpp/util:profiler 2. use StopWatch, Task, and ScopedTask objects as shown in profiler.h's class documentation See bazelbuild#5444 Change-Id: I43f0afd124b486c694f451e8455a66ffca8137b6
Add a simple profiler that can measure function call counts and durations, and report statistics by printing to stdout. Motivation: I recently needed a profiler for PR bazelbuild#5445 and PR bazelbuild#5448, so I'm adding the polished code now. Usage: 1. depend on //src/main/cpp/util:profiler 2. use StopWatch, Task, and ScopedTask objects as shown in profiler.h's class documentation See bazelbuild#5444 Change-Id: I43f0afd124b486c694f451e8455a66ffca8137b6
Add a simple profiler that can measure function call counts and durations, and report statistics by printing to stdout. Motivation: I recently needed a profiler for PR bazelbuild#5445 and PR bazelbuild#5448, so I'm adding the polished code now. Usage: 1. depend on //src/main/cpp/util:profiler 2. use StopWatch, Task, and ScopedTask objects as shown in profiler.h's class documentation See bazelbuild#5444 Change-Id: I43f0afd124b486c694f451e8455a66ffca8137b6
Add a simple profiler that can measure function call counts and durations, and report statistics by printing to stdout. Motivation: I recently needed a profiler for PR bazelbuild#5445 and PR bazelbuild#5448, so I'm adding the polished code now. Usage: 1. depend on //src/main/cpp/util:profiler 2. use StopWatch, Task, and ScopedTask objects as shown in profiler.h's class documentation See bazelbuild#5444 Change-Id: I43f0afd124b486c694f451e8455a66ffca8137b6
Add a simple profiler that can measure function call counts and durations, and report statistics by printing to stdout. Motivation: I recently needed a profiler for PR bazelbuild#5445 and PR bazelbuild#5448, so I'm adding the polished code now. Usage: 1. depend on //src/main/cpp/util:profiler 2. use StopWatch, Task, and ScopedTask objects as shown in profiler.h's class documentation See bazelbuild#5444 Change-Id: I43f0afd124b486c694f451e8455a66ffca8137b6
Add a simple profiler that can measure function call counts and durations, and report statistics by printing to stdout. Motivation: I recently needed a profiler for PR bazelbuild#5445 and PR bazelbuild#5448, so I'm adding the polished code now. Usage: 1. depend on //src/main/cpp/util:profiler 2. use StopWatch, Task, and ScopedTask objects as shown in profiler.h's class documentation See bazelbuild#5444 Change-Id: I43f0afd124b486c694f451e8455a66ffca8137b6
Add a simple profiler that can measure function call counts and durations, and report statistics by printing to stderr. Motivation: I recently needed a profiler for PR #5445 and PR #5448, so I'm adding the polished code now. Usage: 1. depend on //src/main/cpp/util:profiler 2. use StopWatch, Task, and ScopedTask objects as shown in profiler.h's class documentation See #5444 Change-Id: I43f0afd124b486c694f451e8455a66ffca8137b6 Closes #5461. Change-Id: I43f0afd124b486c694f451e8455a66ffca8137b6 PiperOrigin-RevId: 202314319
When extracting embedded binaries, the client now caches which directories it has already created and won't attempt creating them again. This saves some time on Windows: from 16.3 sec on average down to 13.2 sec. (n=10 runs, always starting Bazel with a new --output_user_root and shutting down afterwards.) On Linux I see only a marginal speedup, not significant enough to claim credit for it. :) See bazelbuild#5444 Closes bazelbuild#5448. PiperOrigin-RevId: 201933181
Add a simple profiler that can measure function call counts and durations, and report statistics by printing to stderr. Motivation: I recently needed a profiler for PR bazelbuild#5445 and PR bazelbuild#5448, so I'm adding the polished code now. Usage: 1. depend on //src/main/cpp/util:profiler 2. use StopWatch, Task, and ScopedTask objects as shown in profiler.h's class documentation See bazelbuild#5444 Change-Id: I43f0afd124b486c694f451e8455a66ffca8137b6 Closes bazelbuild#5461. Change-Id: I43f0afd124b486c694f451e8455a66ffca8137b6 PiperOrigin-RevId: 202314319
When extracting embedded binaries, the client now
caches which directories it has already created
and won't attempt creating them again.
This saves some time on Windows: from 16.3 sec on
average down to 13.2 sec. (n=10 runs, always
starting Bazel with a new --output_user_root and
shutting down afterwards.)
On Linux I see only a marginal speedup, not
significant enough to claim credit for it. :)
See #5444