Skip to content
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

Closed

Conversation

laszlocsomor
Copy link
Contributor

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

@laszlocsomor
Copy link
Contributor Author

laszlocsomor commented Jun 21, 2018

Based on #5447 -- enough to review the last commit (bee1005).

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) {
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

ASSERT_TRUE(mtime.get()->GetIfInDistantFuture(tempdir, &actual));
ASSERT_FALSE(actual);

// Assert that a directory is always a good embedded embedded binary. (We do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

embedded embedded

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

// 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;
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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
Copy link
Contributor

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.

Copy link
Contributor Author

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
@laszlocsomor
Copy link
Contributor Author

I addressed all comments, rebased this PR on top of master, and removed the diffbase (PR #5445) to make it cleaner.

Sorry for the confusion and for the confusing-looking commit history. Now it should look cleaner.

@bazel-io bazel-io closed this in f5043d6 Jun 25, 2018
laszlocsomor added a commit to laszlocsomor/bazel that referenced this pull request Jun 25, 2018
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
laszlocsomor added a commit to laszlocsomor/bazel that referenced this pull request Jun 25, 2018
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
laszlocsomor added a commit to laszlocsomor/bazel that referenced this pull request Jun 25, 2018
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
laszlocsomor added a commit to laszlocsomor/bazel that referenced this pull request Jun 26, 2018
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
laszlocsomor added a commit to laszlocsomor/bazel that referenced this pull request Jun 26, 2018
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
laszlocsomor added a commit to laszlocsomor/bazel that referenced this pull request Jun 26, 2018
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
laszlocsomor added a commit to laszlocsomor/bazel that referenced this pull request Jun 26, 2018
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
laszlocsomor added a commit to laszlocsomor/bazel that referenced this pull request Jun 27, 2018
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
laszlocsomor added a commit to laszlocsomor/bazel that referenced this pull request Jun 27, 2018
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
laszlocsomor added a commit to laszlocsomor/bazel that referenced this pull request Jun 27, 2018
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
@laszlocsomor laszlocsomor deleted the client-speedup-2 branch June 27, 2018 12:20
bazel-io pushed a commit that referenced this pull request Jun 27, 2018
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
werkt pushed a commit to werkt/bazel that referenced this pull request Aug 2, 2018
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
werkt pushed a commit to werkt/bazel that referenced this pull request Aug 2, 2018
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants