Skip to content

build: Performance and Dep Locking #2400

@ignoramous

Description

@ignoramous

Dep locks: https://docs.gradle.org/current/userguide/dependency_locking.html

Dynamic deps: https://docs.gradle.org/current/userguide/performance.html#minimize_dynamic_and_snapshot_versions

configurations.all {
    resolutionStrategy {
        cacheDynamicVersionsFor 4, 'hours'
        cacheChangingModulesFor 10, 'minutes'
    }
}

Cache: https://docs.gradle.org/current/userguide/caching_android_projects.html#annotation_processors_and_kotlin

plugins.withId("kotlin-kapt") {
    kapt.useBuildCache = true
}

Compiler: https://docs.gradle.org/current/userguide/performance.html#a_run_the_compiler_as_a_separate_process

tasks.withType(JavaCompile).configureEach {
    options.fork = true
}

Resource shrinking: https://developer.android.com/topic/performance/app-optimization/enable-app-optimization / https://developer.android.com/topic/performance/baselineprofiles/dex-layout-optimizations

// build.gradle
    buildTypes {
        release {
            isMinifyEnabled = true
            isShrinkResources = true
            dexLayoutOptimization = true
            ...
        }

        ...
    }

// github.com/celzero/rethink-app/blob/main/gradle.properties
android.r8.optimizedResourceShrinking=true

After analyzing build, if safe, enable configuration-cache: https://developer.android.com/build/optimize-your-build#use-the-configuration-cache

Convert bundled images to webp: https://developer.android.com/build/optimize-your-build#use_webp

JVM opts: https://developer.android.com/build/optimize-your-build#increase-the-jvm-heap-size

org.gradle.jvmargs=-Xmx6g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC -XX:MaxMetaspaceSize=1g

Create a base app startup profile: https://developer.android.com/topic/performance/baselineprofiles/create-baselineprofile (see also: https://developer.android.com/topic/performance/baselineprofiles/dex-layout-optimizations#considerations)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions