Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ~30s to load Source Han CJK fonts #279

Open
Firestar-Reimu opened this issue Apr 4, 2024 · 10 comments
Open

Use ~30s to load Source Han CJK fonts #279

Firestar-Reimu opened this issue Apr 4, 2024 · 10 comments

Comments

@Firestar-Reimu
Copy link

Firestar-Reimu commented Apr 4, 2024

Issue maybe related to #49

Multiple tests see CTeX-org/ctex-kit#708

in a simple mwe:

\documentclass[a4paper,fontset=none]{ctexart}

\setCJKmainfont{Source Han Serif CN}[BoldFont=Source Han Sans CN Medium]

\title{\textbf{作业}}
\author{作业}
\date{2024年3月29日}

\begin{document}

\maketitle

正文

\end{document}

It take ~44s to compile and although luaotfload generate font cache, the next compile still need ~44s

@zauguin
Copy link
Member

zauguin commented Apr 4, 2024

I don't have the FZKai-Z03 font, so maybe that is causing your issue, but otherwise I can't reproduce this.

After initially building the caches I get further runs in 2.6 seconds. That's slow, but much faster than 44s and not primarily caused by luaotfload. This was tested with system fonts in Arch Linux.

Do you still have the issue also without FZKai-Z03 and can you send an example without ctex?

Please also attach your log file.

@Firestar-Reimu
Copy link
Author

Sorry I changed the MWE so that no FZKai-Z03 is required. It is just Source Han's fault.

@Firestar-Reimu
Copy link
Author

Firestar-Reimu commented Apr 6, 2024

console output

(base) [firestar@Archlinux Documents]$ latexmk -lualatex -bibtex -synctex=1 -interaction=nonstopmode -file-line-error --shell-escape mwe2.tex
Rc files read:
  NONE
Latexmk: This is Latexmk, John Collins, 31 Jan. 2024. Version 4.83.
No existing .aux file, so I'll make a simple one, and require run of *latex.
Latexmk: applying rule 'lualatex'...
Rule 'lualatex':  Reasons for rerun
Category 'other':
  Rerun of 'lualatex' forced or previously required:
    Reason or flag: 'Initial setup'

------------
Run number 1 of rule 'lualatex'
------------
------------
Running 'lualatex  -synctex=1 -interaction=nonstopmode -file-line-error --shell-escape -recorder  "mwe2.tex"'
------------
This is LuaHBTeX, Version 1.18.0 (TeX Live 2024) 
 system commands enabled.
(./mwe2.tex
LaTeX2e <2023-11-01> patch level 1
L3 programming layer <2024-03-14>
 (/home/firestar/.texlive/2024/texmf-dist/tex/latex/ctex/ctexart.cls
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/ctex/config/ctexbackend.cfg)
 (/home/firestar/.texlive/2024/texmf-dist/tex/latex/l3kernel/expl3.sty
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/l3backend/l3backend-luatex.d
ef))
Document Class: ctexart 2022/07/14 v2.5.10 Chinese adapter for class article (C
TEX)
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/ctex/ctexhook.sty)
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/ctex/ctexpatch.sty)
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/base/fix-cm.sty
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/base/ts1enc.def))
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/ctex/config/ctexopts.cfg)
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/base/article.cls
Document Class: article 2023/05/17 v1.4n Standard LaTeX document class
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/base/size10.clo))
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/ctex/engine/ctex-engine-luat
ex.def
(/home/firestar/.texlive/2024/texmf-dist/tex/luatex/luatexja/luatexja.sty
(/home/firestar/.texlive/2024/texmf-dist/tex/luatex/luatexja/luatexja-core.sty
(/home/firestar/.texlive/2024/texmf-dist/tex/generic/infwarerr/infwarerr.sty)
(/home/firestar/.texlive/2024/texmf-dist/tex/luatex/luatexbase/luatexbase.sty
(/home/firestar/.texlive/2024/texmf-dist/tex/luatex/ctablestack/ctablestack.sty
)) (/home/firestar/.texlive/2024/texmf-dist/tex/generic/ltxcmds/ltxcmds.sty)
(/home/firestar/.texlive/2024/texmf-dist/tex/generic/pdftexcmds/pdftexcmds.sty
(/home/firestar/.texlive/2024/texmf-dist/tex/generic/iftex/iftex.sty))
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/xkeyval/xkeyval.sty
(/home/firestar/.texlive/2024/texmf-dist/tex/generic/xkeyval/xkeyval.tex
(/home/firestar/.texlive/2024/texmf-dist/tex/generic/xkeyval/xkvutils.tex
(/home/firestar/.texlive/2024/texmf-dist/tex/generic/xkeyval/keyval.tex))))
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/etoolbox/etoolbox.sty)
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/everyhook/everyhook.sty
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/svn-prov/svn-prov.sty))
(/home/firestar/.texlive/2024/texmf-dist/tex/luatex/luatexja/ltj-base.sty))
(/home/firestar/.texlive/2024/texmf-dist/tex/luatex/luatexja/luatexja-compat.st
y)) (/home/firestar/.texlive/2024/texmf-dist/tex/latex/fontspec/fontspec.sty
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/l3packages/xparse/xparse.sty
)
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/fontspec/fontspec-luatex.sty
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/base/fontenc.sty)
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/fontspec/fontspec.cfg)))
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/base/tuenc.def)
(/home/firestar/.texlive/2024/texmf-dist/tex/luatex/chinese-jfm/jfm-zh_CN.lua))
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/zhnumber/zhnumber.sty
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/zhnumber/zhnumber-utf8.cfg))

