Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Tradeoffs, Bad Science, and Polar Bears – The World of Java Optimisation

Tradeoffs, Bad Science, and Polar Bears – The World of Java Optimisation

Welcome to the Java optimisation jungle. Why can’t we “just make it go faster”? It turns out, in most cases, we need to first work out “faster for whom?” and “why do we want to go faster?” and “what even is faster?” This talk introduces the basic principles of optimisation, before bouncing through the pitfalls of optimisation; why the exact same techniques which make Quarkus rocket-fast used to be a terrible idea fifteen years ago, why fast benchmarks make for slow programs, why project loom may not be the speedup you’re hoping for, and why even though it can be easy to get wrong, optimisation really really matters. Along the way we’ll talk about measuring things, bad advice, garbage collection, and climate change.

Holly Cummins

October 04, 2023
Tweet

More Decks by Holly Cummins

Other Decks in Programming

Transcript

  1. tradeoffs, bad science, and polar bears:


    the world of java optimisation


    Holly Cummins


    Red Hat




    Devoxx Belgium


    October 5, 2023


    View Slide

  2. #Quarkus @[email protected]
    why optimise?

    View Slide

  3. #Quarkus @[email protected]
    why optimise?

    View Slide

  4. #Quarkus @[email protected]
    why optimise?
    0.5s extra search
    page time

    View Slide

  5. #Quarkus @[email protected]
    why optimise?
    0.5s extra search
    page time
    20% drop in
    traffic

    View Slide

  6. #Quarkus @[email protected]
    why optimise?
    0.5s extra search
    page time
    20% drop in
    traffic
    100 ms latency on page
    load

    View Slide

  7. #Quarkus @[email protected]
    why optimise?
    0.5s extra search
    page time
    20% drop in
    traffic
    100 ms latency on page
    load
    7% lower
    conversion rate

    View Slide

  8. #Quarkus @[email protected]
    why optimise?
    0.5s extra search
    page time
    20% drop in
    traffic
    100 ms latency on page
    load
    7% lower
    conversion rate

    View Slide

  9. #Quarkus @[email protected]
    why optimise?
    0.5s extra search
    page time
    20% drop in
    traffic
    10 ms delay in trading
    platform
    100 ms latency on page
    load
    7% lower
    conversion rate

    View Slide

  10. #Quarkus @[email protected]
    why optimise?
    0.5s extra search
    page time
    20% drop in
    traffic
    10 ms delay in trading
    platform
    10% drop in
    revenue
    100 ms latency on page
    load
    7% lower
    conversion rate

    View Slide

  11. #Quarkus @holly_cummins
    what is optimising?

    View Slide

  12. #Quarkus @[email protected]
    for whom?


    when?


    doing what?
    “make it go faster”

    View Slide

  13. #Quarkus @holly_cummins

    View Slide

  14. #Quarkus @holly_cummins
    performance can be:

    View Slide

  15. #Quarkus @holly_cummins
    performance can be:
    throughput

    View Slide

  16. #Quarkus @holly_cummins
    performance can be:
    throughput
    transactions
    per second

    View Slide

  17. #Quarkus @holly_cummins
    performance can be:
    throughput
    latency
    transactions
    per second

    View Slide

  18. #Quarkus @holly_cummins
    performance can be:
    throughput
    latency
    transactions
    per second
    start-up
    time

    View Slide

  19. #Quarkus @holly_cummins
    performance can be:
    throughput
    latency
    transactions
    per second
    response
    time
    start-up
    time

    View Slide

  20. #Quarkus @holly_cummins
    performance can be:
    throughput
    latency
    ramp-up
    time
    transactions
    per second
    response
    time
    start-up
    time

    View Slide

  21. #Quarkus @holly_cummins
    performance can be:
    throughput
    latency
    capacity
    ramp-up
    time
    transactions
    per second
    response
    time
    start-up
    time

    View Slide

  22. #Quarkus @holly_cummins
    performance can be:
    throughput
    latency
    capacity
    ramp-up
    time
    transactions
    per second
    response
    time
    start-up
    time
    bandwidth

    View Slide

  23. #Quarkus @holly_cummins
    performance can be:
    throughput
    latency
    capacity
    ramp-up
    time
    transactions
    per second
    response
    time
    start-up
    time
    footprint
    bandwidth

    View Slide

  24. #Quarkus @holly_cummins
    performance can be:
    throughput
    latency
    capacity
    ramp-up
    time
    transactions
    per second
    response
    time
    start-up
    time
    CPU usage
    footprint
    bandwidth

    View Slide

  25. #Quarkus @holly_cummins
    performance can be:
    throughput
    latency
    capacity
    utilisation
    ramp-up
    time
    transactions
    per second
    response
    time
    start-up
    time
    CPU usage
    footprint
    bandwidth

    View Slide

  26. #Quarkus @holly_cummins
    performance can be:
    throughput
    latency
    capacity
    utilisation

    ramp-up
    time
    transactions
    per second
    response
    time
    start-up
    time
    CPU usage
    footprint
    bandwidth

    View Slide

  27. #Quarkus @holly_cummins
    performance can be:
    throughput
    latency
    capacity
    utilisation

    ramp-up
    time
    transactions
    per second
    response
    time
    start-up
    time
    CPU usage
    footprint
    bandwidth

    View Slide

  28. #Quarkus @[email protected]
    Never underestimate the bandwidth [throughput] of a
    station wagon full of tapes hurtling down the highway.


    –Andrew Tanenbaum, 1981

    View Slide

  29. #Quarkus @[email protected]
    Never underestimate the bandwidth [throughput] of a
    station wagon full of tapes hurtling down the highway.


    –Andrew Tanenbaum, 1981
    but the latency is terrible …


    View Slide

  30. @holly_cummins
    requirements change

    View Slide

  31. @holly_cummins

    View Slide

  32. @holly_cummins

    View Slide

  33. @holly_cummins

    View Slide

  34. @holly_cummins

    View Slide

  35. @holly_cummins
    I am not
    designed for this.

    View Slide

  36. @holly_cummins
    the world changes

    View Slide

  37. #Quarkus @[email protected]

    View Slide

  38. #Quarkus @[email protected]
    -Xmx == $

    View Slide

  39. #Quarkus @[email protected]
    -Xmx == $
    footprint

    View Slide

  40. #Quarkus @[email protected]

    View Slide

  41. #Quarkus @[email protected]
    which performs better?

    View Slide

  42. #Quarkus @[email protected]
    quarkus + graalvm
    trading-off flexibility + throughput
    against startup speed and footprint

    View Slide

  43. #Quarkus @[email protected]
    quarkus + graalvm
    trading-off flexibility + throughput
    against startup speed and footprint
    uhh … are you supposed
    to shut down applications
    after using them?

    View Slide

  44. #Quarkus @[email protected]
    aside: quarkus + jvm

    View Slide

  45. #Quarkus @[email protected]
    aside: quarkus + jvm
    better startup time

    View Slide

  46. #Quarkus @[email protected]
    aside: quarkus + jvm
    better startup time
    better footprint

    View Slide

  47. #Quarkus @[email protected]
    aside: quarkus + jvm
    better startup time
    better footprint
    better throughput

    View Slide

  48. #Quarkus @[email protected]
    aside: quarkus + jvm
    better startup time
    better footprint
    better throughput
    better developer experience

    View Slide

  49. #Quarkus @[email protected]
    aside: quarkus + jvm
    better startup time
    better footprint
    better throughput
    better developer experience

    View Slide

  50. #Quarkus @[email protected]
    aside: quarkus + jvm
    better startup time
    better footprint
    better throughput
    better developer experience
    there is no tradeoff

    View Slide

  51. #Quarkus @[email protected]
    aside: quarkus + jvm
    better startup time
    better footprint
    better throughput
    better developer experience
    there is no tradeoff
    (only elimination of waste)

    View Slide

  52. #Quarkus @[email protected]
    aside: quarkus + jvm
    better startup time
    better footprint
    better throughput
    better developer experience
    there is no tradeoff
    (only elimination of waste)
    ok, there is a tradeoff: not optimising for dynamism nobody needs in the cloud

    View Slide

  53. #Quarkus @[email protected]
    “waste”


    a trade-off where only one side has value

    View Slide

  54. #Quarkus @holly_cummins
    recap:


    which is “faster?”

    View Slide

  55. #Quarkus @holly_cummins
    GraalVM
    Quarkus
    Application
    recap:


    which is “faster?”

    View Slide

  56. #Quarkus @holly_cummins
    OpenJDK GraalVM
    Quarkus Quarkus
    Application Application
    recap:


    which is “faster?”

    View Slide

  57. #Quarkus @holly_cummins
    ephemeral or serverless
    OpenJDK GraalVM
    Quarkus Quarkus
    Application Application
    recap:


    which is “faster?”

    View Slide

  58. #Quarkus @holly_cummins
    ephemeral or serverless
    OpenJDK GraalVM
    Quarkus Quarkus
    Application Application
    running your application
    for a long time
    recap:


    which is “faster?”

    View Slide

  59. #Quarkus @holly_cummins
    ephemeral or serverless
    OpenJDK GraalVM
    Quarkus Quarkus
    Application Application
    running your application
    for a long time
    recap:


    which is “faster?”

    View Slide

  60. @holly_cummins
    requirements aren’t
    what we think they are

    View Slide

  61. #Quarkus @[email protected]
    behaviour at idle

    View Slide

  62. #Quarkus @[email protected]
    “optimise for
    being unused”
    behaviour at idle

    View Slide

  63. #Quarkus @[email protected]
    “optimise for
    being unused”
    useless
    behaviour at idle

    View Slide

  64. #Quarkus @[email protected]
    30%


    of VMs are zombies
    antithesisgroup.com

    View Slide

  65. #Quarkus @holly_cummins
    how to optimise?

    View Slide

  66. #Quarkus @[email protected]
    find the bottleneck.
    fix it.

    View Slide

  67. #IBM @holly_cummins
    what could possibly go wrong?!

    View Slide

  68. #RedHat @holly_cummins
    intuition
    pitfall 1

    View Slide

  69. #Quarkus @[email protected]
    this is not the place for ideas

    View Slide

  70. #Quarkus @[email protected]
    measure, don’t guess.

    View Slide

  71. #Quarkus @[email protected]
    measure the right thing

    View Slide

  72. #Quarkus @[email protected]
    measure the right thing
    what do your users care about?

    View Slide

  73. #RedHat @holly_cummins
    numbers
    pitfall 2
    (The McNamara Fallacy)

    View Slide

  74. #Quarkus @[email protected]

    View Slide

  75. #Quarkus @[email protected]
    leading indicators

    View Slide

  76. #Quarkus @[email protected]
    leading indicators lagging indicators

    View Slide

  77. #Quarkus @[email protected]
    leading indicators
    we care about them
    lagging indicators

    View Slide

  78. #Quarkus @[email protected]
    leading indicators
    we care about them
    easy to measure
    lagging indicators

    View Slide

  79. #Quarkus @[email protected]
    leading indicators
    we care about them
    easy to measure
    hard to change
    lagging indicators

    View Slide

  80. #Quarkus @[email protected]
    leading indicators
    we care about them
    easy to measure
    hard to change
    lagging indicators
    easy to change

    View Slide

  81. #Quarkus @[email protected]
    leading indicators
    we care about them
    easy to measure
    hard to change
    lagging indicators
    predictive of a thing we care about
    easy to change

    View Slide

  82. #Quarkus @[email protected]
    leading indicators
    we care about them
    easy to measure
    hard to change
    lagging indicators
    predictive of a thing we care about
    hard to identify
    easy to change

    View Slide

  83. #Quarkus @[email protected]
    leading indicators
    we care about them
    easy to measure
    hard to change
    lagging indicators
    predictive of a thing we care about
    hard to identify
    easy to change

    View Slide

  84. #Quarkus @[email protected]
    caution:


    performance experiments for entertainment purposes only.


    do not try these at home.

    View Slide

  85. #Quarkus @[email protected]
    2007

    View Slide

  86. #Quarkus @[email protected]
    bad-ish advice: “reduce time spent in garbage collection”

    View Slide

  87. #Quarkus @[email protected]
    bad-ish advice: “reduce time spent in garbage collection”
    actually, garbage collection can make your application go faster

    View Slide

  88. #Quarkus @[email protected]
    2007

    View Slide

  89. #Quarkus @[email protected]
    2007
    compacting every time


    gc overhead is huge

    View Slide

  90. #Quarkus @[email protected]
    2007
    compacting every time


    gc overhead is huge

    View Slide

  91. #Quarkus @[email protected]
    2007
    compacting every time


    gc overhead is huge
    throughput is … better?!

    View Slide

  92. #Quarkus @[email protected]
    2021

    View Slide

  93. #Quarkus @[email protected]
    2021

    View Slide

  94. #Quarkus @[email protected]
    -verbose:gc
    -Xverbosegclog:gclog.xml
    -Xcompactgc

    View Slide

  95. #Quarkus @[email protected]
    -verbose:gc
    -Xverbosegclog:gclog.xml
    -Xgcpolicy:optthruput
    -Xcompactgc

    View Slide

  96. #Quarkus @[email protected]
    -verbose:gc
    -Xverbosegclog:gclog.xml
    -Xgcpolicy:optthruput
    -Xmx110m
    -Xms110m
    -Xnocompactgc

    View Slide

  97. #Quarkus @[email protected]
    -verbose:gc
    -Xverbosegclog:gclog.xml
    -Xgcpolicy:optthruput
    -Xmx160m
    -Xms160m
    -Xnocompactgc

    View Slide

  98. #Quarkus @[email protected]
    -verbose:gc
    -Xverbosegclog:gclog.xml
    -Xgcpolicy:optthruput
    -Xmx300m
    -Xms300m
    -Xcompactgc
    why does the
    performance stay exactly the
    same no matter what gc
    settings I choose?

    View Slide

  99. #Quarkus @[email protected]
    by the way, this is cheating.
    (remember the ‘bad science’?)

    View Slide

  100. #Quarkus @[email protected]
    -verbose:gc
    -Xverbosegclog:gclog.xml
    -Xgcpolicy:optthruput

    View Slide

  101. #Quarkus @[email protected]
    -verbose:gc
    -Xverbosegclog:gclog.xml
    -Xgcpolicy:optthruput
    tool: GCMV

    View Slide

  102. #Quarkus @[email protected]
    -verbose:gc
    -Xverbosegclog:gclog.xml
    -Xgcpolicy:optthruput
    total GC time: 21.6s
    tool: GCMV

    View Slide

  103. #Quarkus @[email protected]
    -verbose:gc
    -Xverbosegclog:gclog.xml
    -Xgcpolicy:optthruput
    total GC time: 21.6s
    4.1% of time in GC pause
    tool: GCMV

    View Slide

  104. #Quarkus @[email protected]
    -verbose:gc
    -Xverbosegclog:gclog.xml
    -Xgcpolicy:optthruput
    total GC time: 21.6s
    4.1% of time in GC pause
    total GC time: 12.0s
    tool: GCMV

    View Slide

  105. #Quarkus @[email protected]
    -verbose:gc
    -Xverbosegclog:gclog.xml
    -Xgcpolicy:optthruput
    total GC time: 21.6s
    4.1% of time in GC pause
    total GC time: 12.0s
    3.6% of time in GC pause
    tool: GCMV

    View Slide

  106. #Quarkus @[email protected]
    -verbose:gc
    -Xverbosegclog:gclog.xml
    -Xgcpolicy:optthruput
    total GC time: 21.6s
    4.1% of time in GC pause
    23.9 GB garbage collected
    total GC time: 12.0s
    3.6% of time in GC pause
    13.0 GB garbage collected
    tool: GCMV

    View Slide

  107. #Quarkus @[email protected]
    -verbose:gc
    -Xverbosegclog:gclog.xml
    -Xgcpolicy:optthruput
    total GC time: 21.6s
    4.1% of time in GC pause
    23.9 GB garbage collected
    493 transactions/s
    total GC time: 12.0s
    3.6% of time in GC pause
    13.0 GB garbage collected
    260 transactions/s
    tool: GCMV

    View Slide

  108. #Quarkus @[email protected]
    -verbose:gc
    -Xverbosegclog:gclog.xml
    -Xgcpolicy:optthruput
    total GC time: 21.6s
    4.1% of time in GC pause
    23.9 GB garbage collected
    493 transactions/s
    total GC time: 12.0s
    3.6% of time in GC pause
    13.0 GB garbage collected
    260 transactions/s
    tool: GCMV

    View Slide

  109. #Quarkus @[email protected]
    -verbose:gc
    -Xverbosegclog:gclog.xml
    -Xgcpolicy:optthruput
    total GC time: 21.6s
    4.1% of time in GC pause
    23.9 GB garbage collected
    493 transactions/s
    total GC time: 12.0s
    3.6% of time in GC pause
    13.0 GB garbage collected
    260 transactions/s
    tool: GCMV

    View Slide

  110. #Quarkus @holly_cummins
    total GC time: 21.6s
    4.1% of time in GC pause
    23.9 GB garbage collected
    493 transactions/s
    total GC time: 12.0s
    3.6% of time in GC pause
    13.0 GB garbage collected
    260 transactions/s

    View Slide

  111. #Quarkus @holly_cummins
    total GC time: 21.6s
    4.1% of time in GC pause
    23.9 GB garbage collected
    493 transactions/s
    total GC time: 12.0s
    3.6% of time in GC pause
    13.0 GB garbage collected
    260 transactions/s

    View Slide

  112. #Quarkus @holly_cummins
    total GC time: 21.6s
    4.1% of time in GC pause
    23.9 GB garbage collected
    493 transactions/s
    total GC time: 12.0s
    3.6% of time in GC pause
    13.0 GB garbage collected
    260 transactions/s
    leading indicator

    View Slide

  113. #Quarkus @holly_cummins
    total GC time: 21.6s
    4.1% of time in GC pause
    23.9 GB garbage collected
    493 transactions/s
    total GC time: 12.0s
    3.6% of time in GC pause
    13.0 GB garbage collected
    260 transactions/s
    leading indicator

    View Slide

  114. #Quarkus @holly_cummins
    total GC time: 21.6s
    4.1% of time in GC pause
    23.9 GB garbage collected
    493 transactions/s
    total GC time: 12.0s
    3.6% of time in GC pause
    13.0 GB garbage collected
    260 transactions/s
    leading indicator
    lagging indicator

    View Slide

  115. #Quarkus @holly_cummins
    total GC time: 21.6s
    4.1% of time in GC pause
    23.9 GB garbage collected
    493 transactions/s
    total GC time: 12.0s
    3.6% of time in GC pause
    13.0 GB garbage collected
    260 transactions/s
    leading indicator
    lagging indicator
    ?

    View Slide

  116. #Quarkus @holly_cummins
    total GC time: 21.6s
    4.1% of time in GC pause
    23.9 GB garbage collected
    493 transactions/s
    total GC time: 12.0s
    3.6% of time in GC pause
    13.0 GB garbage collected
    260 transactions/s
    leading indicator
    lagging indicator
    ?
    ?

    View Slide

  117. #Quarkus @[email protected]
    so wait, what changed to make the app faster?
    running jmeter on the same machine as the app gives a big speedup!

    View Slide

  118. #Quarkus @[email protected]
    “Any improvements made anywhere
    besides the bottleneck are an illusion.”


    – Gene Kim

    View Slide

  119. #Quarkus @[email protected]
    time kills all performance advice
    (even mine)

    View Slide

  120. #Quarkus @[email protected]
    zgc Brian Goetz, yesterday

    View Slide

  121. #Quarkus @[email protected]
    zgc Brian Goetz, yesterday

    View Slide

  122. #Quarkus @[email protected]
    zgc Brian Goetz, yesterday

    View Slide

  123. #Quarkus @[email protected]
    zgc Brian Goetz, yesterday

    View Slide

  124. #Quarkus @[email protected]
    zgc Brian Goetz, yesterday
    tradeoff: throughput
    is ~2% lower

    View Slide

  125. #Quarkus @[email protected]
    zgc Brian Goetz, yesterday
    tradeoff: throughput
    is ~2% lower
    tradeoff: memory is
    higher

    View Slide

  126. #Quarkus @[email protected]
    zgc Brian Goetz, yesterday
    tradeoff: throughput
    is ~2% lower
    tradeoff: memory is
    higher
    java 21 adds generational zgc


    reduces zgc footprint by 75%

    View Slide

  127. #Quarkus @[email protected]
    the takeaways:


    gc can improve performance by rearranging the heap


    find the bottleneck


    validate advice independently


    optimise the right thing … for you

    View Slide

  128. #RedHat @holly_cummins
    advice
    pitfall 3

    View Slide

  129. #Quarkus @[email protected]
    I read it on the
    internet!

    View Slide

  130. #IBM @holly_cummins
    noooooo!
    “make one big method because method dispatching is slow”

    View Slide

  131. #IBM @holly_cummins
    noooooo!
    “re-use your objects to help the garbage collector”

    View Slide

  132. #IBM @holly_cummins
    noooooo!
    “to tune your JVM, use this command-line:”


    -server -Xms1g -Xmx1g -XX:PermSize=1g -XX:MaxPermSize=256m -Xmn256m
    -Xss64k -XX:SurvivorRatio=30 -XX:+UseConcMarkSweepGC -XX:
    +CMSParallelRemarkEnabled -XX:+UseCMSInitiatingOccupancyOnly
    -XX:CMSInitiatingOccupancyFraction=10 -XX:+ScavengeBeforeFullGC -XX:
    +CMSScavengeBeforeRemark -XX:+PrintGCDateStamps -verbose:gc -XX:
    +PrintGCDetails -Dsun.net.inetaddr.ttl=5 -XX:+HeapDumpOnOutOfMemoryError
    -XX:HeapDumpPath=`date`.hprof -Dcom.sun.management.jmxremote.port=5616
    -Dcom.sun.management.jmxremote.authenticate=false
    -Dcom.sun.management.jmxremote.ssl=false -server -Xms2g -Xmx2g
    -XX:MaxPermSize=256m -XX:NewRatio=1 -XX:+UseConcMarkSweepGC

    View Slide

  133. #IBM @holly_cummins
    noooooo!
    use StringBuilder, never concatenate strings with +=

    View Slide

  134. #IBM @holly_cummins
    noooooo!
    use StringBuilder, never concatenate strings with +=
    wait, what?


    yes, right?

    View Slide

  135. #Quarkus @[email protected]
    remember, measure, don’t guess.

    View Slide

  136. #Quarkus @[email protected]
    2 things ruin advice:


    • context


    • time

    View Slide

  137. #RedHat @holly_cummins
    micro-optimisation theatre
    pitfall 4

    View Slide

  138. #Quarkus @[email protected]
    static string beSlow()
    {
    string result = "";
    for (int i = 0; i < 314159; i++)
    {
    result += getStringData(i);
    }
    return result;
    }

    View Slide

  139. #Quarkus @[email protected]
    @Override
    public String toString() {
    String ret = "\n\tMarket Summary at: " + getSummaryDate() + “\n\t\t TSIA:" + getTSIA() + “\n\t\t openTSIA:" + getOpenTSIA()
    + “\n\t\t gain:" + getGainPercent() + “\n\t\t volume:" + getVolume();
    if ((getTopGainers() == null) || (getTopLosers() == null)) {
    return ret;
    }
    ret += "\n\t\t Current Top Gainers:";
    Iterator it = getTopGainers().iterator();
    while (it.hasNext()) {
    QuoteDataBean quoteData = it.next();
    ret += ("\n\t\t\t" + quoteData.toString());
    }
    ret += "\n\t\t Current Top Losers:";
    it = getTopLosers().iterator();
    while (it.hasNext()) {
    QuoteDataBean quoteData = it.next();
    ret += ("\n\t\t\t" + quoteData.toString());
    }
    return ret;
    }

    View Slide

  140. #Quarkus @[email protected]
    @Override
    public String toString() {
    String ret = "\n\tMarket Summary at: " + getSummaryDate() + “\n\t\t TSIA:" + getTSIA() + “\n\t\t openTSIA:" + getOpenTSIA()
    + “\n\t\t gain:" + getGainPercent() + “\n\t\t volume:" + getVolume();
    if ((getTopGainers() == null) || (getTopLosers() == null)) {
    return ret;
    }
    ret += "\n\t\t Current Top Gainers:";
    Iterator it = getTopGainers().iterator();
    while (it.hasNext()) {
    QuoteDataBean quoteData = it.next();
    ret += ("\n\t\t\t" + quoteData.toString());
    }
    ret += "\n\t\t Current Top Losers:";
    it = getTopLosers().iterator();
    while (it.hasNext()) {
    QuoteDataBean quoteData = it.next();
    ret += ("\n\t\t\t" + quoteData.toString());
    }
    return ret;
    }

    View Slide

  141. #Quarkus @[email protected]
    @Override
    public String toString() {
    String ret = "\n\tMarket Summary at: " + getSummaryDate() + “\n\t\t TSIA:" + getTSIA() + “\n\t\t openTSIA:" + getOpenTSIA()
    + “\n\t\t gain:" + getGainPercent() + “\n\t\t volume:" + getVolume();
    if ((getTopGainers() == null) || (getTopLosers() == null)) {
    return ret;
    }
    ret += "\n\t\t Current Top Gainers:";
    Iterator it = getTopGainers().iterator();
    while (it.hasNext()) {
    QuoteDataBean quoteData = it.next();
    ret += ("\n\t\t\t" + quoteData.toString());
    }
    ret += "\n\t\t Current Top Losers:";
    it = getTopLosers().iterator();
    while (it.hasNext()) {
    QuoteDataBean quoteData = it.next();
    ret += ("\n\t\t\t" + quoteData.toString());
    }
    return ret;
    }

    View Slide

  142. #Quarkus @[email protected]
    @Override
    public String toString() {
    String ret = "\n\tMarket Summary at: " + getSummaryDate() + “\n\t\t TSIA:" + getTSIA() + “\n\t\t openTSIA:" + getOpenTSIA()
    + “\n\t\t gain:" + getGainPercent() + “\n\t\t volume:" + getVolume();
    if ((getTopGainers() == null) || (getTopLosers() == null)) {
    return ret;
    }
    ret += "\n\t\t Current Top Gainers:";
    Iterator it = getTopGainers().iterator();
    while (it.hasNext()) {
    QuoteDataBean quoteData = it.next();
    ret += ("\n\t\t\t" + quoteData.toString());
    }
    ret += "\n\t\t Current Top Losers:";
    it = getTopLosers().iterator();
    while (it.hasNext()) {
    QuoteDataBean quoteData = it.next();
    ret += ("\n\t\t\t" + quoteData.toString());
    }
    return ret;
    }
    this never gets called

    View Slide

  143. #Quarkus @[email protected]
    let’s make my travel energy-efficient

    View Slide

  144. #Quarkus @[email protected]
    every little helps?

    View Slide

  145. #Quarkus @[email protected]
    every little helps?
    every optimisation is another optimisation you aren’t doing

    View Slide

  146. #Quarkus @[email protected]
    our platforms help

    View Slide

  147. #Quarkus @[email protected]
    static string beSlow()
    {
    string result = "";
    for (int i = 0; i < 314159; i++)
    {
    result += getStringData(i);
    }
    return result;
    }

    View Slide

  148. #Quarkus @[email protected]
    static string beSlow()
    {
    string result = “”;
    result += getStringData(1);
    result += getStringData(2);
    result += getStringData(3);
    return result;
    }

    View Slide

  149. #Quarkus @[email protected]
    static string beSlow()
    {
    string result = “”;
    result += getStringData(1);
    result += getStringData(2);
    result += getStringData(3);
    return result;
    }
    this is fine

    View Slide

  150. #Quarkus @[email protected]
    the JVM writers have far more time for optimising than you do
    clean, typical, code runs best

    View Slide

  151. #Quarkus @[email protected]
    but …

    View Slide

  152. #Quarkus @[email protected]
    why did the quarkus 2.0.0 codebase use stringbuilder so much?
    but …

    View Slide

  153. #Quarkus @[email protected]
    why did the quarkus 2.0.0 codebase use stringbuilder so much?
    remember, the outside world can change
    but …

    View Slide

  154. #Quarkus @[email protected]
    remember, measure, don’t guess.

    View Slide

  155. #RedHat @holly_cummins
    the shiny stuff
    pitfall 5

    View Slide

  156. #Quarkus @[email protected]
    loom

    View Slide

  157. #Quarkus @[email protected]
    loom
    very good at waiting

    View Slide

  158. #Quarkus @[email protected]
    loom
    very good at waiting
    not so good at cpu-bound
    tasks

    View Slide

  159. #Quarkus @[email protected]
    loom
    very good at waiting
    not so good at cpu-bound
    tasks
    can interact badly with libraries

    View Slide

  160. #Quarkus @[email protected]
    loom
    very good at waiting
    not so good at cpu-bound
    tasks
    can interact badly with libraries
    if a virtual thread gets pinned or
    does a long cpu process all its
    friends grind to a halt

    View Slide

  161. #Quarkus @[email protected]
    is thread management
    really your bottleneck?
    loom is not a magic “faster thread”


    View Slide

  162. #Quarkus @[email protected]
    remember, measure, don’t guess.


    View Slide

  163. #Quarkus @[email protected]
    remember, measure, don’t guess.


    -Djdk.tracePinnedThreads

    View Slide

  164. #Quarkus @[email protected]
    remember, measure, don’t guess.


    -Djdk.tracePinnedThreads
    @ShouldNotPin (in quarkus tests)

    View Slide

  165. #Quarkus @[email protected]
    remember, measure, don’t guess.


    -Djdk.tracePinnedThreads
    @ShouldNotPin (in quarkus tests)

    View Slide

  166. #Quarkus @[email protected]
    learn more

    View Slide

  167. #Quarkus @holly_cummins
    ok, but how to optimise?

    View Slide

  168. #Quarkus @[email protected]
    tools

    View Slide

  169. #Quarkus @[email protected]
    “What you can optimize is limited to what
    you can observe.”


    -Susie Xia, Netflix

    View Slide

  170. #Quarkus @[email protected]
    observability

    View Slide

  171. #Quarkus @[email protected]
    * not free


    this is an incomplete list, because there are a lot of tools out there, and many cost money

    View Slide

  172. #Quarkus @[email protected]
    method profiler
    * not free


    this is an incomplete list, because there are a lot of tools out there, and many cost money

    View Slide

  173. #Quarkus @[email protected]
    method profiler
    VisualVM
    * not free


    this is an incomplete list, because there are a lot of tools out there, and many cost money

    View Slide

  174. #Quarkus @[email protected]
    method profiler
    Mission Control
    VisualVM
    * not free


    this is an incomplete list, because there are a lot of tools out there, and many cost money

    View Slide

  175. #Quarkus @[email protected]
    method profiler
    Mission Control
    VisualVM
    * not free


    this is an incomplete list, because there are a lot of tools out there, and many cost money
    IntelliJ Profiler

    View Slide

  176. #Quarkus @[email protected]
    method profiler
    Mission Control
    VisualVM
    * not free


    this is an incomplete list, because there are a lot of tools out there, and many cost money
    IBM Health Center
    (for OpenJ9)
    IntelliJ Profiler

    View Slide

  177. #Quarkus @[email protected]
    method profiler
    Mission Control
    flame graphs
    VisualVM
    * not free


    this is an incomplete list, because there are a lot of tools out there, and many cost money
    IBM Health Center
    (for OpenJ9)
    IntelliJ Profiler

    View Slide

  178. #Quarkus @[email protected]
    method profiler
    GC analysis
    Mission Control
    flame graphs
    VisualVM
    * not free


    this is an incomplete list, because there are a lot of tools out there, and many cost money
    IBM Health Center
    (for OpenJ9)
    IntelliJ Profiler

    View Slide

  179. #Quarkus @[email protected]
    method profiler
    GC analysis
    Mission Control
    flame graphs
    GCMV
    VisualVM
    * not free


    this is an incomplete list, because there are a lot of tools out there, and many cost money
    IBM Health Center
    (for OpenJ9)
    IntelliJ Profiler

    View Slide

  180. #Quarkus @[email protected]
    method profiler
    GC analysis
    heap analysis
    Mission Control
    flame graphs
    GCMV
    VisualVM
    * not free


    this is an incomplete list, because there are a lot of tools out there, and many cost money
    IBM Health Center
    (for OpenJ9)
    IntelliJ Profiler

    View Slide

  181. #Quarkus @[email protected]
    method profiler
    GC analysis
    heap analysis
    Mission Control
    flame graphs
    GCMV
    VisualVM
    Eclipse MAT
    * not free


    this is an incomplete list, because there are a lot of tools out there, and many cost money
    IBM Health Center
    (for OpenJ9)
    IntelliJ Profiler

    View Slide

  182. #Quarkus @[email protected]
    method profiler
    GC analysis
    heap analysis
    APM
    Mission Control
    flame graphs
    GCMV
    VisualVM
    Eclipse MAT
    * not free


    this is an incomplete list, because there are a lot of tools out there, and many cost money
    IBM Health Center
    (for OpenJ9)
    IntelliJ Profiler

    View Slide

  183. #Quarkus @[email protected]
    method profiler
    GC analysis
    heap analysis
    APM
    Mission Control
    flame graphs
    GCMV
    VisualVM
    Eclipse MAT
    * not free


    this is an incomplete list, because there are a lot of tools out there, and many cost money
    GlowRoot
    IBM Health Center
    (for OpenJ9)
    IntelliJ Profiler

    View Slide

  184. #Quarkus @[email protected]
    method profiler
    GC analysis
    heap analysis
    APM
    Mission Control
    flame graphs
    GCMV
    New Relic*
    VisualVM
    Eclipse MAT
    * not free


    this is an incomplete list, because there are a lot of tools out there, and many cost money
    GlowRoot
    IBM Health Center
    (for OpenJ9)
    IntelliJ Profiler

    View Slide

  185. #Quarkus @[email protected]
    method profiler
    GC analysis
    heap analysis
    APM
    Mission Control
    flame graphs
    GCMV
    New Relic*
    AppDynamics*
    VisualVM
    Eclipse MAT
    * not free


    this is an incomplete list, because there are a lot of tools out there, and many cost money
    GlowRoot
    IBM Health Center
    (for OpenJ9)
    IntelliJ Profiler

    View Slide

  186. #Quarkus @[email protected]
    method profiler
    GC analysis
    heap analysis
    APM
    Mission Control
    flame graphs
    GCMV
    New Relic*
    AppDynamics*
    VisualVM
    Dynatrace*
    Eclipse MAT
    * not free


    this is an incomplete list, because there are a lot of tools out there, and many cost money
    GlowRoot
    IBM Health Center
    (for OpenJ9)
    IntelliJ Profiler

    View Slide

  187. #Quarkus @[email protected]
    method profiler
    GC analysis
    heap analysis
    APM
    Mission Control
    flame graphs
    GCMV
    New Relic*
    AppDynamics*
    VisualVM
    Dynatrace*
    Eclipse MAT
    * not free


    this is an incomplete list, because there are a lot of tools out there, and many cost money
    GlowRoot
    IBM Health Center
    (for OpenJ9)
    IntelliJ Profiler

    View Slide

  188. #Quarkus @[email protected]
    method profiler


    View Slide

  189. #Quarkus @[email protected]
    method profiler


    View Slide

  190. #Quarkus @[email protected]
    method profiler


    View Slide

  191. #Quarkus @[email protected]
    method profiler


    View Slide

  192. #Quarkus @[email protected]
    method profiler


    Open Telemetry

    View Slide

  193. @holly_cummins
    you may need to know the whole system
    context to know what to optimise

    View Slide

  194. #Quarkus @[email protected]
    “Nines don’t matter if your
    users aren’t happy.”


    – Charity Majors

    View Slide

  195. #Quarkus @[email protected]
    don’t forget the edges
    queueing theory helps us understand
    where the disasters happen

    View Slide

  196. #Quarkus @[email protected]
    “When it comes to IT performance, amateurs look
    at averages. Professionals look at distributions.”


    – Avishai Ish-Shalom

    View Slide

  197. #Quarkus @[email protected]
    slow performance can turn into big cloud bills
    make cloud costs visible to engineers

    View Slide

  198. #Quarkus @holly_cummins
    ok, but you promised bears

    View Slide

  199. #Quarkus @[email protected]
    if you leave the TV on when
    you’re not using it, you’re a
    polar bear murderer

    View Slide

  200. #Quarkus @[email protected]
    data centres use 1-2% of
    the world’s electricity

    View Slide

  201. #Quarkus @[email protected]
    performance optimisation is carbon optimisation

    View Slide

  202. #Quarkus @[email protected]
    cost: leading indicator for carbon


    performance: leading indicator for carbon

    View Slide

  203. #Quarkus @[email protected]
    example:


    what our quarkus experiments showed

    View Slide

  204. @holly_cummins #RedHat
    Source: Clement Escoffier
    cost impact of framework choice
    Setup:


    • 800 requests/second, over 20 days


    • SLA > 99%


    • AWS instances


    Assumptions:


    • Costs are for us-east-1 data centre

    View Slide

  205. @holly_cummins #RedHat
    Setup:


    • 800 requests/second, over 20 days


    • SLA > 99%


    Assumptions:


    • 50% load


    • us-east-1 data centre


    • Teads dataset
    Source: Clement Escoffier x Teads
    cloud carbon impact of framework choice
    carbon impact of framework choice

    View Slide

  206. @holly_cummins #RedHat
    Setup:


    • 800 requests/second, over 20 days


    • SLA > 99%


    Assumptions:


    • 50% load


    • us-east-1 data centre


    • Teads dataset
    Source: Clement Escoffier x Teads
    cloud carbon impact of framework choice
    carbon impact of framework choice
    economic model in action:


    the cost and carbon metrics are
    (roughly) the same

    View Slide

  207. @holly_cummins #RedHat
    capacity
    Source: John O’Hara
    Setup:


    • REST + CRUD


    • large heap


    • RAPL energy measurement


    Assumptions:


    • US energy mix
    climate impact of framework choice

    View Slide

  208. @holly_cummins #RedHat
    capacity
    Source: John O’Hara
    Setup:


    • REST + CRUD


    • large heap


    • RAPL energy measurement


    Assumptions:


    • US energy mix
    climate impact of framework choice
    shorter line means
    lower max throughput

    View Slide

  209. @holly_cummins #RedHat
    capacity
    Source: John O’Hara
    Setup:


    • REST + CRUD


    • large heap


    • RAPL energy measurement


    Assumptions:


    • US energy mix
    climate impact of framework choice
    shorter line means
    lower max throughput
    higher line means worse
    carbon footprint

    View Slide

  210. @holly_cummins #RedHat
    capacity
    Source: John O’Hara
    Setup:


    • REST + CRUD


    • large heap


    • RAPL energy measurement


    Assumptions:


    • US energy mix
    climate impact of framework choice
    vrrrooom model in action:


    quarkus on JVM has the smallest footprint …
    because it has the highest throughput
    shorter line means
    lower max throughput
    higher line means worse
    carbon footprint

    View Slide

  211. #Quarkus @[email protected]

    View Slide

  212. #Quarkus @[email protected]
    we should not waste


    • electricity


    • hardware

    View Slide

  213. #Quarkus @[email protected]
    good performance makes us good.
    we should not waste


    • electricity


    • hardware

    View Slide

  214. #Quarkus @[email protected]
    sooo …


    you can optimise, and it can be fun


    measure, don’t guess


    only optimise what matters
    @holly_cummins
    #Quarkus Slides

    View Slide