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

defer squashfs mounts #2276

Merged
merged 1 commit into from
Jul 18, 2022

Conversation

bcressey
Copy link
Contributor

Issue number:
N/A

Description of changes:
Mounting /usr/share/licenses and /usr/src/kernels can add up to one second of delay before reaching local-fs.target.

It's not necessary to read software licenses or build out-of-tree kernel modules at this stage in the boot process. Moving the mounts after local-fs.target doesn't eliminate the delay, but does allow the system to do other useful work in parallel, like acquiring DHCP leases and applying settings.

Testing done:
I verified that link-kernel-modules.service and load-kernel-modules run correctly on the aws-k8s-1.22-nvidia variant.

It's difficult to quantify the actual benefit of this since it can vary widely, and depends on other factors like the amount of console logging and whether the wrong kernel thread gets "stuck" flushing to the console when these messages are printed:

[    4.630105] loop: module loaded
[    4.644181] squashfs: version 4.0 (2009/01/31) Phillip Lougher

Instead I'll just point to the actual mount unit times:

 275ms var-lib-kernel\x2ddevel-.overlay-lower.mount
 274ms x86_64\x2dbottlerocket\x2dlinux\x2dgnu-sys\x2droot-usr-share-licenses.mount
 146ms sys-kernel-tracing.mount
 145ms tmp.mount
 140ms etc-cni.mount
 140ms sys-kernel-debug.mount
 140ms dev-mqueue.mount
 139ms dev-hugepages.mount
  24ms opt-cni-bin.mount
  22ms var-lib-bottlerocket.mount
  21ms etc-containerd.mount
  20ms x86_64\x2dbottlerocket\x2dlinux\x2dgnu-sys\x2droot-usr-lib-modules.mount
  18ms etc-host\x2dcontainers.mount
  17ms sys-kernel-config.mount
  17ms sys-fs-fuse-connections.mount
  14ms local.mount
  11ms mnt.mount
   9ms opt.mount
   8ms var.mount
   5ms x86_64\x2dbottlerocket\x2dlinux\x2dgnu-sys\x2droot-usr-src-kernels.mount

These are consistently the two slowest mounts, and intuitively it is preferable to deal with slow mounts later in boot if possible, to avoid unlucky sequences where the system stalls for 300 ms before reaching local-fs.target.

Terms of contribution:

By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.

Mounting `/usr/share/licenses` and `/usr/src/kernels` can add up to
one second of delay before reaching `local-fs.target`.

It's not necessary to read software licenses or build out-of-tree
kernel modules at this stage in the boot process. Moving the mounts
after `local-fs.target` doesn't eliminate the delay, but does allow
the system to do other useful work in parallel, like acquiring DHCP
leases and applying settings.

Signed-off-by: Ben Cressey <[email protected]>
Copy link
Contributor

@zmrow zmrow left a comment

Choose a reason for hiding this comment

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

Neat! 📸

@bcressey bcressey merged commit dc1e132 into bottlerocket-os:develop Jul 18, 2022
@bcressey bcressey deleted the defer-squashfs-mounts branch July 18, 2022 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants