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

Make unattended upgrades run faster by disabling minimal steps #1797

Merged

Conversation

Chris-Peterson444
Copy link
Contributor

@Chris-Peterson444 Chris-Peterson444 commented Sep 15, 2023

Testing shows minimal steps causes unattended-upgrades to take ~14 minutes, and ~4 minutes without.

Tested using ubuntu-22.04.1-live-server-amd64

Relevant portions of subiquity-server-debug.log:

With minimal steps:

2023-09-14 23:25:21,035 DEBUG root:39 start: subiquity/Install/install/postinstall/run_unattended_upgrades: downloading and installing all updates
2023-09-14 23:25:21,035 DEBUG subiquitycore.utils:112 astart_command called: ['systemd-run', '--wait', '--same-dir', '--property', 'SyslogIdentifier=subiquity_log.1776', '--property', 'PrivateMounts=yes', '--setenv', 'PATH=/snap/subiquity/3698/bin:/snap/subiquity/3698/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/subiquity/3698/bin', '--setenv', 'PYTHONPATH=:/snap/subiquity/3698/lib/python3.8/site-packages', '--setenv', 'PYTHON=/snap/subiquity/3698/usr/bin/python3.8', '--setenv', 'SNAP=/snap/subiquity/3698', '--', '/snap/subiquity/3698/usr/bin/python3.8', '-m', 'curtin', '--showtrace', '-vvv', '--set', 'json:reporting={"subiquity": {"type": "journald", "identifier": "curtin_event.1776.5"}}', 'in-target', '-t', '/target', '--', 'unattended-upgrades', '-v']
2023-09-14 23:25:21,740 DEBUG root:39 start: subiquity/Install/install/postinstall/run_unattended_upgrades/cmd-in-target: curtin command in-target
2023-09-14 23:39:08,491 DEBUG root:39 finish: subiquity/Install/install/postinstall/run_unattended_upgrades/cmd-in-target: SUCCESS: curtin command in-target
2023-09-14 23:39:08,591 DEBUG root:39 finish: subiquity/Install/install/postinstall/run_unattended_upgrades: SUCCESS: downloading and installing all updates

Without minimal steps:

2023-09-14 23:59:16,537 DEBUG root:30 start: subiquity/Install/install/postinstall/run_unattended_upgrades: downloading and installing all updates
2023-09-14 23:59:16,539 DEBUG subiquitycore.utils:151 astart_command called: ['systemd-run', '--wait', '--same-dir', '--property', 'SyslogIdentifier=subiquity_log.1775', '--property', 'PrivateMounts=yes', '--setenv', 'PATH=/snap/subiquity/x1/bin:/snap/subiquity/x1/usr/bin:/snap/subiquity/x1/usr/sbin:/snap/subiquity/x1/usr/bin:/snap/subiquity/x1/sbin:/snap/subiquity/x1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/subiquity/x1/bin:/snap/subiquity/x1/sbin', '--setenv', 'PYTHONPATH=:/snap/subiquity/x1/lib/python3.10/site-packages', '--setenv', 'PYTHON=/snap/subiquity/x1/usr/bin/python3.10', '--setenv', 'SNAP=/snap/subiquity/x1', '--', '/snap/subiquity/x1/usr/bin/python3.10', '-m', 'curtin', '--showtrace', '-vvv', '--set', 'json:reporting={"subiquity": {"type": "journald", "identifier": "curtin_event.1775.10"}}', 'in-target', '-t', '/target', '--', 'unattended-upgrades', '-v']
2023-09-14 23:59:17,197 DEBUG root:30 start: subiquity/Install/install/postinstall/run_unattended_upgrades/cmd-in-target: curtin command in-target
2023-09-15 00:03:38,198 DEBUG root:30 finish: subiquity/Install/install/postinstall/run_unattended_upgrades/cmd-in-target: SUCCESS: curtin command in-target
2023-09-15 00:03:38,226 DEBUG root:30 finish: subiquity/Install/install/postinstall/run_unattended_upgrades: SUCCESS: downloading and installing all updates

LP: #2039090

@Chris-Peterson444
Copy link
Contributor Author

For some context: unattended-upgrades has an option MinimalSteps which atomizes downloads. From the description of the setting in /usr/share/unattended-upgrades/50unattended-upgrades:

// Split the upgrade into the smallest possible chunks so that
// they can be interrupted with SIGTERM. This makes the upgrade
// a bit slower but it has the benefit that shutdown while a upgrade
// is running is possible (with a small delay)
//Unattended-Upgrade::MinimalSteps "true";

During install Unattended-Upgrade::MinimalSteps "true" is the default behavior, however this (obviously) slows down the install process. As stated above in my testing, this added an additional 10 minutes to the install time. This is a serious bottleneck of the install, especially for users who wish to perform multiple installs. This fix would speedup the install process significantly in the average case.

In the future we probably want to consider how this setting can be specified, if at all, since it will cause some issues with cancellation. However, it's well worth the average case speedup, and some cancellations are likely due to unattended-upgrades taking too long in the first place.

Copy link
Collaborator

@dbungert dbungert left a comment

Choose a reason for hiding this comment

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

Please rebase for clean history, I have one suggestion, then we can call this done and merge.

subiquity/server/controllers/install.py Outdated Show resolved Hide resolved
Co-authored-by: Dan Bungert <danielbungert@gmail.com>
@dbungert dbungert merged commit a4fe424 into canonical:main Sep 15, 2023
12 checks passed
@Chris-Peterson444 Chris-Peterson444 deleted the faster-unattended-upgrades branch September 15, 2023 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants