R8 导致 Gradle Daemon 在 Github Hosted Action Runner 上消失
我在尝试编译应用程序的发布版本时遇到了 Githubs 操作运行程序的问题。我的应用程序有 8 种不同的风格,我们在 Play 商店上构建和提供,几个月前,我能够使用 Github Actions 在一个跑步者上同时构建多达 3 种风格。如果我们尝试一次执行 3 种以上的风格,大约 15 分钟后,构建将失败,并显示
FAILURE: Build failed with an exception.
* 出了什么问题:
意外消失(它可能已被杀死或可能已崩溃)
并且 Gradle 日志除了指出当时正在运行的任务 (minify r8) 之外并没有真正的帮助。
Gradle 构建守护进程 代码库,我看到了我们将 jvm 参数中的最大堆大小设置为 6 GB,如果我完全降低该值,那么当 r8 运行时,我最终会出现内存不足错误。对我来说,r8 会占用那么多内存,这似乎有点疯狂,而且最重要的是,github 托管的运行程序只有 7 GB 的 RAM 可供使用。因此,如果我们将 r8 在 gradle 守护进程中使用的内容结合起来,并且知道 kotlin 守护进程也在运行,我认为运行程序正在终止 gradle 守护进程的内存使用,或者它因内存不足而死亡。
自从我们添加 Jetpack Compose 库以来,我们现在无法一次构建超过一种风格的应用程序,而且我担心由于 r8 造成的内存占用而失去在 github 运行器上构建的能力。
这就是我当前的 gradle.properties 的样子:
org.gradle.jvmargs=-Xms1024m -Xmx6144m -XX:-UseGCOverheadLimit -XX:+HeapDumpOnOutOfMemoryError -XX:MaxPermSize=512m -XX:+UseParallelGC org.gradle.parallel =true org.gradle.configureondemand=true org.gradle.daemon=true org.gradle.caching=true android.useAndroidX=true android.debug.obsoleteApi=true kapt.incremental.apt=true
我尝试了一些方法来降低 r8 的工作负载:
- 删除了所有未使用的资源,这些资源使我们的资源文件夹变得混乱
- 我们实际上并没有使用数据绑定,但同时打开了 kotlin android 扩展和数据绑定,所以我将其关闭
- 我们有 Jetifier当我们实际上不再需要它时打开它,所以我禁用了它,
- 我改为使用并行垃圾收集器
- 我尝试不实际使用 gradle 守护进程,但没有看到任何区别
通过所有这些更改,我发现整体r8 步骤中的占用空间实际上确实下降到了 5 GB 以上,但是在操作上运行时,如果我尝试一次执行多个风味,守护进程仍然会消失。
我花了很多时间试图在网上找到更多信息,我似乎能找到的只是人们说增加最大堆大小,但是当我的内存受到运行它的机器的限制时,这将无济于事。
我有点不知道是什么原因造成的,任何帮助都是值得赞赏的!
I am having issues with Githubs action runners while trying to compile the release version of my app. My app has 8 different flavors that we build and provide on the play store, and a few months ago I was able to build up to 3 of those flavors at the same time on one runner using Github Actions. If we tried to do more than 3 flavors at a time, after about 15 minutes, the build would fail saying
FAILURE: Build failed with an exception.
* What went wrong:
Gradle build daemon disappeared unexpectedly (it may have been killed or may have crashed)
and the Gradle log does not really help, besides pointing to which task was running at the time (minify r8)
When I inherited this code base, I saw that we have the max heap size in the jvm args set to 6 gigs, and if I lower that at all, I end up with out of memory errors when r8 runs. It seems kinda crazy to me that r8 would be taking that much memory, and on top of that, the github hosted runners only have 7 Gb of ram available for usage anyway. So if we combine what r8 is using in the gradle daemon, with knowing that the kotlin daemon is also running, I think the runner is killing off the gradle daemon for its memory usage or it is dying from lack of memory.
Ever since we added the Jetpack Compose Libraries, we now can't build more than one flavor of the app at a time, and I am worried about losing the ability to build on github runners due to the memory footprint r8 is causing.
This is what my current gradle.properties looks like:
org.gradle.jvmargs=-Xms1024m -Xmx6144m -XX:-UseGCOverheadLimit -XX:+HeapDumpOnOutOfMemoryError -XX:MaxPermSize=512m -XX:+UseParallelGC org.gradle.parallel=true org.gradle.configureondemand=true org.gradle.daemon=true org.gradle.caching=true android.useAndroidX=true android.debug.obsoleteApi=true kapt.incremental.apt=true
I have tried a few things to lower the workload for r8:
- Removed all unused resources that had managed to clutter up our resource folder
- We weren't actually using databinding but had both the kotlin android extensions and databinding turned on, so I turned that off
- We had Jetifier turned on when we didn't actually need it anymore, so I have disabled that
- I changed to using the parallel garbage collector
- I have attempted to not actually used the gradle daemon and saw no difference
With all of these changes I have seen that the overall footprint during the r8 step actually did drop to just over 5 gigs during that step, but when running on actions, if I try to do more than one flavor at a time, the daemon will still vanish.
I have spent a lot of time trying to find more info on this online, and all I can seem to find is people saying to increase the max heap size, but that will not help when my memory is limited by the machine it is running on.
I am kinda running out of ideas of what could be causing this, any help is appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题是 ubuntus 交换文件的默认大小。在 gitHub 操作(
sudo swapon --show
)的情况下,它只有 ~1GB。当 ubuntu 内存不足(RAM + 交换文件)时,它将冻结。 (在我启用 R8 后发生在我的本地计算机上)。我们可以通过增加交换文件作为第一步来解决这个问题:The problem is the default size of ubuntus swapfile. It is only ~1GB in the case of a gitHub action (
sudo swapon --show
). When ubuntu is running out of memory (RAM + swapfile), it is going to freeze. (happened on my local machine after I enabled R8). We could fix this problem by increasing the swapfile as first step of the action:我今天遇到了完全相同的问题。
我正在 Kubernetes 上运行一个自托管的 GitHub Actions Runner Controller,看起来就像我的应用程序的构建比以前消耗了更多的内存,大约
6Gi
。更改 pod 的内存限制 为我解决了这个问题:
I had the exact same issue today.
I'm running a self-hosted GitHub Actions Runner Controller on Kubernetes, and it seems like the build of my app consumes more memory than it used to, something around
6Gi
.Changing the pod's memory limit solved the issue for me: