View Single Post
Old 03-24-2013, 07:49 AM   #9
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
The template {formats} is evaluated in several steps.

1) When {formats} is referenced for a book, check if it has been resolved and cached for that book. If so, return that value.
2) If the formats for a book have not been resolved, then verify the formats for the book. For each format:
- Check if that format has been resolved in the past. If so, use those values. This cache can be cleared if the content server is running and determines that its view of the database is out of date.
- If the format has not been resolved, do a "stat()" on the format file. Cache the path, the size, and the modtime of the format. Return these values. Return an empty record if the format does not exist.
3) If {formats} is never referenced, never do either step 1 or step 2.

The effects of the caches make getting consistent results from timing tests rather problematic. For example, sorting on {formats} will fill both caches. From that time forward, there will be no disk access. Which cache is used depends on the test.

The "treacle" test should be done in a way that ensures that the caches have not been filled. Something like:
- Ensure that the {formats} column is not in the startup sort set.
- Start calibre.
- Scroll down.

My guess is that calibre will be noticeably slower scrolling when there is a {formats} column. It must do a stat on each format for the book before it can display the book line. The approximate_formats() function avoids this work.
chaley is offline   Reply With Quote