google / gson

A Java serialization/deserialization library to convert Java Objects into JSON and back
Apache License 2.0
23.29k stars 4.28k forks source link

Performance regressions from 2.10.1 to 2.11.0 on R8 minification task #2683

Closed SimonMarquis closed 1 month ago

SimonMarquis commented 4 months ago

Gson version

2.11.0

Java / Android version

Java 17-21

Used tools

Description

Bumping from Gson 2.10.1 to 2.11.0 leads to

On our CI we are running 3 parallel builds (Android flavors) with parallelized proguard -Pandroid.r8.maxWorkers=3 and an insane amount of RAM (72GiB). It used to build fine in ~15min before the update, and now it can no longer build because of these regressions.

2.10.1 2.11.0
image image

Reproduction steps

Compare 2 Android builds configured with proguard minification and with the two different versions.

Notes

This might be related to the recent inclusion of new proguard rules in the binary, but even after switching to these new rules (and keeping the old dependency) the increase in execution time and heap size usage is not as huge as it is with the new version.

Marcono1234 commented 4 months ago

Thanks for the report! Could you please try if using a newer R8 version has any effect, see https://r8.googlesource.com/r8/+/refs/heads/master/#replacing-r8-in-agp (just in case this is an issue with R8 which is fixed in newer versions).

Do you know if there is some way to find out why R8 performance has decreased for Gson or if there is some way to make R8 output profiling data about where it takes the most time? Since you already have VisualVM connected, could you please try enabling the Sampler and share the results (and the R8 version you are using)? Maybe that in combination with the R8 obfuscation mappings (see https://r8.googlesource.com/r8/+/refs/heads/master/#obtaining-prebuilts, r8lib.jar.map) could help at least narrowing it down.

Maybe it would also be worth asking on the R8 mailing list mentioned at https://r8.googlesource.com/r8/+/refs/heads/master/#getting-help.

SimonMarquis commented 1 month ago

Unable to reproduce consistently at this time.