)

To make a cake you need to break some eggs

Max Rydahl Andersen
@maxandersen
redhat

The classic way

buildruntime 1

The classic way

buildruntime 2

The classic way

buildruntime 3

The classic way

buildruntime 4

The classic way

buildruntime 5

The Quarkus Way

buildruntime 6

Configuration can be changed at/after startup

brokenegg

Build and Runtime config

  • Reduce classes needed to load

  • Use Build time info to discard runtime need

  • Example: Only load Hibernate Dialects as needed, Don’t load configuration at runtime, …​

All Beans are available to lookup

brokenegg

Removal of Unused Beans

  • 1 bean = 3 generated classes

  • Big app with some unused beans = waste of time and memory

What are removed ?

Everything, except beans that…​:

  • …​are @Named

  • …​have an observer method (@Observes)

  • …​are annotated with @Unremovable

  • …​are excluded via quarkus.arc.unremovble-types config

  • …​are identified by Quarkus Extensions

Bean removal

  • Less classes loaded, faster startup, less memory used

  • Lookup using CDI.current() not detectable.

  • Solution:

    • Use @Unremovable or unremovable-types config

    • Turn removal off with: quarkus.arc.remove-unused-beans=false

static blocks run at startup

brokenegg

Static init at build time

  • Quarkus initializes all classes at build time = faster startup

  • You or some "bad" library might have static init

class MyClass {
    static Random random = new Random();
    ...
}

Static initialization solutions

  • Don’t do static init!

    • @Observes StartupEvent and @Startup bean

    • Lazy initialization

  • Write Quarkus Extension to handle it

Why inflict "pain" on users?

We went from 50(!) seconds startup with our previous used framework. To just 2-3 seconds with Quarkus in JVM mode and 15ms in native mode with GraalVM.
— Luis from Cap Gemini Spain

Get Used to it

  • Today it is hard as libraries assume runtime init of all statics

  • Quarkus give glimpse of future using GraalVM substitutions (raw speed!)

  • Expect Project Leyden or similar to introduce true static init in Java

Breaking Development Experience Eggs!

You have to restart your app to see changes

brokenegg

quarkus dev

  • A Special run mode

  • Can use full power and memory as dev need

  • Hot-reload on incoming requests

  • Change method, classes, packages, dependencies, …​

  • Restart in less time than you will notice

I have to setup my own testing infrastructure

brokenegg

Quarkus Dev Services

  • With quarkus dev services based on your classpath/extension list

  • But only IFF they are not configured

  • Evergrowing list of supported services

I have to write tests first

brokenegg

Continous Testing

  • Press 'r' in quarkus dev

  • or Run standalone

  • Smart continuous test execution

  • While you write code

Why quarkus dev ?

  • Developers actually get to use it!

Cracked eggs

  • Configuration can be changed at/after startup

  • All Beans are available to lookup

  • static blocks run at startup

  • I have to restart my app to see changes

  • I have to setup my own testing infrastructure

  • I have to write tests first

Conclusion

  • Quarkus is supersonic and subatomic Java

    • Developers get to have joy

    • Operations gets resources

    • Customers get what they need faster

  • Because we broke some eggs!