View Single Post
Quote:
Originally Posted by Chris View Post
I'm counting the time after the "Opening document" progress bar disappears. Is the document still loading after that? This morning it was quite fast, just a couple seconds after that. Probably because I hadn't done anything since yesterday. If I turn off autosync, startup is quite fast, less than 5 seconds.
Ken may hop on to correct me, but once the "opening document" screen disappears, we still have some work to do.

Spinner: contacting sync server to see if there are any new transactions we need to download (and, if so, getting them).

"Opening Document" means we're reading existing data from flash into RAM on the phone.

Once we do that, at a bare minimum, we have to check the existing data for any state changes. (Unavailable/available/overdue changes, for instance.) If there was a sync, we have to integrate any new transactions into the database. Best case scenario, we tack the new transactions onto the end of the transaction tree that's on the phone and roll everything forward. That's likely what's happening during the 5 second sync you mentioned.

However, if we have synced transactions from the network that occurred before the most recent transaction on the device, we have to roll the transactions on the phone back to before the first synced change, insert the synced changes, then walk back to the present, resolving any conflicts we encounter as we go.

The 30-second syncs likely have some of this going on. Again, Ken may correct me, but I'm guessing that any state changes that happened overnight - actions changing between unavailable/available/overdue - are going to generate transactions on both the phone and the Mac. (You don't want the phone to depend on the Mac to tell you when those changes happen.) We have to reconcile those in some fashion...

In general, there's a fair amount going on in a sync beyond the changes that you may have made manually. From one perspective, managing to get a device with a processor that's literally 2000 times slower than a low-end desktop machine to only take 30 times as long to do all that is something of a victory. I also concede that it can be frustrating, though. ;-)

Last edited by Brian; 2009-05-05 at 03:13 PM.. Reason: add the state-change stuff, once I thought of it.