After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 780210 - Thumbnailer gets the size of every page on startup
Thumbnailer gets the size of every page on startup
Status: RESOLVED FIXED
Product: evince
Classification: Core
Component: general
3.20.x
Other Linux
: Normal normal
: ---
Assigned To: Evince Maintainers
Evince Maintainers
Depends on:
Blocks:
 
 
Reported: 2017-03-17 16:52 UTC by Bastien Nocera
Modified: 2017-03-26 15:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
libdocument: Add "don't load cache" load flag (1.90 KB, patch)
2017-03-20 17:34 UTC, Bastien Nocera
committed Details | Review
libdocument: Allow passing flags to load functions (7.01 KB, patch)
2017-03-20 17:34 UTC, Bastien Nocera
committed Details | Review
FIXME: thumbnailer: Speed up thumbnailing (1.58 KB, patch)
2017-03-20 17:34 UTC, Bastien Nocera
committed Details | Review

Description Bastien Nocera 2017-03-17 16:52:36 UTC
Despite needing only the first page, the ev_document_load() gets the page size for *every* page in the document. This is not very expensive for cbz, but it all adds up:
** Message: comics_document_get_page_size took 0.004468 secs
** Message: comics_document_get_page_size took 0.005365 secs
(and that for the 600 pages of the "From Hell" comic book)

That's about 3 seconds getting data we won't use. Short-circuiting the calls for everything but the first page means that the thumbnailing (with libarchive backend) goes from 2.5 seconds to less than a tenth of a second.

  • #0 comics_document_get_page_size
    at /home/hadess/Projects/jhbuild/evince/backend/comics/comics-document.c line 294
  • #1 comics_document_get_page_size_wrap
    at /home/hadess/Projects/jhbuild/evince/backend/comics/comics-document.c line 513
  • #2 _ev_document_get_page_size
    at /home/hadess/Projects/jhbuild/evince/libdocument/ev-document.c line 636
  • #3 ev_document_setup_cache
    at /home/hadess/Projects/jhbuild/evince/libdocument/ev-document.c line 212
  • #4 ev_document_load
    at /home/hadess/Projects/jhbuild/evince/libdocument/ev-document.c line 337
  • #5 ev_document_factory_get_document
    at /home/hadess/Projects/jhbuild/evince/libdocument/ev-document-factory.c line 313
  • #6 evince_thumbnailer_get_document
    at /home/hadess/Projects/jhbuild/evince/thumbnailer/evince-thumbnailer.c line 142
  • #7 main
    at /home/hadess/Projects/jhbuild/evince/thumbnailer/evince-thumbnailer.c line 269

Comment 1 José Aliste 2017-03-17 17:04:48 UTC
Hi Bastien, is it a rule that comics documents have the same page size for all pages?
Comment 2 Bastien Nocera 2017-03-17 17:08:49 UTC
No, but why would the thumbnailer get the page sizes for *all* the pages when it's only going to use the first one?
Comment 3 José Aliste 2017-03-17 17:15:29 UTC
Oh... my bad... I was thinking on Thumbnail sidebar instead of thumbnailer...
Comment 4 Bastien Nocera 2017-03-20 17:34:08 UTC
Created attachment 348338 [details] [review]
libdocument: Add "don't load cache" load flag
Comment 5 Bastien Nocera 2017-03-20 17:34:15 UTC
Created attachment 348339 [details] [review]
libdocument: Allow passing flags to load functions
Comment 6 Bastien Nocera 2017-03-20 17:34:21 UTC
Created attachment 348340 [details] [review]
FIXME: thumbnailer: Speed up thumbnailing

By not loading the page cache for all the pages, but only the first one.
Comment 7 Bastien Nocera 2017-03-20 17:38:48 UTC
Comment on attachment 348340 [details] [review]
FIXME: thumbnailer: Speed up thumbnailing

This should instead do what's in ev_document_setup_cache() when there's no cache setup for the page and we're calling ev_document_get_page_size().

But I don't know how we'd handle the "uniform" parameter to EvDocument.

This is an easy optimisation though, going from around 4.7 seconds to 1.25 seconds thumbnailing the "From Hell" comic (nearly 600 pages) using the libarchive backend.
Comment 8 Carlos Garcia Campos 2017-03-26 11:05:02 UTC
Comment on attachment 348338 [details] [review]
libdocument: Add "don't load cache" load flag

I've pushed this and a follow up to load the cache ondemand only when needed for things like getting max/min sizes, uniform etc.
Comment 9 Carlos Garcia Campos 2017-03-26 11:05:19 UTC
Comment on attachment 348339 [details] [review]
libdocument: Allow passing flags to load functions

Pushed.
Comment 10 Carlos Garcia Campos 2017-03-26 11:06:02 UTC
Comment on attachment 348340 [details] [review]
FIXME: thumbnailer: Speed up thumbnailing

I've pushed this without the change in the comics backend, because I don't understand it, and I'm not sure it's needed.
Comment 11 Carlos Garcia Campos 2017-03-26 11:06:58 UTC
So, I've done some tests and the cache is never loaded when using the thumbnailer now. Please, tests it and reopen this if there are still problems.
Comment 12 Bastien Nocera 2017-03-26 15:47:42 UTC
(In reply to Carlos Garcia Campos from comment #10)
> Comment on attachment 348340 [details] [review] [review]
> FIXME: thumbnailer: Speed up thumbnailing
> 
> I've pushed this without the change in the comics backend, because I don't
> understand it, and I'm not sure it's needed.

The comics backend change was a hack, it would try to load only one page instead of all of them, to work-around the cache population hitting every page. It wasn't needed once you added the on-demand caching.