Skip to content
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

[FR]: Faster build speed with Gradle properties + jemalloc #1510

Open
2 tasks done
kaeawc opened this issue Jun 20, 2024 · 1 comment
Open
2 tasks done

[FR]: Faster build speed with Gradle properties + jemalloc #1510

kaeawc opened this issue Jun 20, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@kaeawc
Copy link
Contributor

kaeawc commented Jun 20, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Describe the problem

I was talking about the settings used in this project with @liutikas and some others. It was speculated that it was possible to reduce the JVM heap size the project uses and also attain a faster build speed.

Describe the solution

I propose we do this by:

  • Using jemalloc as a malloc replacement - most projects get about 10% memory freed up, though no build speed impact
  • Use G1GC - I've seen this work better for Android projects that use JDK 19 or later, or if they're simply having some memory contention/pressure issues with running the project on resource constrained machines.
  • SoftRefLRUPolicy - This is defaulted to 1000 which at current settings would take almost 2 hours to release any soft ref
  • ReservedCodeCacheSize - Increasing this from the default allows the project to preallocate the codecache and not have to spend time growing it during a build
  • MetaspaceSize - From my research about Metaspace, Android Gradle builds benefit the most when MaxMetaspace is allowed to be unlimited (the JVM default) and MetaspaceSize set to 512MB or 1GB instead of the default 20MB. This is because MaxMetaspace is a constraint on both Metapsace and ClassPointers, the latter of which defaults to 1GB.
  • Min & max heap - Experimentation required to see what the optimal heap size for the project would be for both local development and GitHub CI.

Additional context

I already did the performance testing and changes, I'm just filling this out so the change can be considered and reviewed.

Code of Conduct

  • I agree to follow this project's Code of Conduct
@kaeawc kaeawc added the enhancement New feature or request label Jun 20, 2024
@Hackermrj
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Describe the problem

I was talking about the settings used in this project with @liutikas and some others. It was speculated that it was possible to reduce the JVM heap size the project uses and also attain a faster build speed.

Describe the solution

I propose we do this by:

  • Using jemalloc as a malloc replacement - most projects get about 10% memory freed up, though no build speed impact
  • Use G1GC - I've seen this work better for Android projects that use JDK 19 or later, or if they're simply having some memory contention/pressure issues with running the project on resource constrained machines.
  • SoftRefLRUPolicy - This is defaulted to 1000 which at current settings would take almost 2 hours to release any soft ref
  • ReservedCodeCacheSize - Increasing this from the default allows the project to preallocate the codecache and not have to spend time growing it during a build
  • MetaspaceSize - From my research about Metaspace, Android Gradle builds benefit the most when MaxMetaspace is allowed to be unlimited (the JVM default) and MetaspaceSize set to 512MB or 1GB instead of the default 20MB. This is because MaxMetaspace is a constraint on both Metapsace and ClassPointers, the latter of which defaults to 1GB.
  • Min & max heap - Experimentation required to see what the optimal heap size for the project would be for both local development and GitHub CI.

Additional context

I already did the performance testing and changes, I'm just filling this out so the change can be considered and reviewed.

Code of Conduct

  • I agree to follow this project's Code of Conduct

Yep sure Mr.kaeawc I'm clear this issue as you soon. Thank you for your information

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants