View Issue Details

IDProjectCategoryView StatusLast Update
0011233MMW v4Synchronizationpublic2013-09-13 02:42
ReporterLudek Assigned To 
PriorityurgentSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version4.1 
Target Version4.1Fixed in Version4.1 
Summary0011233: WiFi sync: Improve performance of "Analyzing sync list" phase
DescriptionCurrently if user performs WiFi from MMA/MM8 and doesn't change anything (no track updated/added/removed) then one would expect that next WiFi sync should take just a second. In fact it can take minutes for large sync-lists, because MMA/MM8 downloads whole sync-list.

MMA needs to read whole sync-list when
- [x] Delete unsynced tracks is enabled -- so that MMA knows which files should be deleted
- [x] Auto-sync to server is enabled --- so that MMA knows what to copy to PC
- user deleted some tracks in MMA, such a tracks are expected to be re-downloaded on next sync (supposing they are still on sync-list)

But in default config both the checkboxes are disabled and user may not delete any file in MMA. In such a case MMW could serve empty sync-list if nothing has changed from the last sync (no track updated, no track added, no track deleted in MMA).

It should work as follows:
On the beggining of WiFi sync MMA should tell MMW whether it needs the whole sync-list or whether the shortened sync-list (inclding only updated/added tracks) is enough.

MMA can decide it based on these conditions:
- no track has been deleted in MMA from the last sync
- [ ] Delete unsynced tracks is disabled
- [ ] Auto-sync to server is disabled or no new track needs to be uploaded

Tech details:
- MMW needs to remember the last served sync-list, because sync-list is dynamic (auto-playlists rules etc.) so that MMW could serve only added/updated tracks
- MMA needs to remember whether a track has been deleted from the last auto-sync

Additional InformationWhen we were proposing WiFi sync workflow in the past with Jiri and Marek, we also had discussed this approach:
- MMA uploads its DB (mmstore.db) to MMW server
- MMW processes mmstore.db
- MMA downloads processed mmstore.db

This approach would have some advantages:
- it would be very similar workflow as in case of USB sync (same code could be used)
- MMW would know MMA's content

But also disadvantages:
- MMA would need to upload its DB on each sync, this wouldn't be effective for large DBs with many tracks
- WiFi sync would be too tied to MMA.DB structure (making harder to maintain) and making troubles when implementing sync with another general client (like MM8)
- wouldn't be much usable for the future cloud sync
TagsNo tags attached.
Fixed in build1657

Relationships

parent of 0011270 closedmarek MMW v4 Wifi Sync: sync fails when it involves deletion of certain files 
parent of 0011302 closedLudek MMW v4 SQL error on portable installation 
related to 0011263 closedmarek MMA WiFi sync: Improve performance of "Analyzing sync list" phase 

Activities

Ludek

2013-09-04 20:18

developer   ~0037424

Last edited: 2013-09-04 21:06

Note that the workflow suggested above wouldn't be so necessary if MMA would be able to analyze sync-list faster. Currently the sync-list download itself is only 3.3% of the whole processing time, the rest is parsing and DB operations. Marek is currently studing (running profiler) what takes so long when processing sync-list.

If MMA won't be able to reduce the parsing time then MMW could serve the whole sync-list in separate SQLite DB file including two tables SyncList and Playlists. This way MMA wouldn't need to parse DIDL-Lite XML, but can read the sync-list directly from DB file. But all the aspects (pros and cons) needs to be revised/evaluated.

peke

2013-09-04 23:22

developer   ~0037427

Last edited: 2013-09-04 23:32

This is generally true, but thing I thought about is that:
- Full DB is Uploaded only on Pairing or When Pairing DB is not newer than one on MMW (Eg. MMW would save last DB from sync per device) especially as MMA would GET Latest DB from MMW at the end of Sync which will than be new DB in MMA and all changes to MMA/Device would be reflected in second DB that would reflect only changes and would be much smaller even in case of large number of files.
Example MMA -> MMW = DB Version is 001, MMW -> MMA = Correct Send me latest DB Changes, MMA -> MMW = Changes Sent Waiting for sync, MMW -> MMA = Execute these updates now (Tags, new Files, Delete Files, ....), MMA -> MMW = Done, Send me updated DB Changes, MMW -> MMA = Merge Changes with This DB adn Make it current. Also MMA would announce its version to MMW and MMW would check Compatibility eg. In case of incompatibility Announce user what version needs to be updated and why, which eliminate regressions and bug risks. Like now when users wants to use Newer MMA feature that is implemented in 4.1 but user have 4.0 (Playlist sync for example).

- As MMW would have full MMA DB stored Locally MMA could Announce itself that is ready for sync and send Last DB HASH checks MD5/SHA1, MMW would start to prepare Sync-List, which will allow MMA to send Updates after last sync (Tags,Ratings, Play Counts, Playlists, Deletions,...), MMW would merge updates and correct sync list, Create New mmstore.db and mmstore.db.Sync that would tell MMA to fetch tracks for sync instead parsing and DB operations MMA will Execute sync based on mmstore.db.Sync -> after complete it would delete it and load new and updated mmstore.db. This would eliminate parsing and DB operations. eg. like on web when you migrate Databases MMW would get pre-prepared *.SQL call script that would be simply executed instead of parsing and complicated DB operations that would bottleneck device (that is why iTunes Initiate Factory reset not device itself)

- Doesn't already MMx client announce itself to MMW so that reads correct DB structure like in USB Sync?

- On MMW side we would use same structure but for each MMx Client app (MMA or MM8) we would have own importer/merger/exporter for DB. Which will allow us to for example do something that no other app is capable. eg. Move/Clone Device profiles among devices like Migrate MMA DB/files/Playlist/Sync Settings from HTC one X -> MM8 Nokia Lumia 920.

My guess is that approach would considerably increase sync analyze speed.

re disadvantages:
- In my approach there is no need for complete upload only changed data would be sent and even 3000 tracks changes is not that big. Full syncs would be done only in cases where DB is essentially changed like on Firmware updates where physical path is changed. Even MMW take some time to Update DB to current version.

- As Device plugin would handle DB format based on Client that initiated sync. Isn't it easier and faster to change how device plugin works than sync/test changes in both MMA/MM8 with MMW changes/updates. Which would also avoid issues like now where we can't release MMW until all bugs are hammered in MMA too and via verso.

- From my point wouldn't cloud sync be a same thing? An stored local DB hash checked with Cloud and sync changes?

Ludek

2013-09-09 22:10

developer   ~0037449

Last edited: 2013-09-09 22:19

As discussed with Marek and Jiri today, the most easy, regressionless and problably the best solution is to retain current workflow and enhance it slightly by adding following steps:

- MMA sends to MMW comma separated list of tracks IDs that are actually presented on the device (previously synced). MMW will exclude these tracks from sync-list unless they have been modified in MMW (e.g. changed rating, changed auto-convert rule)

- if enabled, MMA asks MMW for list of tracks that needs to be deleted from the device (are no longer presented on sync-list)

All should be backward compatible, so if MMA finds that it is an older MMW build (that doesn't know the new steps/commands), then it uses the current workflow

Ludek

2013-09-10 22:53

developer   ~0037460

Implemented for MMW+MM8, to be implemented for MMA by Marek.

marek

2013-09-11 22:26

developer   ~0037473

Implemented for MMA

peke

2013-09-13 02:42

developer   ~0037518

Verified 1657 and 163