Slide 1

Slide 1 text

Holly Cummins Devoxx Belgium Zero Waste, Radical Magic and Italian Graft Quarkus Efficiency Secrets

Slide 2

Slide 2 text

@holly_cummins Rust

Slide 3

Slide 3 text

@holly_cummins Rust

Slide 4

Slide 4 text

@holly_cummins Q: Is Rust efficient?

Slide 5

Slide 5 text

@holly_cummins Q: Is Rust efficient? A: Yes, very. Obviously.

Slide 6

Slide 6 text

@holly_cummins

Slide 7

Slide 7 text

@holly_cummins Rust is too hard to learn

Slide 8

Slide 8 text

@holly_cummins

Slide 9

Slide 9 text

@holly_cummins too difficult to be widely adopted

Slide 10

Slide 10 text

@holly_cummins

Slide 11

Slide 11 text

@holly_cummins approach with trepidation

Slide 12

Slide 12 text

@holly_cummins approach with trepidation notoriously difficult learning curve

Slide 13

Slide 13 text

@holly_cummins “Rust is the hardest programming language up to that time I’ve met.” -Michael Vaner https://vorner.github.io/difficult.html

Slide 14

Slide 14 text

@holly_cummins Rust has no garbage collection. (Sort of.)

Slide 15

Slide 15 text

@holly_cummins Rust has no garbage collection. (Sort of.) What happens if we give Rust GC?

Slide 16

Slide 16 text

@holly_cummins #RedHat

Slide 17

Slide 17 text

@holly_cummins #RedHat more likely to complete the task required only about a third as much time

Slide 18

Slide 18 text

@holly_cummins #RedHat Oh. Maybe Rust isn’t efficient.

Slide 19

Slide 19 text

@holly_cummins Rust human efficiency machine efficiency

Slide 20

Slide 20 text

@holly_cummins Rust human efficiency machine efficiency

Slide 21

Slide 21 text

@holly_cummins can we do better? #RedHat

Slide 22

Slide 22 text

@holly_cummins #RedHat can we do better?

Slide 23

Slide 23 text

@holly_cummins Enter … Quarkus. #RedHat A Java framework that gets you going faster, faster. can we do better?

Slide 24

Slide 24 text

Quarkus applications start fast Quarkus + graalvm 0.014 Seconds REST application Quarkus + open jdk 0.75 Seconds traditional cloud-native stack 4.3 Seconds https://Quarkus.io/blog/runtime-performance/

Slide 25

Slide 25 text

@holly_cummins machine Quarkus Quarkus Quarkus Quarkus Quarkus Quarkus Quarkus Quarkus Quarkus Quarkus Quarkus Quarkus Quarkus Quarkus container orchestration machine traditional cloud-native java stack traditional cloud-native java stack traditional cloud-native java stack traditional cloud-native java stack Quarkus applications have high deployment density. Quarkus native

Slide 26

Slide 26 text

@holly_cummins machine Quarkus Quarkus Quarkus Quarkus Quarkus Quarkus Quarkus Quarkus Quarkus Quarkus Quarkus Quarkus Quarkus Quarkus container orchestration machine traditional cloud-native java stack traditional cloud-native java stack traditional cloud-native java stack traditional cloud-native java stack Quarkus applications have high deployment density. Quarkus native (but Quarkus on JVM is also way smaller than traditional java)

Slide 27

Slide 27 text

@holly_cummins traditional cloud-native java stack traditional cloud-native java stack traditional cloud-native java stack traditional cloud-native java stack node.js node.js node.js node.js node.js node.js node.js go go machine go go go go go go go go go go go go go go go go go go go Quarkus Quarkus Quarkus Quarkus Quarkus Quarkus Quarkus Quarkus Quarkus Quarkus Quarkus Quarkus Quarkus Quarkus … and not just when comparing to other Java frameworks container orchestration machine machine machine https:/ /developers.redhat.com/blog/2017/03/14/java-inside-docker/

Slide 28

Slide 28 text

Let’s talk about throughput. https://www.redhat.com/en/resources/mi-quarkus-lab-validation-idc-analyst-paper 48 concurrent connections Traditional cloud native stack 3555 req/s

Slide 29

Slide 29 text

Let’s talk about throughput. quarkus native 3212 req/s https://www.redhat.com/en/resources/mi-quarkus-lab-validation-idc-analyst-paper 48 concurrent connections Traditional cloud native stack 3555 req/s

Slide 30

Slide 30 text

Let’s talk about throughput. quarkus native 3212 req/s https://www.redhat.com/en/resources/mi-quarkus-lab-validation-idc-analyst-paper a trade-off of throughput against footprint 48 concurrent connections Traditional cloud native stack 3555 req/s

Slide 31

Slide 31 text

@holly_cummins Native compilation trade-offs throughput startup time + footprint

Slide 32

Slide 32 text

@holly_cummins Native compilation trade-offs throughput startup time + footprint

Slide 33

Slide 33 text

but … traditional cloud native stack 3555 req/s quarkus native 3212 req/s https://www.redhat.com/en/resources/mi-quarkus-lab-validation-idc-analyst-paper a trade-off of throughput against footprint 48 concurrent connections

Slide 34

Slide 34 text

but … traditional cloud native stack 3555 req/s quarkus on jvm 6389 req/s quarkus native 3212 req/s https://www.redhat.com/en/resources/mi-quarkus-lab-validation-idc-analyst-paper a trade-off of throughput against footprint 48 concurrent connections

Slide 35

Slide 35 text

but … traditional cloud native stack 3555 req/s quarkus on jvm 6389 req/s quarkus native 3212 req/s https://www.redhat.com/en/resources/mi-quarkus-lab-validation-idc-analyst-paper no trade-off, just better :) a trade-off of throughput against footprint 48 concurrent connections

Slide 36

Slide 36 text

@holly_cummins we beat the trade-off. throughput startup time + footprint

Slide 37

Slide 37 text

@holly_cummins we beat the trade-off. throughput startup time + footprint

Slide 38

Slide 38 text

@holly_cummins we beat the trade-off. throughput startup time + footprint it’s a double-win.

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

@holly_cummins what’s the secret?

Slide 41

Slide 41 text

@holly_cummins what’s the secret? what are the secrets?

Slide 42

Slide 42 text

@holly_cummins Challenge assumptions. African wild ass

Slide 43

Slide 43 text

@holly_cummins Challenge assumptions. Challenge outdated assumptions. African wild ass

Slide 44

Slide 44 text

@holly_cummins ssssshhhhhhhh! it’s a secret! Don’t be dynamic.

Slide 45

Slide 45 text

@holly_cummins ssssshhhhhhhh! it’s a secret! Don’t be dynamic. (Wait, what??)

Slide 46

Slide 46 text

@holly_cummins #RedHat old Java frameworks were optimised for …

Slide 47

Slide 47 text

@holly_cummins #RedHat long-lived processes old Java frameworks were optimised for …

Slide 48

Slide 48 text

@holly_cummins #RedHat long-lived processes annual (!) deployments old Java frameworks were optimised for …

Slide 49

Slide 49 text

@holly_cummins #RedHat long-lived processes annual (!) deployments late-binding old Java frameworks were optimised for …

Slide 50

Slide 50 text

@holly_cummins #RedHat long-lived processes annual (!) deployments late-binding re-configurable without restart old Java frameworks were optimised for …

Slide 51

Slide 51 text

@holly_cummins #RedHat application frameworks were optimised for dynamism

Slide 52

Slide 52 text

@holly_cummins #RedHat application frameworks were optimised for dynamism dynamism has a cost

Slide 53

Slide 53 text

@holly_cummins #RedHat cloud apps are immutable now

Slide 54

Slide 54 text

@holly_cummins #RedHat cloud apps are immutable now

Slide 55

Slide 55 text

@holly_cummins #RedHat a highly dynamic runtime in a container is pointless

Slide 56

Slide 56 text

@holly_cummins Java dynamism

Slide 57

Slide 57 text

@holly_cummins Java dynamism build time

Slide 58

Slide 58 text

@holly_cummins Java dynamism build time runtime

Slide 59

Slide 59 text

@holly_cummins Java dynamism build time runtime

Slide 60

Slide 60 text

@holly_cummins Java dynamism packaging (maven, gradle…) build time runtime

Slide 61

Slide 61 text

@holly_cummins Java dynamism build time runtime

Slide 62

Slide 62 text

@holly_cummins Java dynamism build time runtime

Slide 63

Slide 63 text

@holly_cummins Java dynamism > build time runtime load and parse • config files • properties • yaml • xml • etc.

Slide 64

Slide 64 text

@holly_cummins Java dynamism > build time runtime

Slide 65

Slide 65 text

@holly_cummins Java dynamism @ @ > build time runtime • classpath scanning and annotation discovery • attempt to load class to enable/disable features

Slide 66

Slide 66 text

@holly_cummins Java dynamism @ @ > build time runtime

Slide 67

Slide 67 text

@holly_cummins Java dynamism @ @ > build time runtime build a metamodel of the world

Slide 68

Slide 68 text

@holly_cummins Java dynamism @ @ > build time runtime

Slide 69

Slide 69 text

@holly_cummins Java dynamism @ @ > build time runtime start • thread pools • I/O • etc.

Slide 70

Slide 70 text

@holly_cummins Java dynamism @ @ > build time runtime ready to do work!

Slide 71

Slide 71 text

@holly_cummins what if we start the application more than once? @ @ >

Slide 72

Slide 72 text

@holly_cummins what if we start the application more than once? @ @ > @ @ >

Slide 73

Slide 73 text

@holly_cummins what if we start the application more than once? @ @ > @ @ > @ @ >

Slide 74

Slide 74 text

@holly_cummins what if we start the application more than once? @ @ > @ @ > @ @ > @ @ >

Slide 75

Slide 75 text

@holly_cummins what if we start the application more than once? @ @ > @ @ > @ @ > @ @ >

Slide 76

Slide 76 text

@holly_cummins what if we start the application more than once? @ @ > @ @ > @ @ > @ @ > so much work gets redone every time

Slide 77

Slide 77 text

@holly_cummins Hibernate startup speed example: JTA auto-wiring

Slide 78

Slide 78 text

@holly_cummins Hibernate startup speed example: JTA auto-wiring Class.forName(“LikelyJTAImplementation”);

Slide 79

Slide 79 text

@holly_cummins Hibernate startup speed example: JTA auto-wiring Class.forName(“LikelyJTAImplementation”);

Slide 80

Slide 80 text

@holly_cummins Hibernate startup speed example: JTA auto-wiring Class.forName(“LikelyJTAImplementation”); Class.forName(“APossibleJTAImplementation”);

Slide 81

Slide 81 text

@holly_cummins Hibernate startup speed example: JTA auto-wiring Class.forName(“LikelyJTAImplementation”); Class.forName(“APossibleJTAImplementation”); Class.forName(“AnotherJTAImplementation”);

Slide 82

Slide 82 text

@holly_cummins Hibernate startup speed example: JTA auto-wiring Class.forName(“LikelyJTAImplementation”); Class.forName(“APossibleJTAImplementation”); Class.forName(“AnotherJTAImplementation”); …

Slide 83

Slide 83 text

@holly_cummins Hibernate startup speed example: JTA auto-wiring Class.forName(“LikelyJTAImplementation”); Class.forName(“APossibleJTAImplementation”); Class.forName(“AnotherJTAImplementation”); Class.forName(“NicheJTAImplementation”); …

Slide 84

Slide 84 text

@holly_cummins Hibernate startup speed example: JTA auto-wiring Class.forName(“LikelyJTAImplementation”); Class.forName(“APossibleJTAImplementation”); Class.forName(“AnotherJTAImplementation”); Class.forName(“NicheJTAImplementation”); Class.forName(“VeryNicheJTAImplementation”); …

Slide 85

Slide 85 text

@holly_cummins Hibernate startup speed example: JTA auto-wiring Class.forName(“LikelyJTAImplementation”); Class.forName(“APossibleJTAImplementation”); Class.forName(“AnotherJTAImplementation”); Class.forName(“NicheJTAImplementation”); Class.forName(“VeryNicheJTAImplementation”); …

Slide 86

Slide 86 text

@holly_cummins Hibernate startup speed example: JTA auto-wiring Class.forName(“LikelyJTAImplementation”); Class.forName(“APossibleJTAImplementation”); Class.forName(“AnotherJTAImplementation”); Class.forName(“NicheJTAImplementation”); Class.forName(“VeryNicheJTAImplementation”); … ~129 auto-wiring attempts

Slide 87

Slide 87 text

@holly_cummins Hibernate startup speed example: JTA auto-wiring Class.forName(“LikelyJTAImplementation”); Class.forName(“APossibleJTAImplementation”); Class.forName(“AnotherJTAImplementation”); Class.forName(“NicheJTAImplementation”); Class.forName(“VeryNicheJTAImplementation”); … ~129 auto-wiring attempts every single start.

Slide 88

Slide 88 text

@holly_cummins it’s not just JTA this happens for lots of internal service bindings

Slide 89

Slide 89 text

@holly_cummins JVM footprint example: Hibernate

Slide 90

Slide 90 text

@holly_cummins JVM spends time loading classes for specific databases JVM class for unused database class for unused database class for unused database class for unused database class for unused database class for unused database class for unused database class for unused database class for unused database class for unused database class for unused database class for unused database class for unused database class for unused database class for unused database class for unused database footprint example: Hibernate

Slide 91

Slide 91 text

@holly_cummins JVM spends time loading classes for specific databases JVM class for unused database class for unused database class for unused database class for unused database class for unused database class for unused database class for unused database class for unused database class for unused database class for unused database class for unused database class for unused database class for unused database class for unused database class for unused database class for unused database turns out they’re never used footprint example: Hibernate

Slide 92

Slide 92 text

@holly_cummins JVM spends time loading classes for specific databases JVM turns out they’re never used JIT spends time unloading classes footprint example: Hibernate

Slide 93

Slide 93 text

@holly_cummins Hibernate example: ~500 classes which are only useful if you're running an Oracle database loaded and then unloaded

Slide 94

Slide 94 text

@holly_cummins Hibernate example: ~500 classes which are only useful if you're running an Oracle database loaded and then unloaded every single start.

Slide 95

Slide 95 text

@holly_cummins the true cost of loaded classes isn’t just memory + start time

Slide 96

Slide 96 text

@holly_cummins the true cost of loaded classes isn’t just memory + start time method dispatching:

Slide 97

Slide 97 text

@holly_cummins interface the true cost of loaded classes isn’t just memory + start time method dispatching:

Slide 98

Slide 98 text

@holly_cummins unused implementation the one we want interface unused implementation unused implementation the true cost of loaded classes isn’t just memory + start time method dispatching:

Slide 99

Slide 99 text

@holly_cummins unused implementation the one we want interface unused implementation unused implementation the true cost of loaded classes isn’t just memory + start time method dispatching:

Slide 100

Slide 100 text

@holly_cummins unused implementation the one we want interface megamorphic call slow dispatching unused implementation unused implementation the true cost of loaded classes isn’t just memory + start time method dispatching:

Slide 101

Slide 101 text

@holly_cummins the true cost of loaded classes isn’t just memory + start time the one we want interface

Slide 102

Slide 102 text

@holly_cummins the true cost of loaded classes isn’t just memory + start time the one we want monomorphic call fast dispatching interface

Slide 103

Slide 103 text

@holly_cummins how do we fix all this?

Slide 104

Slide 104 text

@holly_cummins @ @ > build time runtime what if we initialize at build time?

Slide 105

Slide 105 text

@holly_cummins @ @ > build time runtime what if we initialize at build time?

Slide 106

Slide 106 text

@holly_cummins @ @ > build time runtime start • thread pools • I/O • etc. what if we initialize at build time?

Slide 107

Slide 107 text

@holly_cummins @ @ > build time runtime ready to do work! start • thread pools • I/O • etc. what if we initialize at build time?

Slide 108

Slide 108 text

@holly_cummins @ @ > repeated starts are now efficient

Slide 109

Slide 109 text

@holly_cummins @ @ > repeated starts are now efficient

Slide 110

Slide 110 text

@holly_cummins @ @ > repeated starts are now efficient

Slide 111

Slide 111 text

@holly_cummins @ @ > repeated starts are now efficient

Slide 112

Slide 112 text

@holly_cummins @ @ > repeated starts are now efficient

Slide 113

Slide 113 text

@holly_cummins @ @ > repeated starts are now efficient

Slide 114

Slide 114 text

@holly_cummins @ @ > repeated starts are now efficient less wasted work

Slide 115

Slide 115 text

@holly_cummins the Quarkus way enables native compilation native (graalvm) @ @ > jvm build time

Slide 116

Slide 116 text

@holly_cummins the Quarkus way enables native compilation native (graalvm) @ @ > jvm build time

Slide 117

Slide 117 text

@holly_cummins

Slide 118

Slide 118 text

@holly_cummins doing more up-front

Slide 119

Slide 119 text

@holly_cummins doing more up-front - speeds up start

Slide 120

Slide 120 text

@holly_cummins doing more up-front - speeds up start - shrinks memory footprint

Slide 121

Slide 121 text

@holly_cummins doing more up-front - speeds up start - shrinks memory footprint - improves throughput (!)

Slide 122

Slide 122 text

@holly_cummins implementation corollary: libraries must participate in the build process, not just the runtime process

Slide 123

Slide 123 text

@holly_cummins implementation corollary: libraries must participate in the build process, not just the runtime process you need an extensible build process

Slide 124

Slide 124 text

@holly_cummins ssssshhhhhhhh! it’s a secret! have the right plug-points, so the whole ecosystem can become faster

Slide 125

Slide 125 text

@holly_cummins build steps + build items extensible builds

Slide 126

Slide 126 text

@holly_cummins build steps + build items extensible builds any extension can make

Slide 127

Slide 127 text

@holly_cummins #Quarkus #RedHat

Slide 128

Slide 128 text

@holly_cummins #Quarkus #RedHat build steps

Slide 129

Slide 129 text

@holly_cummins #Quarkus #RedHat

Slide 130

Slide 130 text

@holly_cummins #Quarkus #RedHat build items

Slide 131

Slide 131 text

@holly_cummins #Quarkus #RedHat

Slide 132

Slide 132 text

@holly_cummins #Quarkus #RedHat framework automatically determines correct execution order and injects parameters

Slide 133

Slide 133 text

@holly_cummins #Quarkus #RedHat build items are communication mechanism between build steps framework automatically determines correct execution order and injects parameters

Slide 134

Slide 134 text

No content

Slide 135

Slide 135 text

@holly_cummins isn’t long compilation kind of terrible for developers? @ @ >

Slide 136

Slide 136 text

@holly_cummins isn’t long compilation kind of terrible for developers? not if you have live coding :) @ @ >

Slide 137

Slide 137 text

@holly_cummins framework works out required level of reload live coding

Slide 138

Slide 138 text

@holly_cummins file reload live coding

Slide 139

Slide 139 text

@holly_cummins file reload live coding SASS changes detected, will rebuild: [META-INF/ resources/public/stylesheets/live.scss] Files changed but restart not needed - notified extensions in: 0.043s

Slide 140

Slide 140 text

@holly_cummins file reload JVM agent reload live coding

Slide 141

Slide 141 text

@holly_cummins file reload JVM agent reload live coding Application restart not required, replacing classes via instrumentation Live reload performed via instrumentation, no restart needed, total time: 0.180s

Slide 142

Slide 142 text

@holly_cummins full restart file reload JVM agent reload live coding

Slide 143

Slide 143 text

@holly_cummins full restart file reload JVM agent reload live coding Restarting Quarkus due to changes in Application$RenardeRequest.class, Application.class, Application$ApplicationGlobals.class, Application$Templates.class. Live reload total time: 1.415s

Slide 144

Slide 144 text

@holly_cummins full restart file reload JVM agent reload not noticeable (Quarkus starts fast) live coding Restarting Quarkus due to changes in Application$RenardeRequest.class, Application.class, Application$ApplicationGlobals.class, Application$Templates.class. Live reload total time: 1.415s

Slide 145

Slide 145 text

@holly_cummins fast start enables live coding

Slide 146

Slide 146 text

@holly_cummins the most expensive resource: humans

Slide 147

Slide 147 text

@holly_cummins how to make people efficient

Slide 148

Slide 148 text

@holly_cummins how to make people efficient - make it hard to get wrong

Slide 149

Slide 149 text

@holly_cummins how to make people efficient - make it hard to get wrong - strong typing

Slide 150

Slide 150 text

@holly_cummins how to make people efficient - make it hard to get wrong - strong typing - garbage collection

Slide 151

Slide 151 text

@holly_cummins how to make people efficient - make it hard to get wrong - strong typing - garbage collection - give them a tight feedback loop

Slide 152

Slide 152 text

@holly_cummins how to make people efficient - make it hard to get wrong - strong typing - garbage collection - give them a tight feedback loop - for manual testing - for automated testing

Slide 153

Slide 153 text

@holly_cummins how to make people efficient - make it hard to get wrong - strong typing - garbage collection - give them a tight feedback loop - for manual testing - for automated testing - allow less typing

Slide 154

Slide 154 text

@holly_cummins how to make people efficient - make it hard to get wrong - strong typing - garbage collection - give them a tight feedback loop - for manual testing - for automated testing - allow less typing thank you, Java - strong typing - garbage collection

Slide 155

Slide 155 text

@holly_cummins how to make people efficient - make it hard to get wrong - strong typing - garbage collection - give them a tight feedback loop - for manual testing - for automated testing - allow less typing thank you, Java - strong typing - garbage collection we just covered this

Slide 156

Slide 156 text

@holly_cummins developer joy

Slide 157

Slide 157 text

@holly_cummins ssssshhhhhhhh! it’s a secret! index, index, index (and let your ecosystem use the index)

Slide 158

Slide 158 text

@holly_cummins most frameworks need to…

Slide 159

Slide 159 text

@holly_cummins most frameworks need to… -find all classes + interfaces + methods + fields annotated with @X

Slide 160

Slide 160 text

@holly_cummins most frameworks need to… -find all classes + interfaces + methods + fields annotated with @X -find all classes implementing or extending X

Slide 161

Slide 161 text

@holly_cummins most frameworks need to… -find all classes + interfaces + methods + fields annotated with @X -find all classes implementing or extending X Java doesn’t help us nothing in the reflection package does this

Slide 162

Slide 162 text

@holly_cummins Jandex

Slide 163

Slide 163 text

@holly_cummins Jandex “offline reflection”

Slide 164

Slide 164 text

@holly_cummins we have an index now what?

Slide 165

Slide 165 text

@holly_cummins challenge assumptions.

Slide 166

Slide 166 text

@holly_cummins challenge assumptions. what if developers didn’t have to … ?

Slide 167

Slide 167 text

@holly_cummins #RedHat package com.example; import org.jboss.logging.Logger; public class Thing { private static final Logger log = Logger.getLogger(Thing.class); public void doSomething() { log.info("It works!"); } } example: logging

Slide 168

Slide 168 text

@holly_cummins #RedHat package com.example; import org.jboss.logging.Logger; public class Thing { private static final Logger log = Logger.getLogger(Thing.class); public void doSomething() { log.info("It works!"); } } example: logging import io.quarkus.logging.Log; Log

Slide 169

Slide 169 text

@holly_cummins ssssshhhhhhhh! it’s a secret!

Slide 170

Slide 170 text

@holly_cummins ssssshhhhhhhh! it’s a secret! don’t make humans tell the computer what the computer already knows

Slide 171

Slide 171 text

@holly_cummins “but isn’t that dynamism expensive?”

Slide 172

Slide 172 text

@holly_cummins no. “but isn’t that dynamism expensive?”

Slide 173

