Slide 1

Slide 1 text

decide to write extension write extension share extension

Slide 2

Slide 2 text

decide to write extension write extension share extension

Slide 3

Slide 3 text

why? (in general)

Slide 4

Slide 4 text

reminder: what makes quarkus special

Slide 5

Slide 5 text

@holly_cummins Java dynamism

Slide 6

Slide 6 text

@holly_cummins Java dynamism build time

Slide 7

Slide 7 text

@holly_cummins Java dynamism build time runtime

Slide 8

Slide 8 text

@holly_cummins Java dynamism build time runtime

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

@holly_cummins Java dynamism build time runtime

Slide 11

Slide 11 text

@holly_cummins Java dynamism build time runtime

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

@holly_cummins Java dynamism > build time runtime

Slide 14

Slide 14 text

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

Slide 15

Slide 15 text

@holly_cummins Java dynamism @ @ > build time runtime

Slide 16

Slide 16 text

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

Slide 17

Slide 17 text

@holly_cummins Java dynamism @ @ > build time runtime

Slide 18

Slide 18 text

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

Slide 19

Slide 19 text

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

Slide 20

Slide 20 text

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

Slide 21

Slide 21 text

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

Slide 22

Slide 22 text

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

Slide 23

Slide 23 text

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

Slide 24

Slide 24 text

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

Slide 25

Slide 25 text

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

Slide 26

Slide 26 text

@holly_cummins how do we fix all this?

Slide 27

Slide 27 text

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

Slide 28

Slide 28 text

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

Slide 29

Slide 29 text

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

Slide 30

Slide 30 text

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

Slide 31

Slide 31 text

@holly_cummins @ @ > repeated starts are now efficient

Slide 32

Slide 32 text

@holly_cummins @ @ > repeated starts are now efficient

Slide 33

Slide 33 text

@holly_cummins @ @ > repeated starts are now efficient

Slide 34

Slide 34 text

@holly_cummins @ @ > repeated starts are now efficient

Slide 35

Slide 35 text

@holly_cummins @ @ > repeated starts are now efficient

Slide 36

Slide 36 text

@holly_cummins @ @ > repeated starts are now efficient

Slide 37

Slide 37 text

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

Slide 38

Slide 38 text

@holly_cummins

Slide 39

Slide 39 text

@holly_cummins doing more up-front

Slide 40

Slide 40 text

@holly_cummins doing more up-front - speeds up start

Slide 41

Slide 41 text

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

Slide 42

Slide 42 text

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

Slide 43

Slide 43 text

@holly_cummins but what about other libraries?

Slide 44

Slide 44 text

@holly_cummins but what about other libraries? @ @ >

Slide 45

Slide 45 text

@holly_cummins but what about other libraries? @ @ > @ @ >

Slide 46

Slide 46 text

@holly_cummins but what about other libraries? @ @ > @ @ > @ @ >

Slide 47

Slide 47 text

@holly_cummins but what about other libraries? @ @ > @ @ > @ @ >

Slide 48

Slide 48 text

@holly_cummins the quarkus build process is extensible what extensions do is participate in the build process

Slide 49

Slide 49 text

and another thing

Slide 50

Slide 50 text

and another thing

Slide 51

Slide 51 text

and another thing developer experience

Slide 52

Slide 52 text

and another thing developer experience developer joy

Slide 53

Slide 53 text

No content

Slide 54

Slide 54 text

dynamic-but-static

Slide 55

Slide 55 text

dynamic-but-static “wouldn’t it be nice if … … but it’s too expensive to do it at runtime.”

Slide 56

Slide 56 text

why? (for you)

Slide 57

Slide 57 text

why write a new extension? • the community hasn’t written one yet • it’s your library • support a use case particular to your environment

Slide 58

Slide 58 text

how?

Slide 59

Slide 59 text

decide to write extension write extension share extension

Slide 60

Slide 60 text

extension concept deployment + runtime

Slide 61

Slide 61 text

extension concept build phase + startup phase

Slide 62

Slide 62 text

Quarkus

Slide 63

Slide 63 text

Quarkus deployment

Slide 64

Slide 64 text

Quarkus deployment runtime

Slide 65

Slide 65 text

Quarkus deployment runtime

Slide 66

Slide 66 text

Quarkus deployment runtime bytecode

Slide 67

Slide 67 text

Quarkus deployment runtime bytecode extension

Slide 68

Slide 68 text

Quarkus deployment runtime bytecode extension deployment

Slide 69

Slide 69 text

Quarkus deployment runtime bytecode extension deployment runtime

Slide 70

Slide 70 text

Quarkus deployment runtime bytecode extension deployment runtime

