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

texlive.combine: set TEXMFCNF in binary wrapper #83816

Merged
merged 1 commit into from Apr 1, 2020

Conversation

veprbl
Copy link
Member

@veprbl veprbl commented Mar 31, 2020

This helps kpathsea to find texmf.cnf in some cases. For example,
dvipng was trying to look for it in
/nix/store/<hash>-texlive-dvipng.bin-2019/ instead of
/nix/store/<hash>-texlive-combined-full-2019/.

cc @jethrokuan

Motivation for this change

Fixes: #82923

Things done
{ setHome }:
  
with import ./. {};

stdenvNoCC.mkDerivation {
  name = "dvipng-benchmark";

  buildInputs = [
    file
    hyperfine
    imagemagick
    texlive.combined.scheme-full
  ];

  buildCommand = (lib.optionalString setHome ''
    export HOME=$(mktemp -d)
  '') + ''
    cat >test.tex <<EOF
\documentclass[12pt]{article}
\begin{document}
Hello world!
\$Hello world!\$ %math mode
\end{document}
EOF
    latex test.tex 1>/dev/null 2>/dev/null

    mkdir -p $out

    hyperfine -s basic \
      "dvipng -T tight -o $out/dvipng.png test.dvi" \
      "convert -trim -antialias -density 100 test.dvi -quality 100 $out/convert.png" \
      --warmup 50

    file "$out"/*
  '';
}

before (need to set HOME to allow mktexpk to write its output):

% nix-build bench.nix --arg setHome true 
these derivations will be built:
  /nix/store/4bmv4c20y78cdz4ywrm25fgkf97gln0m-dvipng-benchmark.drv
building '/nix/store/4bmv4c20y78cdz4ywrm25fgkf97gln0m-dvipng-benchmark.drv'...
Benchmark #1: dvipng -T tight -o /nix/store/i0h1axkicn5v8pjn12zd1hlvngic3bnx-dvipng-benchmark/dvipng.png test.dvi
  Time (mean ± σ):      2.094 s ±  0.085 s    [User: 1.807 s, System: 0.292 s]
  Range (min … max):    2.023 s …  2.257 s    10 runs

Benchmark #2: convert -trim -antialias -density 100 test.dvi -quality 100 /nix/store/i0h1axkicn5v8pjn12zd1hlvngic3bnx-dvipng-benchmark/convert.png
  Time (mean ± σ):     257.5 ms ±   2.8 ms    [User: 215.1 ms, System: 52.5 ms]
  Range (min … max):   253.7 ms … 262.8 ms    11 runs

Summary
  'convert -trim -antialias -density 100 test.dvi -quality 100 /nix/store/i0h1axkicn5v8pjn12zd1hlvngic3bnx-dvipng-benchmark/convert.png' ran
    8.13 ± 0.34 times faster than 'dvipng -T tight -o /nix/store/i0h1axkicn5v8pjn12zd1hlvngic3bnx-dvipng-benchmark/dvipng.png test.dvi'
/nix/store/i0h1axkicn5v8pjn12zd1hlvngic3bnx-dvipng-benchmark/convert.png: PNG image data, 249 x 796, 8-bit gray+alpha, non-interlaced
/nix/store/i0h1axkicn5v8pjn12zd1hlvngic3bnx-dvipng-benchmark/dvipng.png:  PNG image data, 249 x 796, 8-bit colormap, non-interlaced

after:

% nix-build bench.nix --arg setHome false
these derivations will be built:
  /nix/store/58mil3wmkl1dvpxqkdmwykwkvn2j0k0j-dvipng-benchmark.drv
building '/nix/store/58mil3wmkl1dvpxqkdmwykwkvn2j0k0j-dvipng-benchmark.drv'...
Benchmark #1: dvipng -T tight -o /nix/store/amzhv8rrqasfdfr2zmlk94f2kj5ms8bl-dvipng-benchmark/dvipng.png test.dvi
  Time (mean ± σ):      70.1 ms ±   3.1 ms    [User: 59.4 ms, System: 10.5 ms]
  Range (min … max):    65.7 ms …  77.3 ms    42 runs

Benchmark #2: convert -trim -antialias -density 100 test.dvi -quality 100 /nix/store/amzhv8rrqasfdfr2zmlk94f2kj5ms8bl-dvipng-benchmark/convert.png
  Time (mean ± σ):     274.2 ms ±  11.4 ms    [User: 237.8 ms, System: 47.2 ms]
  Range (min … max):   257.2 ms … 295.8 ms    11 runs

Summary
  'dvipng -T tight -o /nix/store/amzhv8rrqasfdfr2zmlk94f2kj5ms8bl-dvipng-benchmark/dvipng.png test.dvi' ran
    3.91 ± 0.24 times faster than 'convert -trim -antialias -density 100 test.dvi -quality 100 /nix/store/amzhv8rrqasfdfr2zmlk94f2kj5ms8bl-dvipng-benchmark/convert.png'
/nix/store/amzhv8rrqasfdfr2zmlk94f2kj5ms8bl-dvipng-benchmark/convert.png: PNG image data, 249 x 796, 8-bit gray+alpha, non-interlaced
/nix/store/amzhv8rrqasfdfr2zmlk94f2kj5ms8bl-dvipng-benchmark/dvipng.png:  PNG image data, 249 x 796, 4-bit colormap, non-interlaced

This helps kpathsea to find texmf.cnf in some cases. For example,
dvipng was trying to look for it in
/nix/store/<hash>-texlive-dvipng.bin-2019/ instead of
/nix/store/<hash>-texlive-combined-full-2019/.
@veprbl
Copy link
Member Author

veprbl commented Mar 31, 2020

@GrahamcOfBorg build texlive.combined.scheme-small texlive.combined.scheme-full

@veprbl veprbl added the 9.needs: port to stable A PR needs a backport to the stable release. label Mar 31, 2020
@ofborg ofborg bot added 6.topic: TeX Issues regarding texlive and TeX in general 10.rebuild-darwin: 11-100 10.rebuild-linux: 101-500 labels Mar 31, 2020
@jethrokuan
Copy link
Contributor

@veprbl I applied your patch, and can confirm major speedups in dvipng. Many thanks!

@veprbl veprbl merged commit 2ca5abd into NixOS:master Apr 1, 2020
@veprbl veprbl deleted the pr/texlive_set_texmfcnf branch April 1, 2020 06:22
veprbl added a commit that referenced this pull request Apr 2, 2020
This helps kpathsea to find texmf.cnf in some cases. For example,
dvipng was trying to look for it in
/nix/store/<hash>-texlive-dvipng.bin-2019/ instead of
/nix/store/<hash>-texlive-combined-full-2019/.

(cherry picked from commit 91c9f2a)
cc #83816
@veprbl veprbl added 8.has: port to stable A PR already has a backport to the stable release. and removed 9.needs: port to stable A PR needs a backport to the stable release. labels Apr 2, 2020
stigok pushed a commit to stigok/nixpkgs that referenced this pull request Jun 12, 2020
This helps kpathsea to find texmf.cnf in some cases. For example,
dvipng was trying to look for it in
/nix/store/<hash>-texlive-dvipng.bin-2019/ instead of
/nix/store/<hash>-texlive-combined-full-2019/.

(cherry picked from commit 91c9f2a)
cc NixOS#83816
@veprbl veprbl restored the pr/texlive_set_texmfcnf branch December 1, 2020 16:49
@veprbl veprbl deleted the pr/texlive_set_texmfcnf branch December 1, 2020 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: TeX Issues regarding texlive and TeX in general 8.has: port to stable A PR already has a backport to the stable release. 10.rebuild-darwin: 11-100 10.rebuild-linux: 101-500
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dvipng extremely slow
2 participants