[android-developers] Re: Jackson Object Mapping is so slow in the process with an Activity.

2011-06-23 Thread idleSun
It turns out that it is slow when I run it in debug mode. So it is not
a big deal. However, if you have a heavy jackson use and want to debug
your code then you got to be really patient.


On Jun 22, 10:59 am, idleSun idle...@gmail.com wrote:
 I am using pretty complicated JSON data with Object Mapping to Java
 Classes that are of course also pretty complicated (inheritance depth
 is high and there are members defined as List and so on). When I 
 doJacksonobject mapping in a service with a separate process, it took
 about 4 sec. But surprisingly, when I tried the same thing in an
 Activity or a service in the same process as the Activity's, it took
 about ten times more, 40 sec! Super slow. I tried IntentService in the
 same process to run it in a different thread than Activity's. And I
 also tried setting thread priority to highest. But all gave the same
 result, super slow.

 I have tested this only on Emulator with Android 2.3 target virtual
 device. And I collect some log and attached in the end. What I found
 in terms of differences between running in an activity and a service
 (with a separate process) are
   1. There are some GC_EXPLICIT in Activity case
   2. Time difference between GC_CONCURRENT logs are different: ~2 sec
 in an Activity, ~300 msec in a Service.

 Anyone help and comment are welcome.

  LogCat logs ===

 06-22 17:32:38.812: DEBUG/qemud(37): fdhandler_accept_event: accepting
 on fd 9
 06-22 17:32:38.812: DEBUG/qemud(37): created client 0x23a38 listening
 on fd 12
 06-22 17:32:38.812: DEBUG/qemud(37): fdhandler_event: disconnect on fd
 12
 06-22 17:32:39.002: DEBUG/dalvikvm(307): GC_EXPLICIT freed 7K, 54%
 free 2545K/5511K, external 716K/1038K, paused 65ms
 
 06-22 17:32:39.342: INFO/MapperActivity(12292): Object Mapping Started
 in Activity
 06-22 17:32:39.402: INFO/MapperActivity(12292): Thread id=12292,
 priority=0
 06-22 17:32:41.282: DEBUG/dalvikvm(12292): GC_CONCURRENT freed 436K,
 54% free 2720K/5831K, external 716K/1038K, paused 6ms+4ms
 06-22 17:32:43.492: DEBUG/dalvikvm(12292): GC_CONCURRENT freed 417K,
 54% free 2736K/5831K, external 716K/1038K, paused 6ms+4ms
 06-22 17:32:43.942: DEBUG/qemud(37): fdhandler_accept_event: accepting
 on fd 9
 06-22 17:32:43.942: DEBUG/qemud(37): created client 0x23a38 listening
 on fd 12
 06-22 17:32:43.942: DEBUG/qemud(37): fdhandler_event: disconnect on fd
 12
 06-22 17:32:45.263: DEBUG/dalvikvm(338): GC_EXPLICIT freed 4K, 55%
 free 2573K/5703K, external 716K/1038K, paused 1287ms
 06-22 17:32:45.333: DEBUG/dalvikvm(12292): GC_CONCURRENT freed 406K,
 53% free 2749K/5831K, external 716K/1038K, paused 6ms+4ms
 06-22 17:32:47.473: DEBUG/dalvikvm(12292): GC_CONCURRENT freed 406K,
 53% free 2747K/5831K, external 716K/1038K, paused 5ms+4ms
 . . .
 06-22 17:33:17.262: DEBUG/dalvikvm(12292): GC_CONCURRENT freed 439K,
 52% free 2905K/6023K, external 716K/1038K, paused 5ms+4ms
 06-22 17:33:18.662: DEBUG/qemud(37): fdhandler_accept_event: accepting
 on fd 9
 06-22 17:33:18.662: DEBUG/qemud(37): created client 0x23a38 listening
 on fd 12
 06-22 17:33:18.662: DEBUG/qemud(37): fdhandler_event: disconnect on fd
 12
 06-22 17:33:19.242: DEBUG/dalvikvm(12292): GC_CONCURRENT freed 436K,
 52% free 2909K/6023K, external 716K/1038K, paused 6ms+4ms
 06-22 17:33:20.792: INFO/MapperActivity(12292): Object Mapping in
 Activity took (msec): 41390
 
 . . .
 06-22 17:33:33.452: INFO/MapperService(12302): Object Mapping Started
 in Service
 06-22 17:33:33.522: INFO/MapperService(12302): Thread id=12302,
 priority=0
 06-22 17:33:33.932: DEBUG/qemud(37): fdhandler_accept_event: accepting
 on fd 9
 06-22 17:33:33.932: DEBUG/qemud(37): created client 0x23a38 listening
 on fd 12
 06-22 17:33:33.932: DEBUG/qemud(37): fdhandler_event: disconnect on fd
 12
 06-22 17:33:34.032: DEBUG/dalvikvm(12302): GC_CONCURRENT freed 519K,
 54% free 2696K/5831K, external 731K/1038K, paused 5ms+4ms
 06-22 17:33:34.302: DEBUG/dalvikvm(12302): GC_CONCURRENT freed 550K,
 54% free 2719K/5895K, external 731K/1038K, paused 5ms+4ms
 06-22 17:33:34.562: DEBUG/dalvikvm(12302): GC_CONCURRENT freed 492K,
 54% free 2718K/5895K, external 731K/1038K, paused 5ms+4ms
 06-22 17:33:34.852: DEBUG/dalvikvm(12302): GC_CONCURRENT freed 506K,
 54% free 2744K/5895K, external 731K/1038K, paused 5ms+4ms
 06-22 17:33:35.072: DEBUG/dalvikvm(12302): GC_CONCURRENT freed 539K,
 54% free 2717K/5895K, external 731K/1038K, paused 5ms+4ms
 06-22 17:33:35.332: DEBUG/dalvikvm(12302): GC_CONCURRENT freed 497K,
 54% free 2732K/5895K, external 731K/1038K, paused 5ms+4ms
 06-22 17:33:35.582: DEBUG/dalvikvm(12302): GC_CONCURRENT freed 438K,
 54% free 2760K/5895K, external 731K/1038K, paused 5ms+4ms
 06-22 17:33:35.802: DEBUG/dalvikvm(12302): GC_CONCURRENT freed 566K,
 54% free 2765K/5959K, external 731K/1038K, paused 5ms+5ms
 06-22 17:33:36.002: DEBUG/dalvikvm(12302): GC_CONCURRENT freed 508K,
 54% free 2768K/5959K, external 731K/1038K, paused 5ms+4ms
 06-22 17:33:36.232: 

Re: [android-developers] Re: Jackson Object Mapping is so slow in the process with an Activity.

2011-06-23 Thread Kostya Vasilyev
Yeah, pretty much any application-side code takes a hit under the debugger,
not just JSON parsing.

Android API methods that are implemented as Binder (RPC) calls don't seem to
take a hit, but any Java code within the application does, and that includes
the framework as well.

Thanks for sharing the information, though.

You might want to test on a real device to get more real-world performance
numbers. The emulator (even 1.6 on a fast machine) is slower than a
mid-grade phone, and each version of Android gets progressively slower when
emulated.

-- Kostya

2011/6/23 idleSun idle...@gmail.com

 It turns out that it is slow when I run it in debug mode. So it is not
 a big deal. However, if you have a heavy jackson use and want to debug
 your code then you got to be really patient.


 On Jun 22, 10:59 am, idleSun idle...@gmail.com wrote:
  I am using pretty complicated JSON data with Object Mapping to Java
  Classes that are of course also pretty complicated (inheritance depth


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: Jackson Object Mapping is so slow in the process with an Activity.

2011-06-23 Thread Dianne Hackborn
Attaching the debugger turns off the JIT, and requires that Dalvik code
running in that process do some work to keep in sync with the debugger.
 When you do a Binder call, you are having code execute in another process,
which is not running under the debugger.

On Thu, Jun 23, 2011 at 9:37 AM, Kostya Vasilyev kmans...@gmail.com wrote:

 Yeah, pretty much any application-side code takes a hit under the debugger,
 not just JSON parsing.

 Android API methods that are implemented as Binder (RPC) calls don't seem
 to take a hit, but any Java code within the application does, and that
 includes the framework as well.

 Thanks for sharing the information, though.

 You might want to test on a real device to get more real-world performance
 numbers. The emulator (even 1.6 on a fast machine) is slower than a
 mid-grade phone, and each version of Android gets progressively slower when
 emulated.

 -- Kostya

 2011/6/23 idleSun idle...@gmail.com

 It turns out that it is slow when I run it in debug mode. So it is not
 a big deal. However, if you have a heavy jackson use and want to debug
 your code then you got to be really patient.


 On Jun 22, 10:59 am, idleSun idle...@gmail.com wrote:
  I am using pretty complicated JSON data with Object Mapping to Java
  Classes that are of course also pretty complicated (inheritance depth

  --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en




-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en