Slide 71

Slide 71 text

Quarkus deployment runtime bytecode extension deployment runtime

Slide 72

Slide 72 text

Quarkus deployment runtime bytecode extension deployment runtime bytecode

Slide 73

Slide 73 text

extension concept build steps + build items

Slide 74

Slide 74 text

No content

Slide 75

Slide 75 text

build steps

Slide 76

Slide 76 text

No content

Slide 77

Slide 77 text

build items

Slide 78

Slide 78 text

No content

Slide 79

Slide 79 text

framework automatically determines correct execution order and injects parameters

Slide 80

Slide 80 text

build items are communication mechanism between build steps framework automatically determines correct execution order and injects parameters

Slide 81

Slide 81 text

initial state build items intermediate state build items terminal state build items

Slide 82

Slide 82 text

initial state build items JarResultBuildStep intermediate state build items terminal state build items

Slide 83

Slide 83 text

initial state build items JarResultBuildStep GeneratedResourceBuildItem intermediate state build items terminal state build items

Slide 84

Slide 84 text

initial state build items JarResultBuildStep GeneratedResourceBuildItem ConfigClassBuildItem intermediate state build items terminal state build items

Slide 85

Slide 85 text

initial state build items JarResultBuildStep GeneratedResourceBuildItem ConfigClassBuildItem UnremovableBeanBuildItem intermediate state build items terminal state build items

Slide 86

Slide 86 text

initial state build items JarResultBuildStep GeneratedResourceBuildItem ConfigClassBuildItem UnremovableBeanBuildItem BuildSystemTargetBuildItem intermediate state build items terminal state build items

Slide 87

Slide 87 text

initial state build items JarResultBuildStep GeneratedResourceBuildItem ConfigClassBuildItem UnremovableBeanBuildItem BuildSystemTargetBuildItem LaunchModeBuildItem intermediate state build items terminal state build items

Slide 88

Slide 88 text

initial state build items JarResultBuildStep GeneratedResourceBuildItem ConfigClassBuildItem UnremovableBeanBuildItem BuildSystemTargetBuildItem LaunchModeBuildItem most extensions do stuff here intermediate state build items terminal state build items

Slide 89

Slide 89 text

what kind of things can build items do? Create a servlet Create a route Pull an external bean into the closed world Turn one annotation into another Add a log handler Read an extra application archive Flag a capability as present Interact with Kubernetes Communicate between extensions! …

Slide 90

Slide 90 text

existing build items cover almost all needs like a library for extension writers but you can write your own too

Slide 91

Slide 91 text

No content

Slide 92

Slide 92 text

works in dev mode works in JVM works in native mode con fi guration provides a dev service supersonic performance joyful programming model dev UI codestart template maturity model for quarkus extensions

Slide 93

Slide 93 text

works in dev mode works in JVM works in native mode con fi guration provides a dev service supersonic performance joyful programming model dev UI codestart template maturity model for quarkus extensions

Slide 94

Slide 94 text

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

Slide 95

Slide 95 text

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

Slide 96

Slide 96 text

extension concept GraalVM ● Contribute GraalVM configuration ○ Reflection registration ○ Dynamic proxy registration ○ Resource files ○ Message bundles ○ Etc. ● Provide substitutions ○ Pieces of code that are used in place of regular library code when in native mode

Slide 97

Slide 97 text

Substitutions @TargetClass(org.infinispan.client.hotrod.impl.RemoteCacheImpl.class) public final class SubstituteRemoteCacheImpl { @Delete private ObjectName mbeanObjectName; @Substitute private void registerMBean(ObjectName jmxParent) { } @Substitute private void unregisterMBean() { } @Delete public void init(OperationsFactory operationsFactory, Configuration configuration, ObjectName jmxParent) { } }

Slide 98

Slide 98 text

works in dev mode works in JVM works in native mode con fi guration provides a dev service supersonic performance joyful programming model dev UI codestart template maturity model for quarkus extensions

Slide 99

Slide 99 text

works in dev mode works in JVM works in native mode con fi guration provides a dev service supersonic performance joyful programming model dev UI codestart template examples: configuration

Slide 100

Slide 100 text

Quarkus

Slide 101

Slide 101 text

Quarkus deployment

Slide 102

Slide 102 text

Quarkus deployment runtime

Slide 103

Slide 103 text

Quarkus deployment runtime extension

Slide 104

Slide 104 text

Quarkus deployment runtime extension deployment

Slide 105

Slide 105 text

Quarkus deployment runtime extension deployment runtime

Slide 106

Slide 106 text

Quarkus deployment runtime extension deployment runtime config config

