pdf-tools
pdf-tools copied to clipboard
emacs is slow when the pdf buffer is large
Describe the bug When I read a pdf normally and the buffer is the only one, scrolling is very slow. But if I clone the buffer so that the resulting two buffers are smaller, scrolling is way smoother and faster.
Steps to Reproduce the behaviour
- Open a pdf
- scroll
What is the expected behaviour? It should be faster
Desktop
- OS: Gentoo Linux
- Emacs Version: GNU Emacs 29.3 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.39, cairo version 1.18.0) of 2024-03-27
- Poppler Version: 24.02.0
Your pdf-tools install Please complete the following information:
pdf-toolsVersion:
Status: Available from nongnu -- Install
Archive: nongnu
Version: 1.1.0
Commit: a9c9a12c3ecf2005fa641059368ac8284f507620
Summary: Support library for PDF documents
Requires: emacs-26.3, tablist-1.0, let-alist-1.0.4
Website: https://github.com/vedang/pdf-tools/
Keywords: files multimedia
Maintainer: Vedang Manerikar <[email protected]>
Author: Andreas Politz <[email protected]>
Additional context Here's what I got during profiling:
5068 96% - command-execute
4794 91% - funcall-interactively
4789 91% - mwheel-scroll
4771 91% - pdf-view-scroll-up-or-next-page
4762 91% - pdf-view-next-page
4762 91% - pdf-view-goto-page
4757 90% - pdf-view-redisplay
4757 90% - pdf-view-display-page
246 4% + pdf-view-create-page
2 0% + internal--before-save-selected-window
2 0% + doom-modeline-update-pdf-pages
1 0% image-mode-window-put
9 0% + image-scroll-up
8 0% + pdf-view-scroll-down-or-previous-page
5 0% mouse-wheel--get-scroll-window
2 0% + run-with-timer
5 0% + execute-extended-command
274 5% + byte-code
156 2% + #<compiled -0x726034f3b8bc27b>
6 0% + redisplay_internal (C function)
2 0% + timer-event-handler
0 0% + ...
the pdf-view-display-page function seems to be the deepest one that takes the most time
In my case, I was able to speed up pdf-view by optimizing the pdf.