-
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
Add --async clean independent of expunge #2053
Conversation
Can one of the admins verify this patch? |
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
@@ -191,6 +227,7 @@ private void actuallyClean(CommandEnvironment env, | |||
if (cleanOptions.expunge || cleanOptions.expunge_async) { | |||
throw new ShutdownBlazeServerException(0, ShutdownMethod.EXPUNGE); | |||
} | |||
System.gc(); |
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.
Why gc here?
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.
We noted specifically that workspace.clearCaches() removed nearly all object utilization, and that a gc invocation was definitive in demonstrating that nearly all of bazel's (vm) persistent heap usage was tied up in the cache. Meaningless in the expunge case, it was just an opportunity to show it had nothing else up its sleeves. I'm fine with removing it, it just felt right.
LOG.finest("Cleaning " + child); | ||
FileSystemUtils.deleteTreesBelow(child); | ||
if (cleanOptions.async) { | ||
LOG.finest("Cleaning " + child + " asynchronously..."); |
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.
Can we factor this so we do not have code duplication
"Starting clean." : | ||
"Starting clean (this may take a while). " + | ||
"Consider using --expunge_async if the clean takes more than several minutes."; | ||
"Consider using --async if the clean takes more than several minutes."; |
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.
That will be wrong if the person use --expunge right?
@@ -109,10 +121,10 @@ public ExitCode exec(CommandEnvironment env, OptionsProvider options) | |||
cleanOptions.cleanStyle = "expunge"; | |||
} | |||
|
|||
String cleanBanner = cleanOptions.expunge_async ? | |||
String cleanBanner = (cleanOptions.expunge_async || cleanOptions.async) ? |
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.
You also want to duplicate the logic at line 116 to avoid doing async clean on platforms that does not support it.
@werkt Can you sign the CLA or if signed with a corporate CLA signal us? Sorry for having taken so long to look at this PR. |
Jenkins test this please |
I'm on the corporate CLA - ggensure@uberatc.com (just added as verified email on here), signed and membered of open source group under Uber. |
Ok thank you for updating your PR. I did another quick pass and I think the PR is good to go but I will be OOO for the rest of the week so reassigning to @ulfjack so a more throughful review can be done. Again, I would like to apologize in the name of the whole team for taking so long to look at your change. |
|
||
// Doesn't throw iff command exited and was successful. | ||
new CommandBuilder().addArg(command).useShell(true) | ||
.setWorkingDir(tempPath.getParentDirectory()) |
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.
style: this should be four spaces indentation
defaultValue = "false", | ||
category = "clean", | ||
expansion = "--clean_style=async", | ||
help = "If specified, clean will asynchronously remove the entire working tree for " |
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 would use present tense here:
"If specified, %product% asynchronously removes the entire working tree ..."
I realize that the other doc doesn't do that right now, and I think those should be changed as well.
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 think the change is reasonable. I'm wondering if we should clean async by default instead, but I'm ok with merging this without having that discussion.
@@ -132,6 +150,30 @@ public ExitCode exec(CommandEnvironment env, OptionsProvider options) | |||
} | |||
} | |||
|
|||
private void asyncClean(CommandEnvironment env, |
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.
Can you make this method static?
FileSystemUtils.deleteTreesBelow(child); | ||
LOG.finest("Cleaning " + child + (cleanOptions.async ? " asynchronously..." : "")); | ||
if (cleanOptions.async) { | ||
asyncClean(env, child, "Child"); |
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.
Can you make the string a bit more descriptive? Lukacs suggested 'workspace_root'.
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'm happy to augment this string, but I'm not sure where you're trying to get to here (or specifically how 'workspace_root' fits in). Mind commenting with an example, or giving me a pointer to one of these?
Per directory:
Cleaning [workspace|build|output] directory < asynchronously... if async>
Once for all directories:
Cleaning [workspace|build|output] director{y/ies}< asynchronously... if async>
tbh the inclusion of 'workspace' or 'workspace_root' in the output here for some may indicate that their actual source workspace is in jeopardy, though perhaps not anyone who expects something reasonable out of a build system.
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. How about "Output tree"? In the expunge case, we write "Output base", which also includes a bunch of other things. I suppose the distinction is a bit subtle, but I don't see any good way to explain it with two words.
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.
Thanks for addressing the previous comments. There are two more small things that we discovered in the import process.
@ulfjack : Is there a comment for those issues, or is anyone addressing them right now? Context: I'm sheriff today and am trying to assess the status of this PR. |
An asynchronous clean without a complete purge and daemon shutdown is particularly useful when the daemon takes an inordinate amount of time to read output files for md5sums. Incurs a garbage collector invocation after cache cleanup in the interest of correct usage reporting.
Thanks! Importing. |
@iirina : FYI, I can handle importing this PR |
An asynchronous clean without a complete purge and daemon shutdown is particularly useful when the daemon takes an inordinate amount of time to read output files for md5sums. Incurs a garbage collector invocation after cache cleanup in the interest of correct usage reporting. Closes bazelbuild#2053. -- Reviewed-on: bazelbuild#2053 PiperOrigin-RevId: 141437418 MOS_MIGRATED_REVID=141437418
Basically a refactor of #2053, which separated the concepts of async and expunge but kept them intertwined at the option level. This was confusing to a number of users. The standard interface is to use one of --expunge, --async, or --expunge_async. --clean_style was more verbose and added no value, so can be removed. The contents of actuallyClean() could use some ... actual cleaning. This CL just changes the options, removing some of the artificial option-related complexity. RELNOTES[INC]: --clean_style is no longer an option. PiperOrigin-RevId: 177843049
Basically a refactor of bazelbuild/bazel#2053, which separated the concepts of async and expunge but kept them intertwined at the option level. This was confusing to a number of users. The standard interface is to use one of --expunge, --async, or --expunge_async. --clean_style was more verbose and added no value, so can be removed. The contents of actuallyClean() could use some ... actual cleaning. This CL just changes the options, removing some of the artificial option-related complexity. RELNOTES[INC]: --clean_style is no longer an option. PiperOrigin-RevId: 177843049
An asynchronous clean without a complete purge and daemon shutdown is particularly useful when the daemon takes an inordinate amount of time to read output files for md5sums. Incurs a garbage collector invocation after cache cleanup in the interest of correct usage reporting. Closes #2053. -- Reviewed-on: bazelbuild/bazel#2053 PiperOrigin-RevId: 141437418 MOS_MIGRATED_REVID=141437418
An asynchronous clean without a complete purge and daemon shutdown is
particularly useful when the daemon takes an inordinate amount of time
to read output files for md5sums. Incurs a garbage collector invocation
after cache cleanup in the interest of correct usage reporting.