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 full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  5. #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 full-size slide

  6. #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 full-size slide

  7. #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 full-size slide

  8. #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 full-size slide

  9. #Quarkus @holly_cummins
    what is optimising?

    View full-size slide

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


    when?


    doing what?
    “make it go faster”

    View full-size slide

  11. #Quarkus @holly_cummins

    View full-size slide

  12. #Quarkus @holly_cummins
    performance can be:

    View full-size slide

  13. #Quarkus @holly_cummins
    performance can be:
    throughput

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  22. #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 full-size slide

  23. #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 full-size slide

  24. #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 full-size 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 full-size slide

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


    –Andrew Tanenbaum, 1981

    View full-size slide

  27. #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 full-size slide

  28. @holly_cummins
    requirements change

    View full-size slide

  29. @holly_cummins

    View full-size slide

  30. @holly_cummins

    View full-size slide

  31. @holly_cummins

    View full-size slide

  32. @holly_cummins

    View full-size slide

  33. @holly_cummins
    I am not
    designed for this.

    View full-size slide

  34. @holly_cummins
    the world changes

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  38. #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 full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  46. #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 full-size slide

  47. #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 full-size slide

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


    a trade-off where only one side has value

    View full-size slide

  49. #Quarkus @holly_cummins
    recap:


    which is “faster?”

    View full-size slide

  50. #Quarkus @holly_cummins
    GraalVM
    Quarkus
    Application
    recap:


    which is “faster?”

    View full-size slide

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


    which is “faster?”

    View full-size slide

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


    which is “faster?”

    View full-size slide

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


    which is “faster?”

    View full-size slide

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


    which is “faster?”

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  59. #Quarkus @[email protected]
    30%


    of VMs are zombies
    antithesisgroup.com

    View full-size slide

  60. #Quarkus @holly_cummins
    how to optimise?

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  63. #RedHat @holly_cummins
    intuition
    pitfall 1

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  69. #Quarkus @[email protected]
    leading indicators

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  75. #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 full-size slide

  76. #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 full-size slide

  77. #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 full-size slide

  78. #Quarkus @[email protected]
    caution:


    performance experiments for entertainment purposes only.


    do not try these at home.

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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


    gc overhead is huge

    View full-size slide

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


    gc overhead is huge

    View full-size slide

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


    gc overhead is huge
    throughput is … better?!

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  88. #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 full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  93. #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 full-size slide

  94. #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 full-size slide

  95. #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 full-size slide

  96. #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 full-size slide

  97. #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 full-size slide

  98. #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 full-size slide

  99. #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 full-size slide

  100. #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 full-size slide

  101. #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 full-size slide

  102. #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 full-size slide

  103. #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 full-size slide

  104. #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 full-size slide

  105. #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 full-size slide

  106. #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 full-size slide

  107. #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 full-size slide

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


    – Gene Kim

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  116. #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 full-size slide

  117. #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 full-size slide

  118. #RedHat @holly_cummins
    advice
    pitfall 3

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  122. #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 full-size slide

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

    View full-size slide

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


    yes, right?

    View full-size slide

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

    View full-size slide

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


    • context


    • time

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  129. #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 full-size slide

  130. #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 full-size slide

  131. #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 full-size slide

  132. #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 full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  144. #RedHat @holly_cummins
    the shiny stuff
    pitfall 5

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  148. #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 full-size slide

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


    View full-size slide

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


    View full-size slide

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


    -Djdk.tracePinnedThreads

    View full-size slide

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


    -Djdk.tracePinnedThreads
    @ShouldNotPin (in quarkus tests)

    View full-size slide

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


    -Djdk.tracePinnedThreads
    @ShouldNotPin (in quarkus tests)

    View full-size slide

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

    View full-size slide

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


    -Susie Xia, Netflix

    View full-size slide

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


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

    View full-size slide

  157. #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 full-size slide

  158. #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 full-size slide

  159. #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 full-size slide

  160. #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 full-size slide

  161. #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 full-size slide

  162. #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 full-size slide

  163. #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 full-size slide

  164. #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 full-size slide

  165. #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 full-size slide

  166. #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 full-size slide

  167. #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 full-size slide

  168. #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 full-size slide

  169. #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 full-size slide

  170. #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 full-size slide

  171. #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 full-size slide

  172. #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 full-size slide

  173. #Quarkus @[email protected]
    method profiler


    View full-size slide

  174. #Quarkus @[email protected]
    method profiler


    View full-size slide

  175. #Quarkus @[email protected]
    method profiler


    View full-size slide

  176. #Quarkus @[email protected]
    method profiler


    View full-size slide

  177. #Quarkus @[email protected]
    method profiler


    Open Telemetry

    View full-size slide

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

    View full-size slide

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


    – Charity Majors

    View full-size slide

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

    View full-size slide

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


    – Avishai Ish-Shalom

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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


    performance: leading indicator for carbon

    View full-size slide

  188. #Quarkus @[email protected]
    example:


    what our quarkus experiments showed

    View full-size slide

  189. @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 full-size slide

  190. @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 full-size slide

  191. @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 full-size slide

  192. @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 full-size slide

  193. @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 full-size slide

  194. @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 full-size slide

  195. @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 full-size slide

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


    • electricity


    • hardware

    View full-size slide

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


    • electricity


    • hardware

    View full-size slide

  198. #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 full-size slide