Slide 1

Slide 1 text

Perspectives from a Solutions Engineer Nelson Osacky

Slide 2

Slide 2 text

Toro y Moi - Freelance

Slide 3

Slide 3 text

Perspectives from a Solutions Engineer •Why is productivity important? •What does Nelson do as a Solutions Engineer? •How can I make my build faster? •What is coming up in Gradle?

Slide 4

Slide 4 text

Me • Previously Android Engineer • Large projects • SoundCloud • Square • Small startups • Solutions Engineer at Gradle

Slide 5

Slide 5 text

Me • Gradle Plugin Maintainer • Fladle - Easily Scale Instrumentation Tests on Firebase https://github.com/runningcode/fladle • Delect - Replace Dagger with Dagger Reflect https://github.com/soundcloud/delect/ • Gradle Doctor - Actionable Insights for your build https://github.com/runningcode/gradle-doctor

Slide 6

Slide 6 text

Solutions Engineer https://gradle.com/enterprise/trial/

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

Gradle Build Tool Gradle Enterprise

Slide 9

Slide 9 text

Android Gradle Plugin Android Studio

Slide 10

Slide 10 text

Kotlin Intellij

Slide 11

Slide 11 text

Why is productivity important?

Slide 12

Slide 12 text

Android Development Feature Development Tech Debt (There are other things too)

Slide 13

Slide 13 text

Tech Debt Refactoring Build Speed

Slide 14

Slide 14 text

Build Speed is Tech Debt And it always pays off

Slide 15

Slide 15 text

Cost of Builds 60s waste * 50 builds / day * 50 devs = 42 hours lost / day

Slide 16

Slide 16 text

Cost of Builds 60s waste * 50 builds / day * 50 devs = 42 hours lost / day not including lost focus https://gradle.com/roi-calculator

Slide 17

Slide 17 text

Fast Builds Matter

Slide 18

Slide 18 text

Cost of Builds 60s waste * 50 builds / day * 50 devs = 42 hours lost / day hire 5 new people without paying them! no recruiting https://gradle.com/roi-calculator

Slide 19

Slide 19 text

Build Speed is Tech Debt And it always pays off And is easy to justify working on it

Slide 20

Slide 20 text

Motivated?

Slide 21

Slide 21 text

Solutions Engineer https://gradle.com/enterprise/trial/

Slide 22

Slide 22 text

Solutions Engineer What do I do?

Slide 23

Slide 23 text

Work with trial prospects

Slide 24

Slide 24 text

Help customers get the most out of Gradle Enterprise

Slide 25

Slide 25 text

Help Gradle address customers needs

Slide 26

Slide 26 text

I see a lot of builds from 10 person teams to 1000+ Android, Gradle and Maven

Slide 27

Slide 27 text

Optimize and understand builds Reduce failures Preach Developer Productivity Help customers maximize trials

Slide 28

Slide 28 text

Help prioritize issues with Gradle Build tools and Gradle Enterprise Present business cases for purchasing Gradle Enterprise

Slide 29

Slide 29 text

Meet with Google and Jetbrains to help prioritize issues impacting customers

Slide 30

Slide 30 text

Fix issues in open source plugin affecting customers

Slide 31

Slide 31 text

Solutions Team at Gradle • Gary Hale • Daz Deboer • Etienne Studer • Nelson Osacky (me)

Slide 32

Slide 32 text

Solutions Team at Gradle Supported by Operations and Build Tool teams help me sound like I know what I'm talking about

Slide 33

Slide 33 text

Gradle Enterprise Trials

Slide 34

Slide 34 text

Work with a champion

Slide 35

Slide 35 text

Meet once a week

Slide 36

Slide 36 text

Experiments Examine build scans Help with other Gradle questions

Slide 37

Slide 37 text

What do I see?

Slide 38

Slide 38 text

Understanding of Gradle can vary wildly

Slide 39

Slide 39 text

Optimization level of build can vary wildly

