Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 03-15-2012, 04:42 AM   #1
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: 12,336
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Changes in template evaluation in V0.8.43

I have made some changes in how templates are evaluated to improve performance.

1) Improvements in the base functions that fetch the metadata used by templates. The performance improvement varies from 10 to 15%. For example, on my 20,000-book test library with three custom columns (int, text/tags-like, and composite), and sorting on the composite column (worst case), startup time went from 21 seconds to 19 seconds.

2) Compilation of general program mode templates. Calibre now tries to convert general program mode templates to python to improve their performance. The performance improvement depends on the complexity of the template. For simple templates (one function), it doesn't help much. For more complex templates, it can help a lot. For example, if the composite column in the 20,000-book library being sorted contains the following template:
Code:
program: 
#	fs = formats_sizes();
	fs = "";
	v = select(fs, 'PRC');
	v = add(v, select(fs, 'EPUB'));
	v = add(v, select(fs, 'MOBI'));
	v = add(v, select(fs, 'TXT'));
	v = add(v, select(fs, "\'LIT"));
	v = format_number(v, '{0:5.0f}');
	human_readable(v)
then the performance improvement is 30%. On my machine the startup times are:
Code:
Calibre 0.8.42:                   21.1 seconds
New version w/o compilation:      19.1 seconds
New version w/compilation:        14.6 seconds
Either, startup sorting on title:  7.0 seconds
It is possible that the generated code is incorrect (bugs). If this should happen to you, then you can turn off compilation by setting the tweak "Compile General Program Mode templates to Python" to False. Before you do that, please file a bug report. Provide the template and the generated code, which is displayed if you run calibre in debug mode.

Performance of single-function- and template-program-mode templates are improved by the changes described in 1) above. They are not compiled, so do not benefit from the changes described in 2).

Converting complicated template-program-mode templates to GPM will improve performance. I added a new template function to assist with this: finish_formatting. This function formats the value and adds a prefix and/or a suffix in the same way that the {||} syntax does in non-GPM templates. For example, the template
Code:
{series:re(([^\s])[^\s]+(\s|$),\1)}{series_index:0>2s| - | - }{title}
can be written using GPM as
Code:
program: 
    strcat(
        re(field('series'), '([^\s])[^\s]+(\s|$)', '\1'), 
        finish_formatting(field('series_index'), '0>2s', ' - ', ' - '),
        field('title')
    )
chaley is offline   Reply With Quote
Old 03-16-2012, 03:12 PM   #2
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: 12,336
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
First bug. Sigh... It is the little things that go wrong.

Incorrect code is generated if the last character of the GPM template is a semicolon. Fixed in the next release.

The workaround: remove that last semicolon.
chaley is offline   Reply With Quote
Advert
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
E-book app evaluation on the HTC Touch Pro 2 Steven Lyle Jordan Alternative Devices 36 09-28-2010 11:17 AM
Difference between evaluation vs registered version of bookwise librarian? askyn Fictionwise eBookwise 2 10-09-2008 05:26 PM
Best for Microsoft Word - potential University evaluation tomliversidge Which one should I buy? 24 07-03-2008 07:46 AM
An e-ink competitor ready to step up? SiPix Offers 'Evaluation Package' NatCh News 2 10-27-2006 10:59 PM


All times are GMT -4. The time now is 10:12 PM.


MobileRead.com is a privately owned, operated and funded community.