Slide 173 text

@holly_cummins no. - use Jandex to find use-sites of the Log class “but isn’t that dynamism expensive?”

Slide 174

Slide 174 text

@holly_cummins no. - use Jandex to find use-sites of the Log class - inject a static logger field $logger “but isn’t that dynamism expensive?”

Slide 175

Slide 175 text

@holly_cummins no. - use Jandex to find use-sites of the Log class - inject a static logger field $logger - replace all calls of Log.method with calls to $logger.method “but isn’t that dynamism expensive?”

Slide 176

Slide 176 text

@holly_cummins no. - use Jandex to find use-sites of the Log class - inject a static logger field $logger - replace all calls of Log.method with calls to $logger.method … all at build time “but isn’t that dynamism expensive?”

Slide 177

Slide 177 text

@holly_cummins logging: compiled version public class MyService { // injected private static final Logger $logger = Logger.getLogger(Thing.class) public void doSomething() { $logger.info(“It works!”); } }

Slide 178

Slide 178 text

@holly_cummins what if… you could inherit boilerplate Hibernate queries from a superclass, instead of having to write them all? example: hibernate

Slide 179

Slide 179 text

@holly_cummins #RedHat @ApplicationScoped public class GreetingRepository { public Entity findByName(int name) { return find("name", name).firstResult(); } void persist(Entity entity) {} void delete(Entity entity) {} Entity findById(Id id) {} List list(String query, Sort sort, Object... params) { return null; } Stream stream(String query, Object... params) { return null; } long count() { return 0; } long count(String query, Object... params) { return 0; } } example: hibernate with panache

Slide 180

Slide 180 text

@holly_cummins #RedHat example: hibernate with panache @ApplicationScoped public class GreetingRepository implements PanacheRepository { public Entity findByName(int name) { return find("name", name).firstResult(); } }

Slide 181

Slide 181 text

@holly_cummins #RedHat DAO example: hibernate with panache @ApplicationScoped public class GreetingRepository implements PanacheRepository { public Entity findByName(int name) { return find("name", name).firstResult(); } } repository pattern

Slide 182

Slide 182 text

@holly_cummins #RedHat example: hibernate with panache

Slide 183

Slide 183 text

@holly_cummins #RedHat example: hibernate with panache active record pattern @Entity public class Greeting extends PanacheEntity { public String name; public LocalDate issued; @Version public int version; public static List getTodaysGreetings() { return list("date", LocalDate.now()); } }

Slide 184

Slide 184 text

@holly_cummins why was this even hard? public class PanacheEntity { public static List listAll() { // but… how do we know which entity to query? throw new UnobtainiumException(); } }

Slide 185

Slide 185 text

@holly_cummins why was this even hard? public class PanacheEntity { public static List listAll() { // but… how do we know which entity to query? throw new UnobtainiumException(); } } signature can be generic

Slide 186

Slide 186 text

@holly_cummins why was this even hard? public class PanacheEntity { public static List listAll() { // but… how do we know which entity to query? throw new UnobtainiumException(); } } implementation cannot be generic signature can be generic

Slide 187

Slide 187 text

@holly_cummins here’s what we do @Entity public class Order extends PanacheEntity { // … original class // injected in the bytecode // we add a Order.listAll method public static List listAll() { return DbOperations.listAll(Order.class); } }

Slide 188

Slide 188 text

@holly_cummins machine efficiency unlocked human efficiency we broke the tradeoff

Slide 189

Slide 189 text

@holly_cummins #RedHat but magic

Slide 190

Slide 190 text

@holly_cummins #RedHat magic should always be optional

Slide 191

Slide 191 text

@holly_cummins #RedHat doing less is efficient fighting bad magic is not efficient

Slide 192

Slide 192 text

@holly_cummins optimise for real use, not demo-ware real efficiency

Slide 193

Slide 193 text

@holly_cummins ssssshhhhhhhh! it’s a secret!

Slide 194

Slide 194 text

@holly_cummins ssssshhhhhhhh! it’s a secret! be reactive to go faster, but don’t make humans do reactive programming

Slide 195

Slide 195 text

@holly_cummins quarkus has a reactive core it’s well-hidden :)

Slide 196

Slide 196 text

@holly_cummins what is the common factor behind our performance improvements?

Slide 197

Slide 197 text

@holly_cummins developer-zero on Quarkus redesigned Hibernate to “boot in advance” what is the common factor behind our performance improvements?

Slide 198

Slide 198 text

@holly_cummins hyper-focussed performance engineer delivers big fixes to many open source Java projects what is the common factor behind our performance improvements?

Slide 199

Slide 199 text

@holly_cummins what is the common factor behind our performance improvements? working on neighbouring projects big improvement to efficiency of Jackson with virtual threads

Slide 200

Slide 200 text

@holly_cummins what is the common factor behind our performance improvements?

Slide 201

Slide 201 text

@holly_cummins what is the common factor behind our performance improvements?

Slide 202

Slide 202 text

@holly_cummins #RedHat A lot of clever people made Quarkus so efficient. Only some of them were Italian.

Slide 203

Slide 203 text

@holly_cummins #RedHat > 1000 clever people made Quarkus so efficient. Only some of them were Italian.

Slide 204

Slide 204 text

@holly_cummins #RedHat Emiliia Nesterovych Emmanuel Bernard Emre Kaplan Enrique gonzález Martínez Enrique Mingorance Cano Eoin Gallinagh Eric Deandrea Eric Wittmann Erik Åsén Erik Mattheis Erin Schnabel Eugene Berman Evan Shortiss Fabricio Gregorio faculbsz Falko Modler Fedor Dudinskiy Felipe Carvalho dos Anjos Formentin Felipe Henrique Gross Windmoller Fernando Comunello Fernando Henrique fhavel Fikru Mengesha Filippe Spolti Florian Beutel Florian Bütler Florian Heubeck Florin Botis Foivos Zakkak Foobartender Fouad Almalki Francesco Nigro Francisco Javier Tirado Sarti Francois Steyn Frank Eichfelder franz1981 freakse-sa Fred Bricon Frédérc Blanc Freeman Fang Fu Cheng Gabriele Cardosi Galder Zamarreño galiacheng Gavin King Gavin Ray Geert Schuring Geoffrey De Smet Geoffrey GREBERT Georg Leber George Gastaldi manofthepeace Manyanda Chitimbo Marat Gubaidullin Marc Nuri Marc Schlegel Marc Wrobel Marcel Hanser Marcel Lohmann Marcell Cruz Marcelo Pereira Marcin Czeczko Marcin Kłopotek Marco Bungart Marco Schaub Marco Yeung Marco Zanghì Marcus Paulo Marek goldmann Marek Skacelik Marián Macik Mario Fusco MarioHNogueira Mark Lambert Mark Little Mark McLaughlin Mark Sailes marko-bekhta Markus Heberling Markus Himmel Markus Schwer Martin C. Richards Martin Grammelspacher Martin Kouba Martin Muzikar Martin Panzer Martin Weiler martin-kofoed-jyskebank-dk MartinWitt Marvin B. Lillehaug masini Matej Novotny Matej Vasek Matheus Cruz Mathias Holzer Matteo Mortari Matthias Andreas Benkard Matthias Cullmann mauroal Max Andersen Max Gabrielsson Max Rydahl Andersen Victor Hugo de Oliveira Molinar Vincent Sevel Vincent van Dam Vinícius Ferraz Campos Florentino Viswa Teja Nariboina Vladimir Konkov Vojtech Juranek Vratislav Hais w.glanzer Walter Medvedeo Wayne Ellis Werner Glanzer Willem Jan Glerum William Antônio Siqueira Wim goeman Wippermueller, Frank wojciech.stryjewski Xavier Xieshen xstefank Y. Luis Yann-Thomas LE MOIGNE Yannick Reifschneider YassinHajaj Yelzhas Suleimenov yesunch9 Yoann Rodière Yoshikazu Nojima Youngmin Koo Yubao Liu yugoccp Yukihiro Okada Zaheed Beita zanmagerl zedbeit Zheng Feng Žiga Deisinger Zineb Bendhiba zohar Zoran Regvart Шумов Игорь Юрьевич 出 门 三不惹 > 1000 clever people made Quarkus so efficient. Only some of them were Italian.

Slide 205

Slide 205 text

@holly_cummins Ok, you don’t have to be Italian. But you do have to try really hard.

Slide 206

Slide 206 text

@holly_cummins this is not easy stuff Franz the problem

Slide 207

Slide 207 text

@holly_cummins

Slide 208

Slide 208 text

@holly_cummins profile shave

Slide 209

Slide 209 text

@holly_cummins profile shave shave profile

Slide 210

Slide 210 text

@holly_cummins profile shave shave profile shave profile

Slide 211

Slide 211 text

@holly_cummins profile shave shave profile shave profile shave profile

Slide 212

Slide 212 text

@holly_cummins profile shave shave profile shave profile shave profile shave profile

Slide 213

Slide 213 text

@holly_cummins profile shave shave profile shave profile shave profile shave profile shave profile

Slide 214

Slide 214 text

@holly_cummins “OAAS: obsession as a service” - Francesco Nigro

Slide 215

Slide 215 text

small number of cores Netty http handling example: type pollution

Slide 216

Slide 216 text

lots of cores Netty http handling example: type pollution

Slide 217

Slide 217 text

what’s going on here? lots of cores example: type pollution

Slide 218

Slide 218 text

@holly_cummins to find out, Francesco Nigro and Andrew Haley read 20,000 lines of ASM ASM

Slide 219

Slide 219 text

@holly_cummins if (a instanceof Thing) problematic pattern:

Slide 220

Slide 220 text

@holly_cummins if (a instanceof Thing) problematic pattern: !!

Slide 221

Slide 221 text

@holly_cummins if (a instanceof Thing) problematic pattern: affects : !!

Slide 222

Slide 222 text

@holly_cummins if (a instanceof Thing) – Quarkus core – Netty – Hibernate ORM – Hibernate Reactive – Vert.x – Smallrye Mutiny – Smallrye Common – Vert.x Web – Infinispan – Camel – Drools – Optaplanner – Java Class Library problematic pattern: affects : !!

Slide 223

Slide 223 text

@holly_cummins if (a instanceof Thing) – Quarkus core – Netty – Hibernate ORM – Hibernate Reactive – Vert.x – Smallrye Mutiny – Smallrye Common – Vert.x Web – Infinispan – Camel – Drools – Optaplanner – Java Class Library problematic pattern: affects : !! – Java Class Library!

Slide 224

Slide 224 text

@holly_cummins avoiding the problematic pattern sped Quarkus up a lot (in many-core case)

Slide 225

Slide 225 text

@holly_cummins #RedHat private static int extractSize(Object it) { if (it instanceof Collection) { return ((Collection>) it).size(); } else if (it instanceof Map) { return ((Map, ?>) it).size(); } else if (it.getClass().isArray()) { return Array.getLength(it); } else if (it instanceof Integer) { return ((Integer) it); } return 10; } slow on many-core systems

Slide 226

Slide 226 text

@holly_cummins #RedHat private static int extractSize(Object it) { if (it instanceof Collection) { return ((Collection>) it).size(); } else if (it instanceof Map) { return ((Map, ?>) it).size(); } else if (it.getClass().isArray()) { return Array.getLength(it); } else if (it instanceof Integer) { return ((Integer) it); } return 10; } // Note that we intentionally use "instanceof" to test interfaces as the last resort in order to mitigate the "type pollution” // See https://github.com/RedHatPerf/type-pollution-agent for more information if (it instanceof AbstractCollection) { return ((AbstractCollection>) it).size(); } else if (it instanceof AbstractMap) { return ((AbstractMap, ?>) it).size(); } else if (it instanceof Collection) { return ((Collection>) it).size(); } else if (it instanceof Map) { return ((Map, ?>) it).size(); } return 10; } slow on many-core systems 30% more throughput

Slide 227

Slide 227 text

@holly_cummins #RedHat private static int extractSize(Object it) { if (it instanceof Collection) { return ((Collection>) it).size(); } else if (it instanceof Map) { return ((Map, ?>) it).size(); } else if (it.getClass().isArray()) { return Array.getLength(it); } else if (it instanceof Integer) { return ((Integer) it); } return 10; } // Note that we intentionally use "instanceof" to test interfaces as the last resort in order to mitigate the "type pollution” // See https://github.com/RedHatPerf/type-pollution-agent for more information if (it instanceof AbstractCollection) { return ((AbstractCollection>) it).size(); } else if (it instanceof AbstractMap) { return ((AbstractMap, ?>) it).size(); } else if (it instanceof Collection) { return ((Collection>) it).size(); } else if (it instanceof Map) { return ((Map, ?>) it).size(); } return 10; } but …

Slide 228

Slide 228 text

@holly_cummins #RedHat private static int extractSize(Object it) { if (it instanceof Collection) { return ((Collection>) it).size(); } else if (it instanceof Map) { return ((Map, ?>) it).size(); } else if (it.getClass().isArray()) { return Array.getLength(it); } else if (it instanceof Integer) { return ((Integer) it); } return 10; } // Note that we intentionally use "instanceof" to test interfaces as the last resort in order to mitigate the "type pollution” // See https://github.com/RedHatPerf/type-pollution-agent for more information if (it instanceof AbstractCollection) { return ((AbstractCollection>) it).size(); } else if (it instanceof AbstractMap) { return ((AbstractMap, ?>) it).size(); } else if (it instanceof Collection) { return ((Collection>) it).size(); } else if (it instanceof Map) { return ((Map, ?>) it).size(); } return 10; } but …

Slide 229

Slide 229 text

@holly_cummins #RedHat private static int extractSize(Object it) { if (it instanceof Collection) { return ((Collection>) it).size(); } else if (it instanceof Map) { return ((Map, ?>) it).size(); } else if (it.getClass().isArray()) { return Array.getLength(it); } else if (it instanceof Integer) { return ((Integer) it); } return 10; } // Note that we intentionally use "instanceof" to test interfaces as the last resort in order to mitigate the "type pollution” // See https://github.com/RedHatPerf/type-pollution-agent for more information if (it instanceof AbstractCollection) { return ((AbstractCollection>) it).size(); } else if (it instanceof AbstractMap) { return ((AbstractMap, ?>) it).size(); } else if (it instanceof Collection) { return ((Collection>) it).size(); } else if (it instanceof Map) { return ((Map, ?>) it).size(); } return 10; } not a fan of the fix but …

Slide 230

Slide 230 text

@holly_cummins #RedHat private static int extractSize(Object it) { if (it instanceof Collection) { return ((Collection>) it).size(); } else if (it instanceof Map) { return ((Map, ?>) it).size(); } else if (it.getClass().isArray()) { return Array.getLength(it); } else if (it instanceof Integer) { return ((Integer) it); } return 10; } // Note that we intentionally use "instanceof" to test interfaces as the last resort in order to mitigate the "type pollution” // See https://github.com/RedHatPerf/type-pollution-agent for more information if (it instanceof AbstractCollection) { return ((AbstractCollection>) it).size(); } else if (it instanceof AbstractMap) { return ((AbstractMap, ?>) it).size(); } else if (it instanceof Collection) { return ((Collection>) it).size(); } else if (it instanceof Map) { return ((Map, ?>) it).size(); } return 10; } not a fan of the fix non-idiomatic but …

Slide 231

Slide 231 text

@holly_cummins #RedHat private static int extractSize(Object it) { if (it instanceof Collection) { return ((Collection>) it).size(); } else if (it instanceof Map) { return ((Map, ?>) it).size(); } else if (it.getClass().isArray()) { return Array.getLength(it); } else if (it instanceof Integer) { return ((Integer) it); } return 10; } // Note that we intentionally use "instanceof" to test interfaces as the last resort in order to mitigate the "type pollution” // See https://github.com/RedHatPerf/type-pollution-agent for more information if (it instanceof AbstractCollection) { return ((AbstractCollection>) it).size(); } else if (it instanceof AbstractMap) { return ((AbstractMap, ?>) it).size(); } else if (it instanceof Collection) { return ((Collection>) it).size(); } else if (it instanceof Map) { return ((Map, ?>) it).size(); } return 10; } not a fan of the fix non-idiomatic difficult to maintain but …

Slide 232

Slide 232 text

@holly_cummins #RedHat private static int extractSize(Object it) { if (it instanceof Collection) { return ((Collection>) it).size(); } else if (it instanceof Map) { return ((Map, ?>) it).size(); } else if (it.getClass().isArray()) { return Array.getLength(it); } else if (it instanceof Integer) { return ((Integer) it); } return 10; } // Note that we intentionally use "instanceof" to test interfaces as the last resort in order to mitigate the "type pollution” // See https://github.com/RedHatPerf/type-pollution-agent for more information if (it instanceof AbstractCollection) { return ((AbstractCollection>) it).size(); } else if (it instanceof AbstractMap) { return ((AbstractMap, ?>) it).size(); } else if (it instanceof Collection) { return ((Collection>) it).size(); } else if (it instanceof Map) { return ((Map, ?>) it).size(); } return 10; } not a fan of the fix non-idiomatic difficult to maintain machine efficiency my team’s efficiency but …

Slide 233

Slide 233 text

@holly_cummins #RedHat

Slide 234

Slide 234 text

@holly_cummins #RedHat the quarkus team write reactive code so you don’t have to

Slide 235

Slide 235 text

@holly_cummins #RedHat the quarkus team write reactive code so you don’t have to the quarkus team work around the type pollution bug so you don’t have to

Slide 236

Slide 236 text

@holly_cummins #RedHat efficiency isn’t a one-time activity beware creeping performance deterioration

Slide 237

Slide 237 text

@holly_cummins #RedHat a statistics story: how we missed regressions

Slide 238

Slide 238 text

@holly_cummins #RedHat a statistics story: how we missed regressions is performance getting better or worse here?

Slide 239

Slide 239 text

@holly_cummins #RedHat a statistics story: how we missed regressions is performance getting better or worse here?

Slide 240

Slide 240 text

@holly_cummins #RedHat a statistics story: how we missed regressions

Slide 241

Slide 241 text

@holly_cummins #RedHat a statistics story: how we missed regressions a parametric change-detection algorithm meant this big regression masked other, smaller, regressions

Slide 242

Slide 242 text

@holly_cummins #RedHat a story: how we fixed regressions

Slide 243

Slide 243 text

@holly_cummins #RedHat a story: how we fixed regressions Roberto undid two years of creep in one release

Slide 244

Slide 244 text

@holly_cummins #RedHat challenge assumptions

Slide 245

Slide 245 text

@holly_cummins #RedHat string comparison: who says you have to read strings left-to-right? challenge assumptions

Slide 246

Slide 246 text

@holly_cummins #RedHat string comparison: who says you have to read strings left-to-right? QUARKUS_REPEATED_PREFIX_FOO QUARKUS_REPEATED_PREFIX_BAR challenge assumptions

Slide 247

Slide 247 text

@holly_cummins #RedHat string comparison: who says you have to read strings left-to-right? QUARKUS_REPEATED_PREFIX_FOO QUARKUS_REPEATED_PREFIX_BAR challenge assumptions

Slide 248

Slide 248 text

@holly_cummins ssssshhhhhhhh! it’s a secret! invest in your own Francesco (being Italian is optional)

Slide 249

Slide 249 text

@holly_cummins one last trade-off

Slide 250

Slide 250 text

@holly_cummins sustainability saving planet doing stuff we want to do

Slide 251

Slide 251 text

@holly_cummins sustainability saving planet doing stuff we want to do

Slide 252

Slide 252 text

@holly_cummins the vrroooom model gives hope but …

Slide 253

Slide 253 text

@holly_cummins

Slide 254

Slide 254 text

@holly_cummins invented by Dr. Vroom (really!)

Slide 255

Slide 255 text

@holly_cummins naming is the hardest problem in computer science invented by Dr. Vroom (really!)

Slide 256

Slide 256 text

@holly_cummins naming is the hardest problem in computer science

Slide 257

Slide 257 text

@holly_cummins my vrroooom model

Slide 258

Slide 258 text

No content

Slide 259

Slide 259 text

@holly_cummins #RedHat

Slide 260

Slide 260 text

@holly_cummins #RedHat these two columns are almost the same

Slide 261

Slide 261 text

@holly_cummins #RedHat Energy 1 10 100 Time 1 10 100 energy efficiency across programming languages Python Rust Java Go

Slide 262

Slide 262 text

@holly_cummins #RedHat Energy 1 10 100 Time 1 10 100 the trend line is more or less straight energy efficiency across programming languages Python Rust Java Go

Slide 263

Slide 263 text

@holly_cummins #RedHat capacity Source: John O’Hara Setup: • REST + CRUD • large heap • RAPL energy measurement Assumptions: climate impact at low load (single instance) lower is better

Slide 264

Slide 264 text

@holly_cummins #RedHat capacity Source: John O’Hara Setup: • REST + CRUD • large heap • RAPL energy measurement Assumptions: climate impact at low load (single instance) line length shows max throughput lower is better

Slide 265

Slide 265 text

@holly_cummins #RedHat capacity Source: John O’Hara Setup: • REST + CRUD • large heap • RAPL energy measurement Assumptions: climate impact at low load (single instance) Quarkus on JVM has the lowest carbon … because it has the highest throughput line length shows max throughput lower is better

Slide 266

Slide 266 text

@holly_cummins #RedHat saving planet coding how we wanna code we beat the tradeoff

Slide 267

Slide 267 text

@holly_cummins #RedHat saving planet coding how we wanna code we beat the tradeoff

Slide 268

Slide 268 text

@holly_cummins machine efficiency helps us gain human efficiency

Slide 269

Slide 269 text

@holly_cummins efficient languages (too long; didn’t pay attention) tl;dpa

Slide 270

Slide 270 text

@holly_cummins efficient languages machine efficiency human efficiency (too long; didn’t pay attention) tl;dpa

Slide 271

Slide 271 text

@holly_cummins efficient languages machine efficiency human efficiency (too long; didn’t pay attention) tl;dpa challenge assumptions

Slide 272

Slide 272 text

@holly_cummins efficient languages machine efficiency human efficiency (too long; didn’t pay attention) tl;dpa challenge assumptions only do work once

Slide 273

Slide 273 text

@holly_cummins efficient languages machine efficiency human efficiency (too long; didn’t pay attention) tl;dpa challenge assumptions only do work once move work to where it hurts least

Slide 274

Slide 274 text

@holly_cummins efficient languages machine efficiency human efficiency (too long; didn’t pay attention) tl;dpa challenge assumptions only do work once move work to where it hurts least index, index, index

Slide 275

Slide 275 text

@holly_cummins efficient languages machine efficiency human efficiency (too long; didn’t pay attention) tl;dpa challenge assumptions only do work once move work to where it hurts least index, index, index efficiency needs continued investment

Slide 276

Slide 276 text

@holly_cummins efficient languages machine efficiency human efficiency (too long; didn’t pay attention) tl;dpa challenge assumptions challenge assumptions only do work once move work to where it hurts least index, index, index efficiency needs continued investment

Slide 277

Slide 277 text

@holly_cummins efficient languages machine efficiency human efficiency (too long; didn’t pay attention) tl;dpa challenge assumptions challenge assumptions tighten feedback loops only do work once move work to where it hurts least index, index, index efficiency needs continued investment

Slide 278

Slide 278 text

@holly_cummins efficient languages machine efficiency human efficiency (too long; didn’t pay attention) tl;dpa challenge assumptions challenge assumptions tighten feedback loops only do work once move work to where it hurts least index, index, index efficiency needs continued investment don’t make humans tell the computer what the computer already knows

Slide 279

Slide 279 text

@holly_cummins https://hollycummins.com/quarkus-efficiency-devoxx/ AND STICKERS