Slide 40

Slide 40 text

Always room for improvements! but watch out for diminishing returns

Slide 41

Slide 41 text

How can I go faster?

Slide 42

Slide 42 text

Depends on your build

Slide 43

Slide 43 text

Build Lifecycle •Initialization •Configuration •Execution

Slide 44

Slide 44 text

Build Lifecycle Initialization Sets up the environment for the build and determines which projects will take part in it.

Slide 45

Slide 45 text

Build Lifecycle Configuration All build scripts of all projects are executed. Constructs and configures the task graph.

Slide 46

Slide 46 text

Build Lifecycle Execution Runs the tasks graph in order.

Slide 47

Slide 47 text

Where to start?

Slide 48

Slide 48 text

Check for Red Flags

Slide 49

Slide 49 text

What is a red flag?

Slide 50

Slide 50 text

If nothing changes, no tasks should execute.

Slide 51

Slide 51 text

./gradlew assembleDebug ./gradlew assembleDebug BUILD SUCCESSFUL in 2s 58 actionable tasks: 58 up-to-date

Slide 52

Slide 52 text

./gradlew assembleDebug ./gradlew assembleDebug BUILD SUCCESSFUL in 5s 359 actionable tasks: 3 executed, 356 from cache

Slide 53

Slide 53 text

Check for Red Flags Regularly

Slide 54

Slide 54 text

BUILD SUCCESSFUL in 5s 359 actionable tasks: 3 executed, 356 up-to-date Publishing build scan... https://gradle.com/s/yj5jtd4kh6ucc Build Analyzer results available

Slide 55

Slide 55 text

BUILD SUCCESSFUL in 5s 359 actionable tasks: 3 executed, 356 up-to-date Publishing build scan... https://gradle.com/s/yj5jtd4kh6ucc Build Analyzer results available Gradle Build Scans Android Studio Build Analyzer

Slide 56

Slide 56 text

Android Studio Build Analyzer

Slide 57

Slide 57 text

Run a build scan ./gradlew assembleDebug --scan https://scans.gradle.com/

Slide 58

Slide 58 text

No content

Slide 59

Slide 59 text

Filter

Slide 60

Slide 60 text

No content

Slide 61

Slide 61 text

No content

Slide 62

Slide 62 text

9 tasks ran Bugsnag

Slide 63

Slide 63 text

No content

Slide 64

Slide 64 text

Enable parallel, enable caching, enable daemon

Slide 65

Slide 65 text

16627 tasks is a red flag

Slide 66

Slide 66 text

Use Task Configuration Avoidance https://docs.gradle.org/current/userguide/task_configuration_avoidance.html

Slide 67

Slide 67 text

Configuration time should be roughly 5s per 100 projects

Slide 68

Slide 68 text

Just released

Slide 69

Slide 69 text

File system watching https:///blog.gradle.org/introducing-file-system-watching

Slide 70

Slide 70 text

org.gradle.vfs.watch=true Easiest build speed improvement! gradle.properties

Slide 71

Slide 71 text

Faster input snapshotting

Slide 72

Slide 72 text

Jetifier performance improvements Released in AGP 4.1.0

Slide 73

Slide 73 text

Jetifier - please kill it

Slide 74

Slide 74 text

No content

Slide 75

Slide 75 text

Stuck on the Jetifier?

Slide 76

Slide 76 text

plugins { id "com.github.plnice.canidropjetifier" version "0.5" } Can I drop Jetifier? ./gradlew -Pandroid.enableJetifier=false canIDropJetifier

Slide 77

Slide 77 text

Jetify At Home ./jetifier-standalone -i -o https://developer.android.com/studio/command-line/jetifier

Slide 78

Slide 78 text

Jetify At Home Upload to nexus

Slide 79

Slide 79 text

Update Dependencies

Slide 80

Slide 80 text

No content

Slide 81

Slide 81 text

