>I feel that it is too long and weird, so I restart my Emacs daemon, and the
>results do not change.
Just moments ago, I test it in other way. I stay the buffer view in the end of
my org file, where there are many fragments. When I execute
(my-org-latex-preview-benchmark), it only takes 0.5s-1s, I think, to compile
all fragments and show the results on the screen. But the result of
(my-org-latex-preview-benchmark) would be shown on the message buffer after
some seconds, and its results is stable around 5.5s.
Yu Huang
---- Replied Message ----
FromYu Huang<hyto...@stu.pku.edu.cn>Date3/29/2025 12:04ToKarthik
Chikmagalur<karthikchikmaga...@gmail.com>CcIhor Radchenko<yanta...@posteo.net>,
emacs-orgmode@gnu.org<emacs-orgmode@gnu.org>SubjectRe: org-persist-write:index
takes minutes to run
Could you run this code, then run M-x my-org-latex-preview-benchmark on your
file and report the time? (You should avoid the precompilation first by
previewing a single fragment first.)
Ok, I test several times, in an org file with about 700 fragments. I test first
in my current workspace (without restarting). When turning on precompilation,
the time is stable around 5.5 seconds; while when turnning off precompilation,
the time is stable around 6 seconds.
I feel that it is too long and weird, so I restart my Emacs daemon, and the
results do not change.
Previously, I mentioned the 2-3 seconds based on my naked-eye perception.
Today, I noticed that it seems to prioritize displaying fragments within the
viewpoint. (This maybe the display optimization of org-mode itself)
And I try to make a profiler report. I started profiler, executed
(my-org-latex-preview-benchmark), and stopped profiler when I saw the result
time in the message buffer.
The profiler is strange. The total consuming time is only 2-3s and modeline
redisplay takes lots of time.(I don't know how modeline works and why they
would appear in this profiler)
And (org-latex-preview '(16)) only takes 0.1s.
In fact, I don't know whether my approach to testing the profiler here is
correct.
If time consumption of (org-latex-preview '(16)) is true, maybe the naked-eye
phenonemon before is reasonable, it is really so fast and does not prioritize
any fragments.
P.S. My Emacs works on wsl2, based on the core of Ubuntu-22.04. Its version is
30.1 and the compilation configuration is as follows:
"--with-x-toolkit=lucid --with-imagemagick -C --with-native-compilation
--with-rsvg 'CFLAGS=-O2 -march=native -mtune=native -fomit-frame-pointer'
--with-png --with-jpeg --with-mailutils".
Yeah, I use lucid.
P.S.2. I also identified the overide of autosync mode in this prodiler, so I
conducted two tests, one with autosync enabled and the other without. The
results show only a slight discrepancy.
Yu Huang
---- Replied Message ----
FromKarthik Chikmagalur<karthikchikmaga...@gmail.com>Date3/29/2025
07:18To黄煜<hyto...@stu.pku.edu.cn>,
Ihor
Radchenko<yanta...@posteo.net>ccemacs-orgm...@gnu.org<emacs-orgmode@gnu.org>SubjectRe:
org-persist-write:index takes minutes to run
The overall current performance is quite satisfactory. I describe in
two cases as Karthik's classification.
1. When running org-latex-preview-all inside an org file (about 700
fragments), Emacs is not unresponsive in comparison to the past, and
the fragments rendering is much more faster than before (taking 2-3s
approximately on my modern processor, an R7-5800H).
2-3s for 700 fragments is quite slow on a high-end processor like the
5800H. It takes 2-3 seconds for 600 fragments on a 2012 mid-range
Thinkpad. Could you run this code, then run M-x my-org-latex-preview-benchmark
on your file and report the time? (You should avoid the precompilation
first by previewing a single fragment first.)
--8<---------------cut here---------------start------------->8---
(defvar my-org-latex-preview-benchmark-time 0.0)
(defun my-org-latex-preview-benchmark-finish (&rest _)
(setq my-org-latex-preview-benchmark-time
(- (float-time) my-org-latex-preview-benchmark-time))
(message "Run took: %.4f seconds" my-org-latex-preview-benchmark-time))
(add-hook 'org-latex-preview-process-finish-functions
'my-org-latex-preview-benchmark-finish)
(defun my-org-latex-preview-benchmark ()
(interactive)
(garbage-collect)
(setq my-org-latex-preview-benchmark-time (float-time))
(org-latex-preview '(16)))
--8<---------------cut here---------------end--------------->8---
You can then repeat the experiment after clearing the cache (with M-x
org-latex-preview-clear-cache) and turning off org-persist with:
(setq org-latex-preview-cache 'temp)
I would be interested in the difference in time taken.
Karthik