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

Efficient Software: A Developer’s Manual for Sa...

Avatar for Holly Cummins Holly Cummins
May 08, 2025
88

Efficient Software: A Developer’s Manual for Saving The World

None of us actually like waste, but many of us tolerate it. This is a shame, because waste is really really bad.
It makes our software more expensive to develop, and more expensive to run. It contributes to climate change. It means sometimes, people who’d like to use our software, can’t. It slows us down.

In this talk, Holly will present a range of practical waste-reduction techniques, including:

- LightSwitchOps
- Moving computational work to where it hurts least
- Measuring the right thing, instead of measuring the wrong thing (harder than it seems!)
- Performance profiling basics
- Doing less

Avatar for Holly Cummins

Holly Cummins

May 08, 2025
Tweet

More Decks by Holly Cummins

Transcript

  1. Holly Cummins Senior Principal Software Engineer, Quarkus Devoxx UK May

    9, 2025 Efficient Software: A Developer’s Manual for Saving The World
  2. @holly_cummins #RedHat “Half the money I spend on advertising is

    wasted; the trouble is I don't know which half.” – John Wanamaker (1838-1922)
  3. @holly_cummins #RedHat half the CPU cycles of our apps are

    wasted; the trouble is we don’t know which half.
  4. @holly_cummins #RedHat half the footprint of our apps is wasted;

    the trouble is we don’t know which half.
  5. @holly_cummins #RedHat https://blog.linkedin.com/2017/august/3/making-linkedin-more-accessible-via-linkedin-lite modern web is so inefficient it is

    useless for part of its audience “my heart sank … our new feature failed to load because of poor internet connectivity” Nashik
  6. @holly_cummins #RedHat Lighter area represents high and low estimates, where

    available. Sources: https://www.iea.org/fuels-and-technologies/data-centres-networks https://ourworldindata.org/grapher/electricity-demand?tab=table&country=USA~GBR~FRA~DEU~IND~BRA data centres use as much electricity as a medium country
  7. @holly_cummins Java dynamism @ @ </> packaging (maven, gradle…) build

    time runtime ready to do work! load and parse • config files • properties • yaml • xml • etc. • classpath scanning and annotation discovery • attempt to load class to enable/disable features build a metamodel of the world start • thread pools • I/O • etc.
  8. @holly_cummins what if we start the application more than once?

    @ @ </> @ @ </> @ @ </> @ @ </> so much work gets redone every time
  9. @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:
  10. @holly_cummins the true cost of loaded classes isn’t just memory

    + start time the one we want monomorphic call fast dispatching interface
  11. @holly_cummins @ @ </> build time runtime ready to do

    work! start • thread pools • I/O • etc. what if we initialize at build time?
  12. @holly_cummins #RedHat density 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
  13. @holly_cummins #RedHat but measuring can be scary - make sure

    you’re measuring the right thing - be cautious with micro-benchmarks
  14. #Quarkus @holly_cummins method profiler GC analysis heap analysis APM distributed

    tracing Mission Control flame graphs GCMV New Relic* AppDynamics* Micrometer OpenTelemetry 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)
  15. @holly_cummins #RedHat Energy 1 10 100 Time 1 10 100

    the trend line is more or less straight energy efficiency across programming languages Python Rust Java Go
  16. @holly_cummins #RedHat Setup: • REST + CRUD • large heap

    • RAPL energy measurement • multiple instances to support high load Assumptions: • US energy mix Source: John O’Hara climate impact as a function of load wait, what?
  17. @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
  18. #RedHat @hollycummins.com 29% of servers active <5% of the time

    https://www.anthesisgroup.com/wp-content/uploads/2019/11/Comatose-Servers-Redux-2017.pdf
  19. #RedHat @hollycummins.com the average server: 12 - 18% of capacity

    30 - 60 % of maximum power https://www.nrdc.org/sites/default/files/data-center-efficiency-assessment-IB.pdf
  20. #RedHat @hollycummins.com Hey boss, I created a Kubernetes cluster. I

    forgot it for 2 months. … and it’s €1000 a month. 2018
  21. #RedHat @hollycummins.com “we run this as a batch job on

    weekends, but the servers stay up all week” “
  22. #RedHat @hollycummins.com “we only use this system in UK working

    hours, but we leave it running 24/7 ” “
  23. #RedHat @hollycummins.com we don’t switch the light off because we’re

    not sure if it will come back on never happens
  24. #RedHat @hollycummins.com we don’t switch the server off because we’re

    not sure if it will come back on happens all the time
  25. #RedHat @hollycummins.com we don’t switch the server off because it

    would be too much work to recreate it happens all the time
  26. @hollycummins.com #RedHat turning it off and on again must •

    be fast • actually work • idempotency • resiliency
  27. @hollycummins.com #RedHat the scream is real this internal server doesn’t

    seem to have a purpose uh … why did the backbone of a client’s network just vanish? let’s turn it off! oops.
  28. #RedHat @hollycummins.com large UK bank, 2013 50% reduction in CPUs

    with a lease system self-destructing instances
  29. @hollycummins.com #RedHat timed shutoff we used to leave our applications

    running all the time when we scripted turning them off at night, we reduced our cloud bill by 30% @darkandnerdy, Chicago DevOpsDays
  30. @holly_cummins #RedHat - 99% of requests under 100ms - can

    run on t2.micro instance - cost per transaction < £0.02 - save the world example SLAs ?
  31. @holly_cummins #RedHat return on investment time money saved by the

    fix less money spent on the fix winning financial ruin stop here?
  32. @holly_cummins #RedHat tl;dpa (too long; didn’t pay attention) efficient code

    is good for users, good for business, and good for the world choose an efficient stack (such as quarkus!) measure, profile, and optimise your code to get rid of waste think about how you provision: is it elastic? have you got zombies? flamethrower them!