Monday, April 12, 2010

Enhancing performance on Android devices

Mobile devices are experiencing rapid gains in memory size as well as processing power, but they're certainly not in the same league as hardware we're typically developing software for. At my recent talk for the 2010 ETE conference, the final segment of the presentation focused on some of the performance techniques I'd utilized to enhance the overall user experience. Since the talk ran a bit long, I didn't have the opportunity to go into all the details I was hoping to so I decided to post one in particular here.

The Android platform's primary development language is Java (there's also the ability to utilize native code, but this post's focus is on Java). The Java source is compiled and then converted to run on the Dalvik virtual machine. While again not a focus of this post, it's important to recognize, at least at the time of this writing, that you don't have the capability to specify things like heap size, garbage collector selection, or any of the ergonomics we take for granted in other environments. On the other hand, the platform does offer a rich feature set to execute background work in a concurrent manner; the talk showed the application's usage of AsyncTask, Looper, Handler, and Message constructs. In light of being able to go so far as arbitrary Thread creation, how does one balance between saturation and diminished throughput?

Seasoned developers will be glad to find that the java.util.concurrent packages are at your disposal for Android development. In particular, the ETE app makes use of the ExecutorService. I coded its usage as a Singleton:

package com.chariotsolutions.ete.util;

import java.lang.ref.SoftReference;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ExecutorServiceSingleton {  
    private SoftReference<ExecutorService> 
        executorServiceReference =     
           new SoftReference<ExecutorService>(
                 createExecutorService());    

    private static class SingletonHolder {        
       private static final ExecutorServiceSingleton INSTANCE =        
          new ExecutorServiceSingleton();    
    }    

    private ExecutorServiceSingleton(){}    

    public static ExecutorServiceSingleton instance() {      
       return SingletonHolder.INSTANCE;    
    }    

    public ExecutorService getExecutorService() {
      ExecutorService executorService = 
         executorServiceReference.get();

      if (executorService == null) { 
         // (the reference was cleared)
         executorService = createExecutorService();
         executorServiceReference =
           new SoftReference<ExecutorService>(executorService);
      }
  
      return executorService;    
    }    

    private ExecutorService createExecutorService() {
        // future devices (or perhaps existing netbooks?)
        // will certainly be multi-core:
        return Executors.newFixedThreadPool(
               Runtime.getRuntime().availableProcessors()+2);
    }
}

A couple points from the code:

  • The ExecutorService is wrapped in a SoftReference. In light of the inherent operating constraints, should the resources get tight, the ExecutorService reference will be reclaimed (after all, its usage is only for new data parsing and for searching).
  • Using the SingletonHolder approach, we get the added benefit of lazy initialization, another nod toward efforts of being a good citizen on the device.
  • The createExecutorService method logic asks the runtime for the number of available processors; future devices will most certainly feature multiple cores.

In conclusion, the Android platform offers some really nice approaches for background and/or concurrent processing. Properly utilizing such techniques will certainly enhance the user experience, and after all, it's all about the user.


Special thanks to Ahsen Jaffer for contributing the "Map" feature of the application!

Saturday, April 10, 2010

More Video Reports from Philly ETE

Adam Blum gives us his 30 second overview on his talk at Philly ETE. His talk on best practices for smart phone business apps was well attended. It was great to meet Adam in person.

Friday, April 9, 2010

Emerging Technologies for the Enterprise 2010 - Ed Burns

Ed Burns sat down for a quick interview to discuss his talk on Rock Star Programmers.

I was very impressed that his family was there attending his session including his son.
Also, as you can see, I do need to stop cutting off the top of my interviewees heads.

Emerging Technologies for the Enterprise 2010 - Second Recap

Here is my interview with James Ward, Technical Evangelist for Flex, from Adobe. He spoke on Building Client/Server 2.0 Apps with Flex.

Emerging Technologies for the Enterprise 2010 - First Day Recap

Our first day for the Emerging Technologies for the Enterprise Conference was fantastic. The attendees have been engaged, the speakers have been really terrific. The weather was beautiful!

I will try and give you a glimpse of some of the talks with short clips of interviews with as many speakers as I could catch.

It may take me a few days to get all of them up, so keep checking back.

You can also follow the twitter stream with #phillyete.

First up is Skip Shuda. Skip lead a panel called Social Media - Why Should I Care?
So, please excuse the background noise. I need to get a better mic!

Monday, March 29, 2010

Jason van Zyl - Maven expert and Chariot guest blogger

Chariot's blog is trying something new today. I asked Jason van Zyl to give our audience a preview of his talk at Philly ETE this year. I know it is a bit of promotion for the conference, but our conference planning committee knows we have the best content to date. This year, we are also partnering with Sonatype's Maven Meetup.

PHILLY ETE 2010 – GUEST BLOG

Jason van Zyl, founder and CTO of Sonatype, will be speaking at Emerging Technologies for the Enterprise in Philadelphia. His talk, Next Generation Development Infrastructure: Maven, m2eclipse, Nexus & Hudson, will take place on Thursday April 8, 2010.

In this talk van Zyl will discuss the future of Maven, “specifically Maven 3.x, the rapidly approaching m2eclipse 1.0 release, the recent Nexus 2.0 release and roadmap, and changes that have been made to Hudson to provide better interoperability with Maven.”

My presentation at Emerging Technologies for the Enterprise will cover a lot of ground, as there’s a lot going on a Sonatype these days. Just this past week we released Maven Studio for Eclipse, the only Eclipse Integrated Development Environment specifically optimized for Maven. The Studio essentially cuts the time a developer spends configuring development environments from multiple days to minutes.

I will also discuss the future of Maven, specifically migrating from Maven 2 to Maven 3.0. When migrating from Maven 2 to Maven 3.0 we’ve planned that, in most cases, users won’t experience any challenges. We’ve designed Maven 3.0 to be a drop-in replacement for Maven 2.

Ahead of the Emerging Technologies for the Enterprise conference, Sonatype will be hosting a Maven Meetup. Wednesday April 7, we will be holding a day of presentations covering everything from OSGi Runtimes, to p2, Nexus, Tycho, m2eclipse, Selenium and Peaberry.

You can register for the Sonatype Maven Meetup at www.sonatype.com/meetup2010

Friday, March 19, 2010

Audio Interview: KYW NewsRadio on Social Media in the Radio News Business


On Thursday we did an interview with Steve Butler, Program and News Director of KYW News Radio, discussing the reach of Social Media in news outlets. We cover topics as diverse as Twitter and the generational divide, using social media to discover news stories and are all areas of social media right for every situation and business.

Click on the Play button below to listen to Mr. Butler's interview with Tracey Welson-Rossman.