Status Update
Comments
ch...@google.com <ch...@google.com>
ch...@google.com <ch...@google.com> #2
Thanks for reporting this and for taking the time to create a reproduction. The given app seems to compile to dex in a few seconds, but compiling to class files takes several minutes due to hitting unintentional quadratic behavior in dead code elimination. I will look into fixing this and report back once you should be able to test a new version.
ap...@google.com <ap...@google.com> #3
Branch: main
commit 85ad0d69f99553ce6dd0b99d383e1c55dc70f3df
Author: Christoffer Quist Adamsen <christofferqa@google.com>
Date: Wed Feb 08 08:26:54 2023
Refactor value-is-dead analysis to separate analysis class
Bug:
Change-Id: I8b881203ebe21395f48c8eeb6434faa03f7f9d46
M src/main/java/com/android/tools/r8/ir/code/BasicBlock.java
M src/main/java/com/android/tools/r8/ir/code/Value.java
A src/main/java/com/android/tools/r8/ir/code/ValueIsDeadAnalysis.java
M src/main/java/com/android/tools/r8/ir/optimize/DeadCodeRemover.java
ap...@google.com <ap...@google.com> #4
Branch: main
commit 6edc639a92de908f89ba86445a9d6b21351c58fd
Author: Christoffer Quist Adamsen <christofferqa@google.com>
Date: Wed Feb 08 12:31:15 2023
Rewrite value-is-dead analysis to a worklist algorithm
Bug:
Change-Id: I699f43eba8774083a4b5f2aa2edf7c5d80df4c8e
M src/main/java/com/android/tools/r8/ir/code/ValueIsDeadAnalysis.java
ap...@google.com <ap...@google.com> #5
Branch: main
commit 70bbb88b80b31de9a5ccbe30d27a962b0fb0c45a
Author: Christoffer Quist Adamsen <christofferqa@google.com>
Date: Wed Feb 08 16:13:24 2023
Fix repeated analysis of values in dead code removal
Bug:
Change-Id: I9deebf700e936ad81a8fb25d067acc04637d980d
M src/main/java/com/android/tools/r8/ir/code/ArrayPut.java
M src/main/java/com/android/tools/r8/ir/code/ValueIsDeadAnalysis.java
M src/main/java/com/android/tools/r8/ir/optimize/DeadCodeRemover.java
M src/main/java/com/android/tools/r8/utils/MapUtils.java
ap...@google.com <ap...@google.com> #6
Branch: main
commit 54ed0312d2e5ade4b8092a86989d0e6827e646dd
Author: Christoffer Quist Adamsen <christofferqa@google.com>
Date: Thu Feb 09 08:49:58 2023
Refinements to value-is-dead analysis
Bug:
Fixes:
Change-Id: I8007b13e2a4e0c32dffc181a827867ff4ab0373e
M src/main/java/com/android/tools/r8/ir/code/ValueIsDeadAnalysis.java
M src/main/java/com/android/tools/r8/ir/optimize/DeadCodeRemover.java
ap...@google.com <ap...@google.com> #7
Branch: 4.0
commit 2fc27f8cef33c22525c585e5c65bf3d67a18755a
Author: Christoffer Quist Adamsen <christofferqa@google.com>
Date: Thu Feb 09 11:19:09 2023
Version 4.0.53
Bug:
Bug:
Change-Id: I62f98b9723358310ade7f2bd5f8e589fa91c8ab6
M src/main/java/com/android/tools/r8/Version.java
ap...@google.com <ap...@google.com> #8
Branch: 4.0
commit b86fdf2b2427605e6a238a0232932fa1268245f8
Author: Christoffer Quist Adamsen <christofferqa@google.com>
Date: Thu Feb 09 11:16:04 2023
Refinements to value-is-dead analysis
Bug:
Fixes:
Change-Id: I8007b13e2a4e0c32dffc181a827867ff4ab0373e
M src/main/java/com/android/tools/r8/ir/code/ValueIsDeadAnalysis.java
M src/main/java/com/android/tools/r8/ir/optimize/DeadCodeRemover.java
ap...@google.com <ap...@google.com> #9
Branch: 4.0
commit 472c7fab11e7da906d07eb04d8600f6aea8d3c1e
Author: Christoffer Quist Adamsen <christofferqa@google.com>
Date: Thu Feb 09 11:15:38 2023
Fix repeated analysis of values in dead code removal
Bug:
Change-Id: I9deebf700e936ad81a8fb25d067acc04637d980d
M src/main/java/com/android/tools/r8/ir/code/ArrayPut.java
M src/main/java/com/android/tools/r8/ir/code/ValueIsDeadAnalysis.java
M src/main/java/com/android/tools/r8/ir/optimize/DeadCodeRemover.java
M src/main/java/com/android/tools/r8/utils/MapUtils.java
ap...@google.com <ap...@google.com> #10
Branch: 4.0
commit b14e5bc4c5f41fc593cc6176de220ce43d9c899f
Author: Christoffer Quist Adamsen <christofferqa@google.com>
Date: Thu Feb 09 11:15:14 2023
Rewrite value-is-dead analysis to a worklist algorithm
Bug:
Change-Id: I699f43eba8774083a4b5f2aa2edf7c5d80df4c8e
M src/main/java/com/android/tools/r8/ir/code/ValueIsDeadAnalysis.java
ap...@google.com <ap...@google.com> #11
Branch: 4.0
commit 4621177fe24819fe5459b065a9d6d138cb79b5b2
Author: Christoffer Quist Adamsen <christofferqa@google.com>
Date: Thu Feb 09 11:14:33 2023
Refactor value-is-dead analysis to separate analysis class
Bug:
Change-Id: I8b881203ebe21395f48c8eeb6434faa03f7f9d46
M src/main/java/com/android/tools/r8/ir/code/BasicBlock.java
M src/main/java/com/android/tools/r8/ir/code/Value.java
A src/main/java/com/android/tools/r8/ir/code/ValueIsDeadAnalysis.java
M src/main/java/com/android/tools/r8/ir/optimize/DeadCodeRemover.java
ap...@google.com <ap...@google.com> #12
Branch: 8.0
commit 376af144cf327f0f2b0a2de0a38939a59216a08d
Author: Christoffer Quist Adamsen <christofferqa@google.com>
Date: Thu Feb 09 11:25:18 2023
Version 8.0.29
Bug:
Bug:
Change-Id: I994d406bae7514482ffdf2ef10f092b5a96cc328
M src/main/java/com/android/tools/r8/Version.java
ap...@google.com <ap...@google.com> #13
Branch: 8.0
commit 77704f63db4161833b7072c42cbf9869a2f20e80
Author: Christoffer Quist Adamsen <christofferqa@google.com>
Date: Thu Feb 09 11:23:20 2023
Refinements to value-is-dead analysis
Bug:
Fixes:
Change-Id: I8007b13e2a4e0c32dffc181a827867ff4ab0373e
M src/main/java/com/android/tools/r8/ir/code/ValueIsDeadAnalysis.java
M src/main/java/com/android/tools/r8/ir/optimize/DeadCodeRemover.java
ap...@google.com <ap...@google.com> #14
Branch: 8.0
commit 33930d7b7ff37a746a304bb0230b34123b1e0e6f
Author: Christoffer Quist Adamsen <christofferqa@google.com>
Date: Thu Feb 09 11:22:50 2023
Fix repeated analysis of values in dead code removal
Bug:
Change-Id: I9deebf700e936ad81a8fb25d067acc04637d980d
M src/main/java/com/android/tools/r8/ir/code/ArrayPut.java
M src/main/java/com/android/tools/r8/ir/code/ValueIsDeadAnalysis.java
M src/main/java/com/android/tools/r8/ir/optimize/DeadCodeRemover.java
M src/main/java/com/android/tools/r8/utils/MapUtils.java
ap...@google.com <ap...@google.com> #15
Branch: 8.0
commit 923cf259db1b2f35578a486960afcd28369c520f
Author: Christoffer Quist Adamsen <christofferqa@google.com>
Date: Thu Feb 09 11:22:16 2023
Rewrite value-is-dead analysis to a worklist algorithm
Bug:
Change-Id: I699f43eba8774083a4b5f2aa2edf7c5d80df4c8e
M src/main/java/com/android/tools/r8/ir/code/ValueIsDeadAnalysis.java
ap...@google.com <ap...@google.com> #16
Branch: 8.0
commit 736dd75501862e23764d265887a99ef8d8af0c9d
Author: Christoffer Quist Adamsen <christofferqa@google.com>
Date: Thu Feb 09 11:21:02 2023
Refactor value-is-dead analysis to separate analysis class
Bug:
Change-Id: I8b881203ebe21395f48c8eeb6434faa03f7f9d46
M src/main/java/com/android/tools/r8/ir/code/BasicBlock.java
M src/main/java/com/android/tools/r8/ir/code/Value.java
A src/main/java/com/android/tools/r8/ir/code/ValueIsDeadAnalysis.java
M src/main/java/com/android/tools/r8/ir/optimize/DeadCodeRemover.java
ch...@google.com <ch...@google.com> #17
This should now be fixed in R8 versions 4.0.53 and 8.0.29 - and next week in 8.1.19-dev.
On my machine the build time for compiling the reproduction with R8 is down from ~190s to ~3s.
bv...@gmail.com <bv...@gmail.com> #18
I just tested 4.0.53: on the sample project it also runs in ~3s in my machine. The larger project now finishes within a few minutes, and that previously took almost an hour, wow. Thanks!
Any idea when this fix will become available in the AGP? Next release of Android Studio, I assume?
ch...@google.com <ch...@google.com> #19
Thanks for the confirmation. This will hopefully make it into Flamingo (AGP 8.0).
Description
We're using Renderscript in one of our projects and noticed that our build times for a minified release build went up by a factor of 3 after upgrading the Android Gradle Plugin from 7.3.1 to 7.4.0: from 17 minutes to 53 minutes.
For each Renderscript file, two files are generated: a
ScriptC_$name
file which contains bridging functions, and a$nameBitCode
file which contains a few huge byte arrays that are compiled into GPU code on the user's phone. R8 takes a very long time to process this last file.I made a sample project here:https://github.com/bvschaik/r8-renderscript-minify-issue here .
This project contains a copy of the BitCode class that's generated by Renderscript
Using AGP 7.4.0 (uses R8 4.0.48), running assembleRelease on this project takes almost 4 minutes, with 3m40s taken up by the
minifyReleaseWithR8
task.Downgrading AGP to 7.3.1 (uses R8 3.3.83), the
minifyReleaseWithR8
"only" takes 1m10s, which is still quite long for processing some static byte arrays.For now we're forcing R8 to the last available 3.3 version to get back to acceptable build times.
What could cause this increase in build times?
Why is R8 spending so much time on relatively simple code?
What can we do to tell R8 "don't change anything in this file"? I tried various -keep rules but it didn't make a difference.