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

Add --async clean independent of expunge #2053

Closed
wants to merge 1 commit into from

Conversation

werkt
Copy link
Contributor

@werkt werkt commented Nov 7, 2016

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.

@bazel-io
Copy link
Member

bazel-io commented Nov 7, 2016

Can one of the admins verify this patch?

@googlebot
Copy link

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. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

@@ -191,6 +227,7 @@ private void actuallyClean(CommandEnvironment env,
if (cleanOptions.expunge || cleanOptions.expunge_async) {
throw new ShutdownBlazeServerException(0, ShutdownMethod.EXPUNGE);
}
System.gc();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why gc here?

Copy link
Contributor Author

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...");
Copy link
Contributor

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

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

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.

@damienmg damienmg self-assigned this Dec 5, 2016
@damienmg
Copy link
Contributor

damienmg commented Dec 5, 2016

@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.

@damienmg
Copy link
Contributor

damienmg commented Dec 5, 2016

Jenkins test this please

@werkt
Copy link
Contributor Author

werkt commented Dec 6, 2016

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.

@damienmg
Copy link
Contributor

damienmg commented Dec 6, 2016

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

@ulfjack ulfjack Dec 6, 2016

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

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.

Copy link
Contributor

@ulfjack ulfjack left a 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.

@werkt
Copy link
Contributor Author

werkt commented Dec 6, 2016

Updated for @ulfjack's review. No need to apologize @damienmg, we're all busy people :)

@@ -132,6 +150,30 @@ public ExitCode exec(CommandEnvironment env, OptionsProvider options)
}
}

private void asyncClean(CommandEnvironment env,
Copy link
Contributor

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

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'.

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'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.

Copy link
Contributor

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.

Copy link
Contributor

@ulfjack ulfjack left a 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.

@laszlocsomor
Copy link
Contributor

laszlocsomor commented Dec 7, 2016

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

Thanks! Importing.

@laszlocsomor
Copy link
Contributor

@iirina : FYI, I can handle importing this PR

@bazel-io bazel-io closed this in c75aaeb Dec 8, 2016
werkt pushed a commit to werkt/bazel that referenced this pull request Dec 20, 2016
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
bazel-io pushed a commit that referenced this pull request Dec 4, 2017
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
luca-digrazia pushed a commit to luca-digrazia/DatasetCommitsDiffSearch that referenced this pull request Sep 4, 2022
    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
luca-digrazia pushed a commit to luca-digrazia/DatasetCommitsDiffSearch that referenced this pull request Sep 5, 2022
    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
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.

None yet

6 participants