How to optimize network-queue-take in android Volley? (Volley Google IO 2013)
Asked Answered
S

1

9

Below is a snapshot of the Volley logs for an image request. Almost half of the rendering time is due to network-queue-take. Another one is even more dramatically high, the bulk of the time being in the network-queue-take. How can this be optimized so that network-queue-take is faster? What determines (other than thread priority, image requests are by default LOW priority requests), the speed of the network-queue-take?

Note: I ran this on Samsung Galaxy S4.

08-07 11:01:09.560: D/Volley(938): [1] MarkerLog.finish: (3662 ms) [ ]    http://farm6.static.flickr.com/5487/9452149004_c4ba6d2d97_t.jpg 0x8da7e4ac LOW 84
08-07 11:01:09.560: D/Volley(938): [1] MarkerLog.finish: (+0   ) [ 1] add-to-queue
08-07 11:01:09.565: D/Volley(938): [1] MarkerLog.finish: (+0   ) [12239] cache-queue-take
08-07 11:01:09.565: D/Volley(938): [1] MarkerLog.finish: (+0   ) [12239] cache-miss
08-07 11:01:09.570: D/Volley(938): [1] MarkerLog.finish: (+1694) [12243] network-queue-take
08-07 11:01:09.570: D/Volley(938): [1] MarkerLog.finish: (+1852) [12243] network-http-complete
08-07 11:01:09.570: D/Volley(938): [1] MarkerLog.finish: (+50  ) [12243] network-parse-complete
08-07 11:01:09.575: D/Volley(938): [1] MarkerLog.finish: (+21  ) [12243] network-cache-written
08-07 11:01:09.575: D/Volley(938): [1] MarkerLog.finish: (+0   ) [12243] post-response
08-07 11:01:09.580: D/Volley(938): [1] MarkerLog.finish: (+45  ) [ 1] done

Here is another one that takes even longer:

08-07 11:01:09.845: D/Volley(938): [1] MarkerLog.finish: (3871 ms) [ ] http://farm3.static.flickr.com/2827/9451437485_921584cdea_t.jpg 0x24a8bf69 LOW 85
08-07 11:01:09.860: D/Volley(938): [1] MarkerLog.finish: (+0   ) [ 1] add-to-queue
08-07 11:01:09.865: D/Volley(938): [1] MarkerLog.finish: (+1   ) [12239] cache-queue-take
08-07 11:01:09.870: D/Volley(938): [1] MarkerLog.finish: (+0   ) [12239] cache-miss
08-07 11:01:09.870: D/Volley(938): [1] MarkerLog.finish: (+2543) [12242] network-queue-take
08-07 11:01:09.875: D/Volley(938): [1] MarkerLog.finish: (+1280) [12242] network-http-complete
08-07 11:01:09.880: D/Volley(938): [1] MarkerLog.finish: (+26  ) [12242] network-parse-complete
08-07 11:01:09.885: D/Volley(938): [1] MarkerLog.finish: (+14  ) [12242] network-cache-written
08-07 11:01:09.885: D/Volley(938): [1] MarkerLog.finish: (+0   ) [12242] post-response
08-07 11:01:09.890: D/Volley(938): [1] MarkerLog.finish: (+7   ) [ 1] done
08-07 11:01:09.905: D/dalvikvm(938): GC_CONCURRENT freed 973K, 11% free 14796K/16583K, paused 12ms+6ms, total 56ms
Situs answered 7/8, 2013 at 18:7 Comment(0)
C
7

network-queue-take is taking time because you have a high number of requests running. If you have (by default) 4 threads running, and 8 requests, say all the first requests take exactly 500ms then the network-queue-take for the remaining requests will be 500ms, as it's waited 500ms to get a spot in the queue.

You can "eliminate" it by creating a RequestQueue with a higher than defualt DEFAULT_NETWORK_THREAD_POOL_SIZE, but keep in mind the default is there for a reason. If you for example download 20 images at the same time you can run into OOM conditions. However if you have a large number of low memory, and bad latency requests, increasing it should help your performance without risking oom conditions.

Cytherea answered 16/8, 2013 at 7:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.