-
Notifications
You must be signed in to change notification settings - Fork 415
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
Lambda inlining optimization #353
base: master
Are you sure you want to change the base?
Lambda inlining optimization #353
Conversation
Co-authored-by: Maarten Steevens <[email protected]> Co-authored-by: Timothy Geerkens <[email protected]>
Can you provide some timings for a few applications: how big the applications are and how much time this inlining pass takes? |
So currently the only real world application we tested it on is the klox compiler, it contains many lambda usages so it seemed like a good test. By just inlining the more basic lambdas we are currently focusing on we were able to get a ~10% performance increase. So this is without running proguard on it so only lambda inlining. Inlining the lambdas took around 30s.
We will try do run it on some more real world applications including android apps. |
We ran the inliner on a real world application and found a lot of issues, this commit aims to resolve those.
/** | ||
* Specifies whether lambdas should be inlined. | ||
*/ | ||
public boolean lambdaInlining = 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.
I'm not sure whether we would like to have this enabled by default but rather have this as an opt-in functionality. For opt-in I believe it should be false here.
base/src/main/java/proguard/optimize/inline/lambda_locator/LambdaLocator.java
Outdated
Show resolved
Hide resolved
base/src/main/java/proguard/optimize/inline/lambda_locator/LambdaLocator.java
Outdated
Show resolved
Hide resolved
base/src/main/java/proguard/optimize/inline/lambda_locator/LambdaLocator.java
Outdated
Show resolved
Hide resolved
base/src/main/java/proguard/optimize/inline/NullCheckRemover.java
Outdated
Show resolved
Hide resolved
base/src/main/java/proguard/optimize/inline/RecursiveInliner.java
Outdated
Show resolved
Hide resolved
base/src/main/java/proguard/optimize/inline/RecursiveInliner.java
Outdated
Show resolved
Hide resolved
""".trimIndent() | ||
) | ||
|
||
// TODO: Currently broken due to a bug in the proguard-core test utils |
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.
Is this still the case, I thought it was fixed?
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 is fixed but that version of proguard core is unreleased. This pr makes use of the latest released build of proguard core which is 9.0.10
.
Made LambdaUsageHandler a class Put loadJar inside testUtil.kt and removed LambdaLocator.Util Added comments in CastRemover
We can do some of these changes because we don't modify the code in this version
Refactored LambdaImplementationVisitor visitProgramMethod
Cleaned commented code in NullCheckRemover Removed unused class Removed staircase in LocalUsageRemover
…terativeInstructionVisitor class
Fixes from inlining lambdas in the klox compiler
added a logger in lambda locator
… descriptor This is better because it fixes the case where a lambda is attempted to be inlined into a method that takes object as argument which is then later casted back into a lambda.
…javadoc to Lambda class to explain what each argument/field represents
+ added debug messages
…he BaseLambdaInliner.inline() method
Current performance on a few android applications : ANOTHERpass :
OneList :
Antimine :
|
…ass because the visitors are not part of the API of the BaseLambdaInliner
…mbda inlining without recompiling
…e so it matches the package name used in the tests and it also is just more informative, the MethodInliner for example was not in there
3f62c9c
to
9d080b2
Compare
We noticed that |
(Location can maybe be changed not sure exactly where we should put it, putting it in the official documentation seems incorrect this is not really something a proguard user should know it's more of a developer oriented piece of documentation.)
…ferences have to be updated, just the classes involved in the inlining process This should improve performance a bit.
This should also improve performance a bit.
…lassPool This should again improve performance of the pass a bit.
… method and lambda length
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Added lambda inlining for Kotlin lambdas passed directly as an argument or stored in a variable then passed as an argument. It currently cannot inline lambdas that are passed to a method and then used as an argument to a method called from the first method. We currently do not inline from final fields, nor from lambdas returned from methods. So we just handle the most basic cases for now.