on the twitter? ✤ here is some homework ✤ follow @5280mark ✤ tweet about this talk with #perfmark and #perfmatters ✤ you can look for tweet content hints at the bottom of most every slide ✤ thanks Hey You LOOK HERE ON SCREEN FOR TWEET HINTS
Test everything, every which way ✤ perfect engineer is the engineer that looks both ways when crossing a one way street ✤ Sphero story - performance isn’t always black and white “a great engineer crosses a one way street and looks both ways”
Incorporate performance into pair programming ✤ Add performance to code review process ✤ Add performance into continuous integration pipelines ✤ Think about user performance, reach performance, engagement performance and operational efficiency performance “a great engineer crosses a one way street and looks both ways”
never hear “but it works on my machine” again ✤ 2. select #perfmatters from 100 dev bytes; ✤ 33 hits from 9 hours of content by 50 speakers “wait, @5280mark about to review 9 hours of video content?!”
creates and configures virtual development environments ✤ Vagrantfile is a recipe for your box, a single file that can be checked in and used to recreate the exact same box over and over ✤ vagrantup.com ✤ commands: $ vagrant up $ vagrant ssh $ vagrant halt $ vagrant destroy “Vagrant - awesome tool, bad name though”
✤ Allows you to “Build, Ship, Run” ✤ Containerization ✤ OSX doesn’t support system-level virtualization even though BSD has Jails (similar) so use Ubuntu via Vagrant (alternative would be boot2docker) “Have you seen the whale logo, its tremendous”
(orgins with Hudson and Oracle dispute) ✤ Continuous Integration software ✤ Monitors execution of builds ✤ Makes it easy for anyone to make a build (source into product) “Have I seen Jenkins on TV before?”
your project the same way ✤ Great plugin support, can even publish to Google Play Store ✤ Set up slaves as Docker instances, other Pro Tips … “Jenkins plugins make a great tool even more awesome”
is host, has Vagrant inside of it, can see Mac at / vagrant ✤ Docker is inside Vagrant, use host folder to access up: “Super awesome sauce = vagrant + docker + jenkins”
machine”, the operational efficiency killer ✤ Vagrant, Docker, Jenkins combine for consistent repeatable build environment, Dev machine same as everywhere else ✤ Incorporate performance measurements? “Works on my machine problems are efficiency killers”
features, use Android Design Support Library ✤ TextInputLayout lets you handle input errors with less code ✤ CoordinatorLayout is amazing, helps coordinate motions to actions across widgets
year old Computer Science field ✤ LRU = Least Recently Used ✤ LRU cache helps you figure out which items to get rid of as memory gets low (eg album thumbnails in a gallery) ✤ Best practice: set memory size to a portion of available memory (available by Android call or even better use device profile), 1/8 is a good starting point ✤ Keep calm and profile on
and improve battery life ✤ Reduce GCM messages sent to device ✤ App Invites (performance through downloads!), personal recommendation is better than anonymous corporate messaging
doing ✤ Walking, driving, biking, running ✤ Ever wonder how Google Now knows where you parked? This is how! ✤ Intent based, better performance than a persistant running service ✤ Activity reporting stops when device is still to save on battery
✤ Correctness, Usability, Security, Accessibility, Performance, Internationalization ✤ Can change specific error levels, maybe change too many views to a warning instead of error because newer devices not an issue
a business ✤ BYOD = Bring your own device ✤ Corporate liable = company bought it for you ✤ I.T. Admin can now group purchase licenses for a company, increase your sales performance
and transparent parts ✤ use hasOverlappedRendering to make view draw twice as fast ✤ you can profile app to find out where to make faster, but improvements won’t always make the app faster
objects, kicking off garbage collection events ✤ Framerate drops, steals battery life, bad! ✤ Drawing libraries are actually wrappers around C++ libraries with destructors/finalizers which are not good for performance ✤ Move allocations out of onDraw, make them static or package scope (even better)
✤ Usually blocking calls like network ✤ In developer mode can turn on strict mode ✤ Screen border flashes red if a blocking call is made ✤ like a runtime version of LINT ✤ Can code a detection map (what to test for and what penalty to apply) ✤ noteSlowCall
when making custom views ✤ Never draw things that haven’t changed ✤ Never call invalidate() when you don’t have to ✤ don’t use draw methods that are not hardware accelerated (GPU way better than CPU) ✤ don’t make allocations in onDraw ✤ dual cost from init + garbage collection ✤ when a view is animating onDraw is called 60x per second on UI thread, each has 16ms probably only 8 after you remove overhead
analogy ✤ If Kernel isn’t timely you will get popcorn (its a sound) ✤ tempting to make larger buffers to fix problems but better to systrace profile and fix root cause in kernel
no shuffling of items when something too large for available space comes in, kicks off GC ✤ Bitmaps are largest allocations in app ✤ Use BitmapOptions.config to use different compression types for big wins in memory residency trading off for some CPU usage
much memory in heap ✤ update heap button starts recording ✤ heap tab has display ✤ click cause GC to force an update ✤ see what types of objects your app has allocated
and visual quality ✤ If you don’t need transparency - JPEG ✤ You can separate alpha channel and use 2 JPEGs to take advantage of lossy compression ✤ WebP works on API 17 and above ✤ Data compression helps with data transfer not memory residency, so this video is kind of a filler
inSampleSize is very fast, reads every other pixel for 2, can use with any power of 2 ✤ Perf trick - use both! Get almost right size with inSampleSize then fine tune with createScaledBitmap ✤ Since existing libraries already do this (Glide and Picasso) use these proven libraries for production code
performance concerns ✤ Bitmaps represent largest contiguous blocks of memory in your heaps, can lead to contention and GC ✤ Use object pools ✤ use inBitmap property, but all images must be same size ✤ Again, Glide library does this for you and just use library
to avoid collisons ✤ ArrayMap for Android uses two small arrays, 2nd array has location hashes for 1st array ✤ If 100’s of items with frequent access use ArrayMap otherwise HashMap ✤ Optimizing performance is a constant trade off, there is no silver bullet
collections like java.lang.Integer are not primitives ✤ auto boxing converts from object type to primitive ✤ requires more performance overhead to get underlying value ✤ Allocation Tracker and traceview can find this problem ✤ Colt’s got 99 problems joke
The previously pictured web page from 2009 caused much confusion ✤ Core platform team on Android does not use ENUMs ✤ @IntDef annotation will optimize for you but … ✤ Long story short, watch out for Gremlins and use ProGuard and any ENUM problems will go away on their own
time on building stuff instead of packaging it ✤ Containers are built on Linux Kernel and encapsulate your system (file and processor) ✤ Check out Docker and Kubernetes minecraft server blog posts
Preview 3 and release ✤ Can test doze with ADB commands ✤ $ adb shell dumpsys battery unplug ✤ Can avoid auto backup for apps targeting M and above by using “getnobackup” folder — privacy performance?
be getting yourself into trouble ✤ Don’t want the layout phase of the rendering pipeline to trigger again ✤ Expensive cascade of layout recalculations ✤ GridLayout is better than RelativeLayout from a performance perspective ✤ SysTrace tool can be used to find problems in measure and layout that might lead to frame rate issues ✤ Hierarchy Viewer can be used to find excessive depth
background app can keep state information, graphic resources and heap objects ✤ onTrimMemory callback has trim level 1-100, since ICS ✤ allows you to free up memory to avoid getting killed, reactively ✤ to be proactive for low memory situations use isLowRamDevice() (true if under 512MB), can gate access to certain features
2PM today, same room - Android Internal Library Dependency Management with Kelly Shuster ✤ 4PM today, Keynote room - Performant Threading For the Sophisticated BBQr with Colt McAnlis ✤ 9:30AM tomorrow, Keynote room - Android for Java Developers with Chet Haase ✤ 10AM tomorrow, room 1 - Using the NDK Performantly with Daniel Gilpin ✤ 12:30PM tomorrow, Keynote room - Tales of Optimizing for Android Wear with Michael Kwan ✤ 2:30PM tomorrow, Keynote room - Building battery efficient apps with Ran Nachmany ✤ 3PM tomorrow, room 1 - Advanced Android Espresso with Chiu-Ki Chan
✤ github.com/mscheel ✤ Open Source contributions to Google Glass and Square ✤ stackoverflow.com/mscheel ✤ speakerdeck.com/mscheel ✤ These slides are available now! ✤ lanyrd.com/mscheel ✤ November 20, 2015: droidcon.fr, Paris, France ✤ December 3, 2015: AnDevCon, Santa Clara, CA (Discount code SCHEEL good for $200 off) ✤ meetup.com/gdg-denver ✤ Visit Denver and speak! You can do it. ✤ www.digitalconstruction.com ✤ www.itriagehealth.com ✤ airbnb.com/r/mscheel ($25 travel credit from me) #BABBQ15
✤ github.com/mscheel ✤ Open Source contributions to Google Glass and Square ✤ stackoverflow.com/mscheel ✤ speakerdeck.com/mscheel ✤ These slides are available now! ✤ lanyrd.com/mscheel ✤ November 20, 2015: droidcon.fr, Paris, France ✤ December 3, 2015: AnDevCon, Santa Clara, CA (Discount code SCHEEL good for $200 off) ✤ meetup.com/gdg-denver ✤ Visit Denver and speak! You can do it. ✤ www.digitalconstruction.com ✤ www.itriagehealth.com ✤ airbnb.com/r/mscheel ($25 travel credit from me) #BABBQ15
✤ github.com/mscheel ✤ Open Source contributions to Google Glass and Square ✤ stackoverflow.com/mscheel ✤ speakerdeck.com/mscheel ✤ These slides are available now! ✤ lanyrd.com/mscheel ✤ November 20, 2015: droidcon.fr, Paris, France ✤ December 3, 2015: AnDevCon, Santa Clara, CA (Discount code SCHEEL good for $200 off) ✤ meetup.com/gdg-denver ✤ Visit Denver and speak! You can do it. ✤ www.digitalconstruction.com ✤ www.itriagehealth.com ✤ airbnb.com/r/mscheel ($25 travel credit from me) #BABBQ15
✤ github.com/mscheel ✤ Open Source contributions to Google Glass and Square ✤ stackoverflow.com/mscheel ✤ speakerdeck.com/mscheel ✤ These slides are available now! ✤ lanyrd.com/mscheel ✤ November 20, 2015: droidcon.fr, Paris, France ✤ December 3, 2015: AnDevCon, Santa Clara, CA (Discount code SCHEEL good for $200 off) ✤ meetup.com/gdg-denver ✤ Visit Denver and speak! You can do it. ✤ www.digitalconstruction.com ✤ www.itriagehealth.com ✤ airbnb.com/r/mscheel ($25 travel credit from me) #BABBQ15
✤ github.com/mscheel ✤ Open Source contributions to Google Glass and Square ✤ stackoverflow.com/mscheel ✤ speakerdeck.com/mscheel ✤ These slides are available now! ✤ lanyrd.com/mscheel ✤ November 20, 2015: droidcon.fr, Paris, France ✤ December 3, 2015: AnDevCon, Santa Clara, CA (Discount code SCHEEL good for $200 off) ✤ meetup.com/gdg-denver ✤ Visit Denver and speak! You can do it. ✤ www.digitalconstruction.com ✤ www.itriagehealth.com ✤ airbnb.com/r/mscheel ($25 travel credit from me) #BABBQ15
✤ github.com/mscheel ✤ Open Source contributions to Google Glass and Square ✤ stackoverflow.com/mscheel ✤ speakerdeck.com/mscheel ✤ These slides are available now! ✤ lanyrd.com/mscheel ✤ November 20, 2015: droidcon.fr, Paris, France ✤ December 3, 2015: AnDevCon, Santa Clara, CA (Discount code SCHEEL good for $200 off) ✤ meetup.com/gdg-denver ✤ Visit Denver and speak! You can do it. ✤ www.digitalconstruction.com ✤ www.itriagehealth.com #BABBQ15
✤ github.com/mscheel ✤ Open Source contributions to Google Glass and Square ✤ stackoverflow.com/mscheel ✤ speakerdeck.com/mscheel ✤ These slides are available now! ✤ lanyrd.com/mscheel ✤ November 20, 2015: droidcon.fr, Paris, France ✤ December 3, 2015: AnDevCon, Santa Clara, CA (Discount code SCHEEL good for $200 off) ✤ meetup.com/gdg-denver ✤ Visit Denver and speak! You can do it. ✤ www.digitalconstruction.com ✤ www.itriagehealth.com ✤ airbnb.com/r/mscheel ($25 travel credit from me) #BABBQ15
✤ github.com/mscheel ✤ Open Source contributions to Google Glass and Square ✤ stackoverflow.com/mscheel ✤ speakerdeck.com/mscheel ✤ These slides are available now! ✤ lanyrd.com/mscheel ✤ November 20, 2015: droidcon.fr, Paris, France ✤ December 3, 2015: AnDevCon, Santa Clara, CA (Discount code SCHEEL good for $200 off) ✤ meetup.com/gdg-denver ✤ Visit Denver and speak! You can do it. ✤ www.digitalconstruction.com ✤ www.itriagehealth.com ✤ airbnb.com/r/mscheel ($25 travel credit from me) #BABBQ15
✤ github.com/mscheel ✤ Open Source contributions to Google Glass and Square ✤ stackoverflow.com/mscheel ✤ speakerdeck.com/mscheel ✤ These slides are available now! ✤ lanyrd.com/mscheel ✤ November 20, 2015: droidcon.fr, Paris, France ✤ December 3, 2015: AnDevCon, Santa Clara, CA (Discount code SCHEEL good for $200 off) ✤ meetup.com/gdg-denver ✤ Visit Denver and speak! You can do it. ✤ www.digitalconstruction.com ✤ www.itriagehealth.com ✤ airbnb.com/r/mscheel ($25 travel credit from me) #BABBQ15
✤ github.com/mscheel ✤ Open Source contributions to Google Glass and Square ✤ stackoverflow.com/mscheel ✤ speakerdeck.com/mscheel ✤ These slides are available now! ✤ lanyrd.com/mscheel ✤ November 20, 2015: droidcon.fr, Paris, France ✤ December 3, 2015: AnDevCon, Santa Clara, CA (Discount code SCHEEL good for $200 off) ✤ meetup.com/gdg-denver ✤ Visit Denver and speak! You can do it. ✤ www.digitalconstruction.com ✤ www.itriagehealth.com ✤ airbnb.com/c/mscheel ($20 travel credit from me) #BABBQ15