Update All The Things ⬢ Gradle 6.7 ⬢ Android Gradle Plugin 4.1.1 ⬢ Gradle Enterprise Plugin 3.5 ⬢ Kotlin 1.4.10 ⬢ Third party plugins ⬢ Third party libraries Stable File Watching Caching Improvements Task Configuration Avoidance Compressed scan upload Incremental Annotation Processors Fixes for caching bugs

Slide 82

Slide 82 text

Update All The Things plugins { id "com.github.ben-manes.versions" version "0.33.0" } ./gradlew dependencyUpdates -Drevision=release https://github.com/ben-manes/gradle-versions-plugin

Slide 83

Slide 83 text

No content

Slide 84

Slide 84 text

Let's talk caching

Slide 85

Slide 85 text

Local Cache and Remote Cache

Slide 86

Slide 86 text

https://docs.gradle.org/current/userguide/ build_cache.html https://gradle.com/training/build-cache-deep-dive

Slide 87

Slide 87 text

Scaling Android Builds in Pandemic Times Inaki Villar 3:00pm PST - Nov 17th https://www.online.droidcon.com/americas-speaker/inaki-villar

Slide 88

Slide 88 text

If a task has been run before, no need to re-run

Slide 89

Slide 89 text

Compilation, generation, packaging, tests

Slide 90

Slide 90 text

Fix cache misses

Slide 91

Slide 91 text

Gradle Enterprise

Slide 92

Slide 92 text

Public Gradle Enterprise instances • ge.gradle.org • ge.spring.io • ge.junit.org • ge.jetbrains.com

Slide 93

Slide 93 text

Task Input Comparison • https://ge.gradle.org/s/vmpk3ahkdvf34 • https://ge.gradle.org/c/xjsxszonlcuj6/vmpk3ahkdvf34/task-inputs? cacheability=cacheable&expanded=WyJsbTVwNjU1bWFqbGx5LWNsYXNzcGF0aCIsIjdlN mtzNWVidnRoeTYtY2xhc3NwYXRoIiwidDd4dDZjZ3d2d3ZqcS0kMSJd

Slide 94

Slide 94 text

Failure Analysis • https://ge.gradle.org/s/ryzmyn67iahnw

Slide 95

Slide 95 text

Flaky Test Analysis • https://ge.gradle.org/scans/tests? search.relativeStartTime=P7D&search.timeZoneId=Europe/ Zurich&tests.container=org.gradle.performance.regression.java.JavaUpToDatePerformanc eTest&tests.sortField=FAILED&tests.test=up-to- date%20assemble%20with%20local%20build%20cache%20enabled%20(parallel%20false) &tests.unstableOnly=true

Slide 96

Slide 96 text

Upcoming performance enhancements

Slide 97

Slide 97 text

Configuration Cache https://docs.gradle.org/current/userguide/configuration_cache.html

Slide 98

Slide 98 text

Kotlin 1.4.20 AGP 4.2.0 Full configuration caching support

Slide 99

Slide 99 text

Bugfixes to incremental Kotlin Compiler

Slide 100

Slide 100 text

Performance improvements when restoring from cache for incremental compile https://youtrack.jetbrains.com/issue/KT-34862

Slide 101

Slide 101 text

Gradle 6.8 Improvements https://docs.gradle.org/6.8-milestone-3/release-notes.html#performance-improvements

Slide 102

Slide 102 text

Faster kts build script compilation

Slide 103

Slide 103 text

Compile avoidance for kts build script compilation

Slide 104

Slide 104 text

Configuration cache for included builds

Slide 105

Slide 105 text

Future improvements in AGP and Gradle

Slide 106

Slide 106 text

Unbounded thread executor used for transformations https://github.com/gradle/gradle/pull/15025

Slide 107

Slide 107 text

Android Studio Sync improvements in 4.2.0

Slide 108

Slide 108 text

Empty Source Directory Cache misses

Slide 109

Slide 109 text

Empty Source Directory Cache miss

Slide 110

Slide 110 text

