mozilla / MozStumbler

Android Stumbler for Mozilla
http://location.services.mozilla.com
Mozilla Public License 2.0
620 stars 212 forks source link

Upload Alarm Scheduling: consider uploading small chunks, instead of bulk upload #740

Open garvankeeley opened 10 years ago

garvankeeley commented 10 years ago

Follow up to Issue #738.

The upload scheduler uses an Android alarm, and when it runs, it uploads all the batched data. This can saturate the upload bandwidth. Would it be better to upload for a max amount of time (30s?), then schedule another alarm in 1-2 mins to repeat the process.

Djfe commented 10 years ago

You should consider that too many entries could use up too much memory if you want to compress and upload them all at once. -> Out of memory

Could we use the new functions in Kitkat that tell you how much memory is free still?

Djfe commented 10 years ago

https://developer.android.com/training/articles/memory.html#CheckHowMuchMemory

garvankeeley commented 10 years ago

It would be ok, it uploads the batches synchronously, and a 'batch' ranges from 1-20 kb. At most 2 batches are held in memory during upload.

If I was to gather a few MB of data (perhaps travelling) without uploading, and then walk into my house and start uploading, it would saturate my upload for a few minutes (note to self: upgrade your internet connection). Of course, this is no different than all the online sync services I use: dropbox and google drive. Dropbox has a bandwidth limiter, which I don't like because I would have to change it from office to home, or even different times of the day. Uploading could be done in a burst-pause cycle, which briefly saturates the upload instead of holding the network at the saturation point. That would be very easy to implement because of the way the code is structured.