-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
ci: use zram instead of on-disk swap #27733
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
base: master
Are you sure you want to change the base?
Conversation
|
Seems like the zram module isn't available for azure VMs (which is internally used by GitHub action runners). Guess we will have to keep on using slower swapfiles then |
|
We could test if Zswap is available, maybe that'll let us use a smaller swapfile. |
|
IIRC kernel modules on GitHub CI need to be compiled from source to run. I used to compile |
|
What's the CI time overhead on that? Can we compile the Kernel modules ahead of time or does that need to happen on the CI every run? |
I think that it can be done using Github Cache.
IIRC |
|
Let me see if I can get this thing going with zram dkms module |
|
There we go. Some cleaning required. Then we can go ahead and get the builds for zram cached using GitHub Cache, and it should be pretty quick to load instead of 1m on cloning the kernel. Will probably get this in a day or two |
| - name: Set process id limit for 32-bit builds depending on aosp-libs | ||
| run: echo 65535 | sudo tee /proc/sys/kernel/pid_max | ||
| - name: Setup zram for packages that need more memory | ||
| run: | |
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 assume this will be adjusted so that it is still only run conditionally when the packages requiring free-space.sh are being built, right?
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.
It should be possible to after splitting this step into 3 steps:
- extraction of kernel version on the runner VM
- Using the kernel version as key for storing into github actions cache
- optionally building the module on cache miss
All these steps can be set to only run if large packages are being built
Although I would prefer to keep this to always on. zram should not negatively affect performance if it is not being used. Also it should improve performance when a process which is just hogging memory without using it is moved over to zram. We can test this on CI, and see if it is worth keeping this on by default
|
On a procedural note since I'm seeing it in the commit log here. That lets you mark commits in a way that they're automatically sorted to be squashed into the commit they are linked to during a [rebase]
autosquash = truein your git config (either This also automatically makes
Footnotes |
|
I needed the commit messages of in-between changes for rewriting the commit history once done. This PR is ready for review once I do that. Also thanks for the |
Yep no worries.
Found out about that one somewhat recently and it's been a really useful addition to my workflow. |
81957a4 to
3f9033f
Compare
|
Thanks! |
| - name: Extract VM kernel version for module compilation | ||
| id: kernel-info | ||
| run: | | ||
| KERNEL_VERSION="$(uname -r | grep -o "^[0-9\\.]*")" | ||
| TAR_KERNEL_VERSION="${KERNEL_VERSION%\.0}" | ||
| echo "kernel_version=${KERNEL_VERSION}" >> "$GITHUB_OUTPUT" | ||
| echo "tar_version=${TAR_KERNEL_VERSION}" >> "$GITHUB_OUTPUT" | ||
| echo "modules_dir=/lib/modules/$(uname -r)" >> "$GITHUB_OUTPUT" | ||
| - name: Restore cached zram kernel module | ||
| id: cache-zram | ||
| uses: actions/cache/restore@v5 | ||
| with: | ||
| path: scripts/zram.ko.zst | ||
| key: ${{ steps.kernel-info.outputs.kernel_version }}-${{ hashFiles('scripts/linux-kernel-signing-keys.gpg') }}-${{ hashFiles('.github/workflows/packages.yml') }} | ||
|
|
||
| - name: Build zram kernel module | ||
| if: steps.cache-zram.outputs.cache-hit != 'true' |
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.
How exactly does the GHA caching work anyway?
Build zram kernel module is conditioned on getting a cache miss.
But I'm guessing we need the kernel version to check the cache in the first place?
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.
The paths specified by path are cached by GHA. If some data is available with the specified key, then it is restored (happens above in actions/cache/restore step). The key is set to the kernel version as well as the script which is running and the files which we are using (the signing keys for the kernel)
We only need to build the module if we couldn't restore from cache.
We further save the cache just after we build the module and load it.
02a3f36 to
b2ea4ea
Compare
|
This PR should be ready for review. Some action runs: Older runs before cleaning commits showing that caching of the built DKMS module works:
|
Should improve performance when compiling large packages. And zram should be unused unless there is requirement for it's usage. Not sure how much will it affect packages that do not need additional memory (needs to be monitored for CI usage after getting merged)
Changes made: - download tarball from cdn.kernel.org instead of git clone Also check the signature of the tarball - Manual install module instead of using modules_install modules_install does do the same thing and run depmod. We are running depmod ourselves. Also kernel Makefile will skip running depmod since System.map is not available on the VM - Also do zstd compression on the module. The kernel makefiles don't seem to do it by default
- Store some of the common variables as outputs for reuse - Manually restore and save cached zram.ko.zst. This should ensure that the builds are cached even when building packages fails - Additionally the built zram.ko.zst needs to be stored in scripts/ as GHA doesn't support caching absolute paths well: See issues: - actions/cache#1127 - actions/cache#1540 which was worked around in oro-os/toolchain@ebcad88 by using relative path Also restoring cache in /lib/modules/ would require actions/cache/restore to run as root, and exists no documented way to do that which I could find online
b2ea4ea to
93e2b74
Compare
No description provided.