-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Improve --help performance for x.py #48569
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -670,7 +670,7 @@ def set_dev_environment(self): | |
self._download_url = 'https://dev-static.rust-lang.org' | ||
|
||
|
||
def bootstrap(): | ||
def bootstrap(help_triggered): | ||
"""Configure, fetch, build and run the initial bootstrap""" | ||
parser = argparse.ArgumentParser(description='Build rust') | ||
parser.add_argument('--config') | ||
|
@@ -708,7 +708,7 @@ def bootstrap(): | |
print(' and so in order to preserve your $HOME this will now') | ||
print(' use vendored sources by default. Note that if this') | ||
print(' does not work you should run a normal build first') | ||
print(' before running a command like `sudo make install`') | ||
print(' before running a command like `sudo ./x.py install`') | ||
|
||
if build.use_vendored_sources: | ||
if not os.path.exists('.cargo'): | ||
|
@@ -734,7 +734,10 @@ def bootstrap(): | |
if 'dev' in data: | ||
build.set_dev_environment() | ||
|
||
build.update_submodules() | ||
# No help text depends on submodules. This check saves ~1 minute of git commands, even if | ||
# all the submodules are present and downloaded! | ||
if not help_triggered: | ||
build.update_submodules() | ||
|
||
# Fetch/build the bootstrap | ||
build.build = args.build or build.build_triple() | ||
|
@@ -760,7 +763,13 @@ def main(): | |
help_triggered = ( | ||
'-h' in sys.argv) or ('--help' in sys.argv) or (len(sys.argv) == 1) | ||
try: | ||
bootstrap() | ||
# If the user is asking for help, let them know that the whole download-and-build | ||
# process has to happen before anything is printed out. | ||
if help_triggered: | ||
print("NOTE: Downloading and compiling bootstrap requirements before processing") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the word "requirements" used in this meaning? "Downloading requirements" sounds weird. |
||
print(" --help command. See src/bootstrap/README.md for help with common") | ||
print(" commands.") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should get this message only if we actually going to download something or do other long operation. Actually there's already There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I decided to print the message every time, because we always rebuild the build tool. So it will never be instant. Also, doing anything more complicated than printing this at the beginning means that we have to go through the whole process to gather information, setup environment variables, and check if anything needs to be done. It would require a lot of logic spread through a lot of the build script, and that complexity simply isn't worth it. I have never noticed The message also doesn't reference --help at all; it states why stuff needs to download before running build commands, but the user will not expect --help to be part of that. My message makes that perfectly clear. Basically, we either have to print this whenever --help happens, regardless of what we actually need to do; OR we have to wait until the build script sets up enough to know if it needs to download, at which point seconds have already passed and the tool will feel sluggish (asking the user to wait after the user has already waited). And if we want to do the second option, because of how the script is organized, we would either have to do a lot of refactoring, or litter the code with checks and print statements. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, sounds good. |
||
bootstrap(help_triggered) | ||
if not help_triggered: | ||
print("Build completed successfully in {}".format( | ||
format_build_time(time() - start_time))) | ||
|
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.
Could you move this into
bootstrap()
? Top levelmain
is for catching and handling exceptions only.