09-17-2018, 11:54 PM | #1 |
Plugin Developer
Posts: 6,307
Karma: 3966249
Join Date: Dec 2011
Location: Midwest USA
Device: Kindle Paperwhite(10th)
|
Send metadata to device Slow on 2nd Kindle Voyage?
I have a three year old Kindle Voyage that I love. A 'Send metadata to device' job after updating a few books on it takes 15-30 seconds.
I just bought a 2nd Kindle Voyage(new from Amazon) for a backup (it looks like Amazon is dropping Voyage). A 'Send metadata to device' job after updating a few books on the new one takes 3-5 minutes. This is after the background book indexing has finished for the books already loaded--that took a few days. I recall that something changed in Calibre a while back that vastly improved 'Send metadata to device' time. Is there some setting I have forgotten? Or some other hint why it's so much slower? Thanks. |
09-18-2018, 04:43 AM | #2 |
creator of calibre
Posts: 43,843
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
run calibre in debug mode too see exactly what is taking so long
|
09-18-2018, 09:38 AM | #3 |
Plugin Developer
Posts: 6,307
Karma: 3966249
Join Date: Dec 2011
Location: Midwest USA
Device: Kindle Paperwhite(10th)
|
Here's a debug log from each showing a small update.
Aside from some re-ordering and old Kindle getting 2 books vs 1 for new Kindle, I don't see anything in the logs. But hopefully you can. See attached. Last edited by JimmXinu; 09-18-2018 at 09:38 AM. Reason: correct spelling |
09-18-2018, 10:16 AM | #4 |
creator of calibre
Posts: 43,843
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Nothing jumps out at me. Try adding some more debugs into the sync_booklists() function in usbms/driver.py and see where inside that unction it is taking long. If I had to guess I would choose lines 445-447
|
09-18-2018, 11:49 AM | #5 |
Plugin Developer
Posts: 6,307
Karma: 3966249
Join Date: Dec 2011
Location: Midwest USA
Device: Kindle Paperwhite(10th)
|
I was unable to run using CALIBRE_DEVELOP_FROM pointing to the current GitHub master. Unrelated to the issue I'm having, but thought you'd want to know. Details:
Spoiler:
Going back to the v3.31.0 tag worked. I turned on cProfile around sync_booklists: Spoiler:
Results with new Kindle: Spoiler:
It looks like the lion's share of the time is in method 'write' of 'file' objects. By contrast, here's the same for the old Kindle: Spoiler:
The number of writes is the same (only 9), but the time length is radically different. It does not look like it's the same processing between the two. For example method 'get' of 'dict' objects is called ~400k times on the old Kindle and 5.5m times on the new one. |
09-18-2018, 11:55 AM | #6 |
creator of calibre
Posts: 43,843
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Yeah currently running from master is broken, because of some ongoing py3 compat work. I should have told you that, sorry.
write being slow indicates device issues. It may be possible to work around it by changing the code to use a single write instead of mltiple ones. essentially change the json serialization to output a string whichis written to the file in one write call. |
09-18-2018, 11:59 AM | #7 |
creator of calibre
Posts: 43,843
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Oh and unless the metadata and books on the two kindles are identical, the various other calls will be expected to be different.
|
09-18-2018, 12:00 PM | #8 |
creator of calibre
Posts: 43,843
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Sorry scratch that, I took a look at the code and it is already doing that. Dont have any more (not very) bright ideas.
|
09-18-2018, 12:19 PM | #9 | |
Plugin Developer
Posts: 6,307
Karma: 3966249
Join Date: Dec 2011
Location: Midwest USA
Device: Kindle Paperwhite(10th)
|
Quote:
Or so I thought. metadata.calibre is 16M on the old Kindle and 180M on the new one. Which would explain the difference in write time. Guess I should have checked that first. Now the question is: Why are the metadata.calibre file sizes so different with the same ebooks from the same library? |
|
09-18-2018, 01:36 PM | #10 |
Plugin Developer
Posts: 6,307
Karma: 3966249
Join Date: Dec 2011
Location: Midwest USA
Device: Kindle Paperwhite(10th)
|
Examining the contents of the metadata.calibre files, I find that the new one has complete user_metadata and thumbnail for all ebooks from the library.
The old device file has those for some ebooks (newer ones) but they are null / {} for most. The contents of the user_metadata and thumbnail elements make up ~95% of the 178M metadata.calibre file on the new device. Removing them brings it down to roughly the same size. Since the old device doesn't have values for these, clearly they aren't necessary for Kindle. Is there a tweak or option somewhere I could use to not send them to the device? And if not, would you object to having such a tweak or option? |
09-18-2018, 08:46 PM | #11 |
Plugin Developer
Posts: 6,307
Karma: 3966249
Join Date: Dec 2011
Location: Midwest USA
Device: Kindle Paperwhite(10th)
|
FYI, I've made a github PR for this that is working for me.
Requires a change to Tweaks so it doesn't effect anyone who doesn't specifically set it, but for me, it reduces time to send metadata from 5 minutes to <10 seconds. |
09-18-2018, 11:03 PM | #12 |
creator of calibre
Posts: 43,843
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
The thumbnails are used in the device view in calibre. IIRC the user_metadata was added to support the wifi device connection/calibre companion use case.
I'm somewhat surprised that the old voyage does not have those data. All (reasonably modern) kindles share the same driver as far as I know. And all the kindle drivers delegate the creation of metadata.calibre to usbms/driver.py I'd like to track down why the old voyage does not have that data available, if possible. Rather than a tweak, it is probably better to allow individual device drivers to specify if they need user_metadata or not. Not to mention that a tweak could allow users to exclude arbitrary metadata which can lead to subtle and hard to diagnore bugs. I'd rather not remove the thumbnails, since as I said they are used by calibre itself, for the covers in the device view. |
09-18-2018, 11:39 PM | #13 | ||
Plugin Developer
Posts: 6,307
Karma: 3966249
Join Date: Dec 2011
Location: Midwest USA
Device: Kindle Paperwhite(10th)
|
Quote:
But I can tell you that out of a library of ~5300 with daily updates, only 238 have thumbnails & user_metadata. That's about a month worth of updates. Quote:
Because I consider a savings of 5 minutes (frequently several times a day) and ~170M of device storage more than worth giving up thumbnails on device and some redundant metadata. |
||
09-19-2018, 12:05 AM | #14 |
creator of calibre
Posts: 43,843
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
There definitely haven't been any (intentional) changes to sending thumbnails in the last month.
What is the breakup of the data in thumbnails vs user metadata? user_metatata I am willing to get rid of on a per device basis. Thumbnails can be fixed in one of several ways: 1) Stop storing them in metadata.calibre and instead use a subdirectory named calibre-thumbnails or similar. That way update jobs dont have to resend all thumbnails on every update. 2) Make it a per device driver thing. For instance e-ink kindles have calibre send thumbnails as separate files already. the driver could be changed to use those and not store thumbnails in metadata.calibre |
09-19-2018, 12:11 PM | #15 |
Plugin Developer
Posts: 6,307
Karma: 3966249
Join Date: Dec 2011
Location: Midwest USA
Device: Kindle Paperwhite(10th)
|
Of ~178M, ~118M thumbnails, ~50M user_metadata and ~7M everything else. (No, it doesn't add up--FAT32 size differences.)
Kindle Voyage is an e-ink kindle--unless that means something else specifically. If there are thumbnails as separate files, I don't see them. Plus, writing them as separate files helps with write time, but makes storage worse. Due to the fact that calibre reads metadata.calibre, updates only changed books and then writes it again, simply removing thumbnails and user_metadata from my metadata.calibre when it gets too slow is a viable 'solution'. Apparently I've already been using that for months, because I'm sure it was longer ago than that it sped up for me. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Determine what metadata to send to device | sun_reads | Devices | 0 | 10-03-2017 01:56 PM |
Kindle Voyage metadata transfer very slow | HarryT | Devices | 6 | 11-08-2014 12:36 PM |
Send to device based on Metadata | DavidTC | Calibre | 0 | 09-18-2011 01:18 PM |
send book to device too much slow | danizzz | Calibre | 0 | 06-23-2010 07:38 AM |
Send to Device & Metadata | Bob Butler | Calibre | 18 | 02-22-2009 09:33 PM |