Slide 107

Slide 107 text

Quarkus deployment runtime extension deployment runtime config config config config

Slide 108

Slide 108 text

Quarkus deployment runtime extension deployment runtime config config config config

Slide 109

Slide 109 text

demo https://github.com/holly-cummins/quarkus-minecraft-observability-extension

Slide 110

Slide 110 text

works in dev mode works in JVM works in native mode con fi guration provides a dev service supersonic performance joyful programming model dev UI codestart template examples: dev service

Slide 111

Slide 111 text

demo https://github.com/holly-cummins/quarkus-minecraft-observability-extension

Slide 112

Slide 112 text

works in dev mode works in JVM works in native mode con fi guration provides a dev service supersonic performance joyful programming model dev UI codestart template examples: dev ui

Slide 113

Slide 113 text

Uses JBoss log consumer which pipes output from dev container to a tab in the dev service

Slide 114

Slide 114 text

works in dev mode works in JVM works in native mode con fi guration provides a dev service supersonic performance joyful programming model dev UI codestart template examples: joyful programming model

Slide 115

Slide 115 text

extension concept index

Slide 116

Slide 116 text

extension concept index

Slide 117

Slide 117 text

extension concept index “offline-reflection”

Slide 118

Slide 118 text

extension concept index jandex “offline-reflection”

Slide 119

Slide 119 text

extension concept index jandex “offline-reflection” eliminates need for runtime classpath scanning

Slide 120

Slide 120 text

open world closed world

Slide 121

Slide 121 text

open world closed world hard to build-time optimise

Slide 122

Slide 122 text

open world closed world hard to build-time optimise easy to build-time optimise

Slide 123

Slide 123 text

open world closed world hard to build-time optimise easy to build-time optimise runtime class surprise!

Slide 124

Slide 124 text

open world closed world hard to build-time optimise easy to build-time optimise runtime class surprise!

Slide 125

Slide 125 text

open world closed world hard to build-time optimise easy to build-time optimise no worries runtime class surprise!

Slide 126

Slide 126 text

open world closed world hard to build-time optimise easy to build-time optimise no worries runtime class surprise!

Slide 127

Slide 127 text

open world closed world hard to build-time optimise easy to build-time optimise uh oh, this is outside our closed world no worries runtime class surprise!

Slide 128

Slide 128 text

AdditionalBeanBuildItem

Slide 129

Slide 129 text

AdditionalBeanBuildItem

Slide 130

Slide 130 text

extension concept bytecode recording easier than writing ASM

Slide 131

Slide 131 text

extension concept gizmo when you don’t want to ASM… … but bytecode recording isn’t enough

Slide 132

Slide 132 text

persistence.xml hibernate extension

Slide 133

Slide 133 text

persistence.xml hibernate extension the hibernate extension makes this go away

Slide 134

Slide 134 text

works in dev mode works in JVM works in native mode con fi guration provides a dev service supersonic performance joyful programming model dev UI codestart template examples: supersonic subatomic performance

Slide 135

Slide 135 text

deployment

Slide 136

Slide 136 text

understand app deployment

Slide 137

Slide 137 text

understand app eliminate reflection deployment

Slide 138

Slide 138 text

understand app eliminate reflection convert annotations to bytecode deployment

Slide 139

Slide 139 text

understand app eliminate reflection convert annotations to bytecode optimize deployment

Slide 140

Slide 140 text

@holly_cummins Hibernate speed example: JTA auto-wiring

Slide 141

Slide 141 text

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

Slide 142

Slide 142 text

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

Slide 143

Slide 143 text

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

Slide 144

Slide 144 text

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

Slide 145

Slide 145 text

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

Slide 146

Slide 146 text

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

Slide 147

Slide 147 text

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

Slide 148

Slide 148 text

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

Slide 149

Slide 149 text

@holly_cummins Hibernate 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 150

Slide 150 text

@holly_cummins Hibernate 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 151

Slide 151 text

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

Slide 152

Slide 152 text

@holly_cummins JVM footprint example: Hibernate

Slide 153

Slide 153 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 154

Slide 154 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 155

Slide 155 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 156

Slide 156 text

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

Slide 157

Slide 157 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 158

Slide 158 text

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

Slide 159

Slide 159 text

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

Slide 160

Slide 160 text

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

Slide 161

Slide 161 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 162

Slide 162 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 163

Slide 163 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 164

Slide 164 text

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

Slide 165

Slide 165 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 166

Slide 166 text

decide to write extension write extension share extension

Slide 167

Slide 167 text

No content

Slide 168

Slide 168 text

No content

Slide 169

Slide 169 text

No content