Need forbuildspeed agile2012
description
Transcript of Need forbuildspeed agile2012
![Page 1: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/1.jpg)
© Reaktor 2012
The Need for(Build) Speed
Lasse Koskela
(Please go ahead and pre-fill those feedback forms. I appreciate that. It also
brings you that much closer to beer.)
![Page 2: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/2.jpg)
© Reaktor 2012
Lasse Koskela works as a coach, trainer, consultant and programmer, spending his days helping clients and colleagues at Reaktor create successful software products.
Follow him on Twitter as @lassekoskela
![Page 3: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/3.jpg)
”© Reaktor 2012
Standing between an audience and their beer is tough so you better talk fast.
~ agile conference proverb
Session Outline1) Impact of build time2) Profiling a build3) Optimizing test code4) Tweaking infrastructure
![Page 4: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/4.jpg)
© Reaktor 2012
Impact of build time
![Page 5: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/5.jpg)
© Reaktor 2012
Delayed feedback is bad for you• The faster you know that your software is
(still) working as it should the faster your brain can move on to the next thing.
• The longer you have to wait for feedback the higher the chance of doing rework and context-switching.
![Page 6: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/6.jpg)
”© Reaktor 2012
http://gojko.net/2009/12/07/improving-testing-practices-at-google/
Delayed feedback costs $$$
[Google] estimated that a bug found during TDD costs $5 to fix, which surges to $50 for tests during a full build and $500 during an integration test. It goes to $5000 during a system test. Fixing bugs earlier would save them an estimated $160M per year.
![Page 7: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/7.jpg)
© Reaktor 2012
Profiling a build
![Page 8: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/8.jpg)
© Reaktor 2012
How do we know what’s up?• Shooting in the dark works amazingly well
...if you’re lucky.• The rest of us need to understand what is
making our build slow before reaching for our guns.
![Page 9: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/9.jpg)
© Reaktor 2012
What exactly do we want to know?• How much time it takes altogether?• Which build activities take up the majority
of that total?• Which of these have potential for
optimization?
![Page 10: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/10.jpg)
© Reaktor 2012
Demo
Profiling an Apache Ant build with built-in utilities and open source tools
![Page 11: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/11.jpg)
© Reaktor 2012
Demo
Profiling an Apache Ant build with built-in utilities and open source tools
$ ant -listener net.sf.antcontrib.perf.AntPerformanceListener
![Page 12: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/12.jpg)
© Reaktor 2012
Demo
Profiling an Apache Ant build with built-in utilities and open source tools
$ ant -listener net.sf.antcontrib.perf.AntPerformanceListener
$ ant -logger org.apache.tools.ant.listener.ProfileLogger
![Page 13: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/13.jpg)
© Reaktor 2012
Demo
Profiling an Apache Maven build with built-in utilities and open source tools
![Page 14: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/14.jpg)
© Reaktor 2012
Demo
Profiling an Apache Maven build with built-in utilities and open source tools
<build> <extensions> <extension> <groupId>com.github.lkoskela</groupId> <artifactId>maven-build-utils</artifactId> <version>1.4</version> </extension> </extensions> </build>
![Page 15: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/15.jpg)
© Reaktor 2012
Optimizing test code
![Page 16: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/16.jpg)
© Reaktor 2012
Tests can be slow because they...
![Page 17: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/17.jpg)
© Reaktor 2012
Tests can be slow because they...
do many things.
a)
![Page 18: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/18.jpg)
© Reaktor 2012
Tests can be slow because they...
do many things.
a)
do slow things.
b)
![Page 19: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/19.jpg)
© Reaktor 2012
![Page 20: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/20.jpg)
© Reaktor 2012
Examples ofdoing too much
Tests do setup that isn’t relevant to the test.
Tests build input from unnecessarily raw materials.
Tests do the same thing many times when once is enough.
Tests use a slow real object when a stub would suffice.
![Page 21: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/21.jpg)
© Reaktor 2012
Examples ofdoing too much
Tests do setup that isn’t relevant to the test.
Tests build input from unnecessarily raw materials.
Tests do the same thing many times when once is enough.
Tests use a slow real object when a stub would suffice.
![Page 22: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/22.jpg)
© Reaktor 2012
Examples ofdoing too much
Tests do setup that isn’t relevant to the test.
Tests build input from unnecessarily raw materials.
Tests do the same thing many times when once is enough.
Tests use a slow real object when a stub would suffice.
![Page 23: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/23.jpg)
© Reaktor 2012
Examples ofdoing too much
Tests do setup that isn’t relevant to the test.
Tests build input from unnecessarily raw materials.
Tests do the same thing many times when once is enough.
Tests use a slow real object when a stub would suffice.
![Page 24: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/24.jpg)
© Reaktor 2012
Examples ofdoing too much
Tests do setup that isn’t relevant to the test.
Tests build input from unnecessarily raw materials.
Tests do the same thing many times when once is enough.
Tests use a slow real object when a stub would suffice.
![Page 25: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/25.jpg)
© Reaktor 2012
Examples ofdoing too much
Tests do setup that isn’t relevant to the test.
Tests build input from unnecessarily raw materials.
Tests do the same thing many times when once is enough.
Tests use a slow real object when a stub would suffice.
Examples ofslow things
Tests invoke Thread.sleep(...) to wait for task completion.
Components talk to each other over a network protocol.
Tests run against a production-like database.
Tests access afile system.
![Page 26: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/26.jpg)
© Reaktor 2012
Examples ofdoing too much
Tests do setup that isn’t relevant to the test.
Tests build input from unnecessarily raw materials.
Tests do the same thing many times when once is enough.
Tests use a slow real object when a stub would suffice.
Examples ofslow things
Tests invoke Thread.sleep(...) to wait for task completion.
Components talk to each other over a network protocol.
Tests run against a production-like database.
Tests access afile system.
![Page 27: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/27.jpg)
© Reaktor 2012
Examples ofdoing too much
Tests do setup that isn’t relevant to the test.
Tests build input from unnecessarily raw materials.
Tests do the same thing many times when once is enough.
Tests use a slow real object when a stub would suffice.
Examples ofslow things
Tests invoke Thread.sleep(...) to wait for task completion.
Components talk to each other over a network protocol.
Tests run against a production-like database.
Tests access afile system.
![Page 28: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/28.jpg)
© Reaktor 2012
Examples ofdoing too much
Tests do setup that isn’t relevant to the test.
Tests build input from unnecessarily raw materials.
Tests do the same thing many times when once is enough.
Tests use a slow real object when a stub would suffice.
Examples ofslow things
Tests invoke Thread.sleep(...) to wait for task completion.
Components talk to each other over a network protocol.
Tests run against a production-like database.
Tests access afile system.
![Page 29: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/29.jpg)
© Reaktor 2012
Examples ofdoing too much
Tests do setup that isn’t relevant to the test.
Tests build input from unnecessarily raw materials.
Tests do the same thing many times when once is enough.
Tests use a slow real object when a stub would suffice.
Examples ofslow things
Tests invoke Thread.sleep(...) to wait for task completion.
Components talk to each other over a network protocol.
Tests run against a production-like database.
Tests access afile system.
![Page 30: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/30.jpg)
© Reaktor 2012
Demo
An example of irrelevant setup that’s inherited through a hierarchy of abstract test classes.
![Page 31: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/31.jpg)
© Reaktor 2012
Demo
An example of tests wasting valuable time by Thread#sleep’ing too much.
![Page 32: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/32.jpg)
© Reaktor 2012
Demo
An example of a test that uses a slow(ish) real implementation that talks to the network stack.
![Page 33: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/33.jpg)
© Reaktor 2012
Tweaking infrastructure
![Page 34: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/34.jpg)
© Reaktor 2012
Is your build’s bottleneck...
I/OCPU
![Page 35: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/35.jpg)
© Reaktor 2012
![Page 36: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/36.jpg)
© Reaktor 2012
Peaking “user time” suggests CPU running hot
![Page 37: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/37.jpg)
© Reaktor 2012
![Page 38: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/38.jpg)
© Reaktor 2012
Peaking “idle time” suggests CPU is waiting
![Page 39: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/39.jpg)
© Reaktor 2012
![Page 40: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/40.jpg)
© Reaktor 2012
Peaking “system calls” suggests lots of I/O
![Page 41: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/41.jpg)
© Reaktor 2012
Lifting the CPU bottleneckby using more hardware
![Page 42: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/42.jpg)
© Reaktor 2012
Lifting the CPU bottleneckby using more hardware
![Page 43: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/43.jpg)
© Reaktor 2012
Demo
An example of a Maven build that employs multiple CPU cores.
![Page 44: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/44.jpg)
© Reaktor 2012
Lifting the CPU bottleneckby using better hardware
![Page 45: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/45.jpg)
© Reaktor 2012
Lifting the CPU bottleneckby using better hardware
![Page 46: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/46.jpg)
© Reaktor 2012
Lifting the CPU bottleneckby using better hardware
Amazon EC2 Small Instance1.7 GB memory1 virtual core with 1 EC2 compute units
Amazon EC2 Medium Instance3.75 GB memory1 virtual core with 2 EC2 compute units
![Page 47: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/47.jpg)
© Reaktor 2012
Demo
An example of a Maven build that is run in the cloud on a (more or less) powerful computer.
![Page 48: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/48.jpg)
© Reaktor 2012
Lifting the I/O bottleneckby using better hardware
![Page 49: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/49.jpg)
© Reaktor 2012
Lifting the I/O bottleneckby using better hardware
![Page 50: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/50.jpg)
© Reaktor 2012
Demo
An example of a build that is run from a (more or less) fast disk.
![Page 51: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/51.jpg)
© Reaktor 2012
Lifting the I/O bottleneckby using more hardware
![Page 52: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/52.jpg)
© Reaktor 2012
Lifting the I/O bottleneckby using more hardware
![Page 53: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/53.jpg)
© Reaktor 2012
Summary
![Page 54: Need forbuildspeed agile2012](https://reader033.fdocuments.us/reader033/viewer/2022052618/54c0ea654a79592b7a8b4592/html5/thumbnails/54.jpg)
© Reaktor 2012
Please, fill thefeedback form for me.
I’d really appreciate that.TITLE: The Need for (Build) SpeedPRESENTER: Lasse Koskela