(/home/firestar/.texlive/2024/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-chin
ese-article.def
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/ctex/config/ctex-name-utf8.c
fg)) (/home/firestar/.texlive/2024/texmf-dist/tex/latex/ctex/ctex-c5size.clo))
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/ctex/config/ctex.cfg)
(./mwe2.aux) [1{/home/firestar/.texlive/2024/texmf-var/fonts/map/pdftex/updmap/
pdftex.map}] (./mwe2.aux))
 569 words of node memory still in use:
   4 hlist, 1 vlist, 1 rule, 2 glue, 3 kern, 1 glyph, 57 attribute, 50 glue_spe
c, 11 attribute_list, 1 write, 6 user_defined nodes
   avail lists: 1:2,2:1307,3:22,4:35,5:26,6:8,7:166,8:1,9:62,10:5
</usr/share/fonts/lmroman10-regular.otf></usr/share/fonts/lmroman12-regular.otf
></usr/share/fonts/SourceHanSerifCN-Regular.otf></usr/share/fonts/adobe-source-
han-sans/SourceHanSansCN-Medium.otf>
Output written on mwe2.pdf (1 page, 9712 bytes).
SyncTeX written on mwe2.synctex.gz.
Transcript written on mwe2.log.
Latexmk: Getting log file 'mwe2.log'
Latexmk: Examining 'mwe2.fls'
Latexmk: Examining 'mwe2.log'
Latexmk: Log file says output to 'mwe2.pdf'
Latexmk: All targets (mwe2.pdf) are up-to-date

[ble: elapsed 42.720s (CPU 99.2%)] latexmk -lualatex -bibtex -synctex=1 -interaction=nonstopmode -file-line-er
(base) [firestar@Archlinux Documents]$

https://paste.c-net.org/LaurieBeets log file

@Firestar-Reimu
Copy link
Author

Firestar-Reimu commented Apr 6, 2024

Another MWE using fontspec

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Source Han Serif CN}[BoldFont=Source Han Sans CN Medium]

\title{\textbf{作业}}
\author{作业}
\date{\today}

\begin{document}

\maketitle

正文123

\end{document}

log: https://paste.c-net.org/ValidityTanaka

Time: 41s

(base) [firestar@Archlinux Documents]$ latexmk -lualatex -bibtex -synctex=1 -interaction=nonstopmode -file-line-error --shell-escape mwe2.tex
Rc files read:
  NONE
Latexmk: This is Latexmk, John Collins, 31 Jan. 2024. Version 4.83.
No existing .aux file, so I'll make a simple one, and require run of *latex.
Latexmk: applying rule 'lualatex'...
Rule 'lualatex':  Reasons for rerun
Category 'other':
  Rerun of 'lualatex' forced or previously required:
    Reason or flag: 'Initial setup'

------------
Run number 1 of rule 'lualatex'
------------
------------
Running 'lualatex  -synctex=1 -interaction=nonstopmode -file-line-error --shell-escape -recorder  "mwe2.tex"'
------------
This is LuaHBTeX, Version 1.18.0 (TeX Live 2024) 
 system commands enabled.