Empty Source Directory Cache misses Gary Hale

Slide 111

Slide 111 text

Ease of Use

Slide 112

Slide 112 text

Idiomatic Gradle

Slide 113

Slide 113 text

Upcoming usability improvements

Slide 114

Slide 114 text

Idiomatic Gradle Jendrik Johannes https:///github.com/jjohannes/idiomatic-gradle

Slide 115

Slide 115 text

Idiomatic Gradle ./gradlew my-awesome-library:compileTestJava ./gradlew mAL:cT Kebab case https:///docs.gradle.org/6.7/release-notes.html#other-new-features-and-usability-improvements

Slide 116

Slide 116 text

Idiomatic Gradle allProjects { repositories { mavenCentral() } } Central Repository Declaration https:///docs.gradle.org/6.8-milestone-3/release-notes.html#dependency-resolution-improvements

Slide 117

Slide 117 text

Idiomatic Gradle dependencyResolutionManagement { components { withModule('com.google.guava:guava', GuavaRule) } } Central Component Metadata Rules https:///docs.gradle.org/6.8-milestone-3/release-notes.html#dependency-resolution-improvements

Slide 118

Slide 118 text

Idiomatic Gradle ./gradlew :my-other-project:sub:foo Executing Tasks From Included Builds https:///docs.gradle.org/6.7/release-notes.html#other-new-features-and-usability-improvements

Slide 119

Slide 119 text

More Resources

Slide 120

Slide 120 text

Gradle Training https://gradle.com/training/ https://gradle.com/training/introduction-to-gradle https://gradle.com/training/build-cache-deep-dive

Slide 121

Slide 121 text

Gradle Community Slack https://gradle.com/slack-invite

Slide 122

Slide 122 text

Benchmarking Builds with the Gradle Profiler Tony Robalik https://dev.to/autonomousapps/benchmarking-builds-with-gradle- profiler-oa8

Slide 123

Slide 123 text

Understanding, Profiling, and Optimizing Gradle in Android Builds Nate Ebel https://goobar.io/understanding-profiling-and-optimizing-gradle-in- android-builds/

Slide 124

Slide 124 text

Improving Android Build Performance Devoxx Belgium 2018 Cédric Champeau https://www.youtube.com/watch?v=StahHZ-L83k https://speakerdeck.com/melix/improving-android-build-performance

Slide 125

Slide 125 text

Build Bigger, Better: Gradle for Large Projects Google I/O 2019 Aurimas Liutikas and Xavier Ducrohet https://www.youtube.com/watch?v=sQC9-Rj2yLI

Slide 126

Slide 126 text

Beyond Modularization - Scaling Android Builds Nelson Osacky https://vimeo.com/430648415 https://speakerdeck.com/runningcode/beyond-modularization-scaling- your-android-build-with-gradle

Slide 127

Slide 127 text

The Secrets of the Build Scan Plugin and the Internals of Gradle Virtual Android Makers Paris 2020 Me https://www.youtube.com/watch?v=lgaqS0pmUzk

Slide 128

Slide 128 text

Measuring remote build cache performance https://medium.com/@runningcode https://github.com/runningcode/gradle-doctor

Slide 129

Slide 129 text

Scaling Android Builds in Pandemic Times Inaki Villar 3:00pm PST - Nov 17th https://www.online.droidcon.com/americas-speaker/inaki-villar

Slide 130

Slide 130 text

Android Builds At Scale Zac Sweers, Chiu-Ki Chan, Israel Ferrero Camacho, John Rodriguez, Ivan Gavrilogic 1:10pm PST - Nov 17th https://www.online.droidcon.com/americas-panels-workshops

Slide 131

Slide 131 text

Thank you! Gradle Enterprise Trial osacky.com https://gradle.com/enterprise/trial/ https://speakerdeck.com/runningcode/perspectives-from-a-solutions-engineer https://go.gradle.com/solutions-engineer Gradle Solutions is hiring