papermerge-core icon indicating copy to clipboard operation
papermerge-core copied to clipboard

A 50-page pdf file is very slow to open

Open luyuanerp opened this issue 2 years ago • 2 comments

A 50-page pdf file is very slow to open, and it takes 10 minutes to open it all. What is the reason? WX20220831-090241@2x WX20220831-090301@2x

luyuanerp avatar Aug 31 '22 01:08 luyuanerp

Good one. I need to optimize. I cannot answer yet why it is slow, need to investigate. In any case, thank you for heads up!

ciur avatar Aug 31 '22 04:08 ciur

This one is tricky. In short, the problem is that Backend REST API server (i.e. Django application) is serving dynamic files ( i.e. files for each individual page). It would be more efficient to off load serving of the dynamic files to another, specialized service (e.g. nginx).

In your case, when you open a document with 50 pages, and each page is say 1 MB (or maybe 500k ?) and Backend (application) is trying to serve all those files at once. If you combine with the fact that each page preview is also generated at that moment + maybe there is some OCR in background, then there may be no wonder that it is slow.

So far, I did not give much thought to optimizations and I am sure I will find many ways to speed up this part.

ciur avatar Sep 15 '22 18:09 ciur