(./mwe2.tex
LaTeX2e <2023-11-01> patch level 1
L3 programming layer <2024-03-14>
 (/home/firestar/.texlive/2024/texmf-dist/tex/latex/base/article.cls
Document Class: article 2023/05/17 v1.4n Standard LaTeX document class
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/base/size10.clo))
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/fontspec/fontspec.sty
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/l3packages/xparse/xparse.sty
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/l3kernel/expl3.sty
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/l3backend/l3backend-luatex.d
ef)))
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/fontspec/fontspec-luatex.sty
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/base/fontenc.sty)
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/fontspec/fontspec.cfg)))
(./mwe2.aux) (/home/firestar/.texlive/2024/texmf-dist/tex/latex/base/ts1cmr.fd)
[1{/home/firestar/.texlive/2024/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
(./mwe2.aux))
 406 words of node memory still in use:
   3 hlist, 1 vlist, 1 rule, 2 glue, 3 kern, 1 glyph, 4 attribute, 48 glue_spec
, 4 attribute_list, 1 write nodes
   avail lists: 2:74,3:16,4:3,5:24,6:8,7:154,8:1,9:44,10:2
</usr/share/fonts/SourceHanSerifCN-Regular.otf></usr/share/fonts/adobe-source-h
an-sans/SourceHanSansCN-Medium.otf>
Output written on mwe2.pdf (1 page, 6968 bytes).
SyncTeX written on mwe2.synctex.gz.
Transcript written on mwe2.log.
Latexmk: Getting log file 'mwe2.log'
Latexmk: Examining 'mwe2.fls'
Latexmk: Examining 'mwe2.log'
Latexmk: Log file says output to 'mwe2.pdf'
Latexmk: All targets (mwe2.pdf) are up-to-date

[ble: elapsed 41.106s (CPU 99.4%)]

@Firestar-Reimu
Copy link
Author

Firestar-Reimu commented Apr 6, 2024

Delete the [BoldFont] section does not reduce time

https://paste.c-net.org/WasherStrait 41.750s

@Firestar-Reimu
Copy link
Author

Firestar-Reimu commented Apr 6, 2024

Another question may be the same: https://tex.stackexchange.com/questions/75118/why-does-it-take-lualatex-so-long-to-load-fonts-and-can-i-speed-it-up which also use 30~40s to load a font.

mwe2.log
I need 16s to produce the MWE on the question above

if its not a lipsum which I need 2 runs of lualatex

a abc123 MWE with Times need only 3s

``` (base) [firestar@Archlinux Documents]$ latexmk -lualatex -bibtex -synctex=1 -interaction=nonstopmode -file-line-error --shell-escape mwe2.tex Rc files read: NONE Latexmk: This is Latexmk, John Collins, 31 Jan. 2024. Version 4.83. No existing .aux file, so I'll make a simple one, and require run of *latex. Latexmk: applying rule 'lualatex'... Rule 'lualatex': Reasons for rerun Category 'other': Rerun of 'lualatex' forced or previously required: Reason or flag: 'Initial setup'

Run number 1 of rule 'lualatex'


Running 'lualatex -synctex=1 -interaction=nonstopmode -file-line-error --shell-escape -recorder "mwe2.tex"'

This is LuaHBTeX, Version 1.18.0 (TeX Live 2024)
system commands enabled.
(./mwe2.tex
LaTeX2e <2023-11-01> patch level 1
L3 programming layer <2024-03-14>
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/base/article.cls
Document Class: article 2023/05/17 v1.4n Standard LaTeX document class
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/base/size10.clo))
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/fontspec/fontspec.sty
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/l3packages/xparse/xparse.sty
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/l3kernel/expl3.sty
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/l3backend/l3backend-luatex.d
ef)))
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/fontspec/fontspec-luatex.sty
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/base/fontenc.sty)
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/fontspec/fontspec.cfg)))
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/lipsum/lipsum.sty
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/l3packages/l3keys2e/l3keys2e
.sty) (/home/firestar/.texlive/2024/texmf-dist/tex/latex/lipsum/lipsum.ltd.tex)
) (./mwe2.aux)
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/base/ts1cmr.fd)

Package lipsum Warning: Unknown language 'latin'. Hyphenation patterns for
(lipsum) 'english' will be used instead.
(lipsum)
(lipsum) With LuaTeX, lipsum requires babel to get proper
(lipsum) hyphenation (you can use \usepackage[base]{babel}).

Overfull \hbox (2.17365pt too wide) in paragraph at lines 12--12
\TU/MinionPro(0)/m/n/10 cidunt ul-tri-ces. Lorem ip-sum do-lor sit amet, con-se
ctetuer adip-isc-ing elit. In hac habitasse
[1{/home/firestar/.texlive/2024/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
[2] (./mwe2.aux))
(see the transcript file for additional information)
406 words of node memory still in use:
3 hlist, 1 vlist, 1 rule, 2 glue, 3 kern, 1 glyph, 4 attribute, 48 glue_spec
, 4 attribute_list, 1 write nodes
avail lists: 2:40,3:50,4:12,5:3520,6:12,7:8340,9:121,10:10,11:619
</usr/share/fonts/MinionPro-Regular.otf>
Output written on mwe2.pdf (2 pages, 12489 bytes).
SyncTeX written on mwe2.synctex.gz.
Transcript written on mwe2.log.
Latexmk: Getting log file 'mwe2.log'
Latexmk: Examining 'mwe2.fls'
Latexmk: Examining 'mwe2.log'
Latexmk: Log file says output to 'mwe2.pdf'
Latexmk: applying rule 'lualatex'...
Rule 'lualatex': Reasons for rerun
Changed files or newly in use/created:
mwe2.aux


Run number 2 of rule 'lualatex'


Running 'lualatex -synctex=1 -interaction=nonstopmode -file-line-error --shell-escape -recorder "mwe2.tex"'

This is LuaHBTeX, Version 1.18.0 (TeX Live 2024)
system commands enabled.
(./mwe2.tex
LaTeX2e <2023-11-01> patch level 1
L3 programming layer <2024-03-14>
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/base/article.cls
Document Class: article 2023/05/17 v1.4n Standard LaTeX document class
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/base/size10.clo))
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/fontspec/fontspec.sty
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/l3packages/xparse/xparse.sty
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/l3kernel/expl3.sty
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/l3backend/l3backend-luatex.d
ef)))
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/fontspec/fontspec-luatex.sty
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/base/fontenc.sty)
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/fontspec/fontspec.cfg)))
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/lipsum/lipsum.sty
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/l3packages/l3keys2e/l3keys2e
.sty) (/home/firestar/.texlive/2024/texmf-dist/tex/latex/lipsum/lipsum.ltd.tex)
) (./mwe2.aux)
(/home/firestar/.texlive/2024/texmf-dist/tex/latex/base/ts1cmr.fd)

Package lipsum Warning: Unknown language 'latin'. Hyphenation patterns for
(lipsum) 'english' will be used instead.
(lipsum)
(lipsum) With LuaTeX, lipsum requires babel to get proper
(lipsum) hyphenation (you can use \usepackage[base]{babel}).

Overfull \hbox (2.17365pt too wide) in paragraph at lines 12--12
\TU/MinionPro(0)/m/n/10 cidunt ul-tri-ces. Lorem ip-sum do-lor sit amet, con-se
ctetuer adip-isc-ing elit. In hac habitasse
[1{/home/firestar/.texlive/2024/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
[2] (./mwe2.aux))
(see the transcript file for additional information)
406 words of node memory still in use:
3 hlist, 1 vlist, 1 rule, 2 glue, 3 kern, 1 glyph, 4 attribute, 48 glue_spec
, 4 attribute_list, 1 write nodes
avail lists: 2:40,3:50,4:12,5:3520,6:12,7:8340,9:121,10:10,11:619
</usr/share/fonts/MinionPro-Regular.otf>
Output written on mwe2.pdf (2 pages, 12489 bytes).
SyncTeX written on mwe2.synctex.gz.
Transcript written on mwe2.log.
Latexmk: Getting log file 'mwe2.log'
Latexmk: Examining 'mwe2.fls'
Latexmk: Examining 'mwe2.log'
Latexmk: Log file says output to 'mwe2.pdf'
Latexmk: All targets (mwe2.pdf) are up-to-date

[ble: elapsed 16.611s (CPU 99.6%)] latexmk -lualatex -bibtex -synctex=1 -interaction=nonstopmode -file-line-er
(base) [firestar@Archlinux Documents]$

</details>

@zauguin
Copy link
Member

zauguin commented Apr 6, 2024

You seem to be using ArchLinux, but your font is stored in /usr/share/fonts/SourceHanSerifCN-Regular.otf (instead of Arch's default location /usr/share/fonts/adobe-source-han-serif/SourceHanSerifCN-Regular.otf) Do both files exist on your system? Is the file you are using installed manually?

@Firestar-Reimu
Copy link
Author

Firestar-Reimu commented Apr 7, 2024

Both files exist on my system, one of them is installed manually from my USB drive (with a large collection of fonts), the other is installed by pacman.

I tried to delete the manually installed one, and use the pacman installed one to compile

The first time use ~6s, and after it the compile use ~1s

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Source Han Serif CN}

\title{\textbf{作业}}
\author{作业}
\date{\today}

\begin{document}

\maketitle

正文1234

\end{document}

mwe2.log

So what about other manually installed fonts? Do they have a recommended location other than /usr/share/fonts?

@Firestar-Reimu
Copy link
Author

Firestar-Reimu commented Apr 7, 2024

Also I found that adobe source code pro adobe source han sans adobe source han serif Noto Sans/Serif/Mono/Math are also not in the default place (installed twice)

But for english fonts, the time shortage between default/manual installed font is not so obvious, which is both ~780ms

@cfr42
Copy link

cfr42 commented May 3, 2024

You shouldn't manually install files into system directories period. You could make packages yourself, which should declare conflicts and/or provides etc. so you don't get conflicting files installed. Font packages should also trigger the relevant post-installation hooks to ensure fontconfig updates the database. You can also install into e.g. /usr/local/share/fonts or into your personal fonts directory. See the files in /etc/fonts/ and the wiki for details. If you install into /usr/local/share/fonts, you need to update the fontconfig database yourself and you should still avoid conflicting files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants