Skip to content

Use luatex's kpsewhich for speed. #19551

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

Closed
wants to merge 2 commits into from

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Feb 20, 2021

The machinery for running an interactive tex session mostly already
existed in backend_pgf, so directly reuse that (as a base class). On
the matplotlib macos, this significantly speeds up

python -c 'from pylab import *; mpl.use("pdf"); rcParams["text.usetex"] = True; plot(); savefig("/tmp/test.pdf", backend="pdf")'

from ~4.5s to ~2.5s.

Note that filesystem encodings may be a bit iffy, we still need to check
how things go through the various layers here; it may end up being best
to make the process streams be binary and perform the encoding/decoding
ourselves.

We also need to figure out how to best advertise this (do we emit a
warning suggesting to install luatex on windows and macos if luatex is
not present?).


Edit: See #19558 for another approach, which also works on Windows for a large speedup. I'll keep this PR as separate for now to allow comparing the various approaches.

PR Summary

PR Checklist

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (run flake8 on changed files to check).
  • New features are documented, with examples if plot related.
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).
  • Conforms to Matplotlib style conventions (install flake8-docstrings and run flake8 --docstring-convention=all).
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).

@jklymak
Copy link
Member

jklymak commented Feb 21, 2021

We also need to figure out how to best advertise this (do we emit a warning suggesting to install luatex on windows and macos if luatex is not present?).

I think everyone installs mactex on macs which is just a light wrapper of TexLive, which definitely includes LuaTeX. I have never used LauTeX but it is definitely on my texlive distro.

For Windows, this website from 2016 says that

Both MiKTeX and TeX Live include a ‘full’ set of TeX-related binaries, including the engines pdfTeX, XeTeX, LuaTeX and support programs such as BibTeX, Biber, MakeIndex and Xindy.

It seems to me that most people who had pdftex should have luaTeX.

@anntzer anntzer force-pushed the luatexkpsewhich branch 4 times, most recently from 6d5df02 to b9bec7a Compare February 21, 2021 16:31
The machinery for running an interactive tex session mostly already
existed in backend_pgf, so directly reuse that (as a base class).  On
the matplotlib macos, this significantly speeds up
```sh
python -c 'from pylab import *; mpl.use("pdf"); rcParams["text.usetex"] = True; plot(); savefig("/tmp/test.pdf", backend="pdf")'
```
from ~4.5s to ~2.5s.

Note that filesystem encodings may be a bit iffy, we still need to check
how things go through the various layers here; it may end up being best
to make the process streams be binary and perform the encoding/decoding
ourselves.  (But luatex itself uses utf-8, not ascii.)

We also need to figure out how to best advertise this (do we emit a
warning suggesting to install luatex on windows and macos if luatex is
not present?).
@anntzer
Copy link
Contributor Author

anntzer commented May 20, 2021

Closing in favour of #19558.

@anntzer anntzer closed this May 20, 2021
@anntzer anntzer deleted the luatexkpsewhich branch May 20, 2021 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants