Skip to content

Logo rendering adjustments#82

Merged
kyleam merged 3 commits intomainfrom
logo-tweaks
Jun 5, 2025
Merged

Logo rendering adjustments#82
kyleam merged 3 commits intomainfrom
logo-tweaks

Conversation

@kyleam
Copy link
Collaborator

@kyleam kyleam commented Jun 4, 2025

This PR proposes two logo-related tweaks:

  1. change the includegraphics call for the title logo to avoid changing the logo's aspect ratio

  2. add a smaller logo image and use it in the page headers in order speed up rendering. This is particularly relevant for Metworx 25-02, where rendering has a substantial slowdown that, at least largely, looks to be the result of the slower header logo insertion under xelatex.

Screenshots

Title logo

pre

20250604T150359

post

20250604T150413

Header logo

pre

20250604T150604

post

20250604T150613

Timings

Rendering a subset of scorecards

Summary

render time in seconds, pre (release, 54c48d4) and post (tip of this PR)

24-04 pre 25-02 pre 24-04 post 25-02 post
bbr 8.8 24.9 8.8 9.1
bbr.bayes 6.0 14.1 6.0 6.3
mrgsolve 7.6 24.6 7.6 7.7
nmrec 5.5 10.9 5.5 5.8

Detailed output, including rmarkdown:::perf_timer_summary() output, elapsed time for each package, and total elapsed time:

pre, 24-04.03.01

R 4.3.1, pandoc 3.1.8

               time
knitr          3773
pandoc         4255
post-processor    0
pre-processor     2
render         8078
bbr_1.14.0: 8.838 secs

               time
knitr          2146
pandoc         3800
post-processor    0
pre-processor     1
render         5959
bbr.bayes_0.2.2: 5.995 secs

               time
knitr          3245
pandoc         4264
post-processor    0
pre-processor     2
render         7527
mrgsolve_1.5.2: 7.561 secs

               time
knitr          1710
pandoc         3716
post-processor    0
pre-processor     2
render         5438
nmrec_0.5.0: 5.471 secs

rendered 4 packages in 27.89 secs
pre, 25-02.00.00

R 4.4.2, pandoc 3.3

                time
knitr           3709
pandoc         20348
post-processor     0
pre-processor      2
render         24113
bbr_1.14.0: 24.9 secs

                time
knitr           2112
pandoc         11924
post-processor     0
pre-processor      1
render         14051
bbr.bayes_0.2.2: 14.09 secs

                time
knitr           3049
pandoc         21487
post-processor     0
pre-processor      2
render         24555
mrgsolve_1.5.2: 24.59 secs

                time
knitr           1675
pandoc          9169
post-processor     0
pre-processor      1
render         10856
nmrec_0.5.0: 10.9 secs

rendered 4 packages in 1.242 mins
post, 24-04.03.01

R 4.3.1, pandoc 3.1.8:

               time
knitr          3722
pandoc         4285
post-processor    0
pre-processor     3
render         8055
bbr_1.14.0: 8.807 secs

               time
knitr          2166
pandoc         3797
post-processor    0
pre-processor     1
render         5978
bbr.bayes_0.2.2: 6.013 secs

               time
knitr          3238
pandoc         4268
post-processor    0
pre-processor     1
render         7524
mrgsolve_1.5.2: 7.559 secs

               time
knitr          1690
pandoc         3745
post-processor    0
pre-processor     1
render         5448
nmrec_0.5.0: 5.481 secs

rendered 4 packages in 27.89 secs
post, 25-02.00.00

R 4.4.2, pandoc 3.3

               time
knitr          3745
pandoc         4565
post-processor    0
pre-processor     3
render         8354
bbr_1.14.0: 9.149 secs

               time
knitr          2148
pandoc         4109
post-processor    0
pre-processor     2
render         6273
bbr.bayes_0.2.2: 6.307 secs

               time
knitr          3069
pandoc         4595
post-processor    0
pre-processor     2
render         7682
mrgsolve_1.5.2: 7.717 secs

               time
knitr          1703
pandoc         4054
post-processor    0
pre-processor     1
render         5770
nmrec_0.5.0: 5.809 secs

rendered 4 packages in 29.01 secs

Calling xelatex with minimal input

Here's the minimal tex file used for the hyperfine timings included in the last commit:

\documentclass{article}
\usepackage{graphicx}
\usepackage{fancyhdr}
\pagestyle{fancy}
\setlength\headheight{24pt}
\fancyhead[L]{\includegraphics[width=1.25cm]{mpn_logo.png}}
\title{test}

\begin{document}
\section{a}
\newpage
\section{b}
\newpage
\subsection{b1}
\newpage
\subsection{b2}
\newpage
\section{c}
\newpage
\subsection{c1}
\newpage
\subsection{c2}
\newpage
\subsection{c3}
\end{document}
  25-02.00.00

    Benchmark 1: xelatex logobig
      Time (mean ± σ):      3.625 s ±  0.008 s    [User: 3.409 s, System: 0.233 s]
      Range (min … max):    3.612 s …  3.644 s    10 runs

    Benchmark 2: xelatex logosmall
      Time (mean ± σ):     662.7 ms ±   7.2 ms    [User: 575.2 ms, System: 105.6 ms]
      Range (min … max):   656.3 ms … 681.5 ms    10 runs

    Summary
      'xelatex logosmall' ran
        5.47 ± 0.06 times faster than 'xelatex logobig'

  24-04.03.01

    Benchmark 1: xelatex logobig
      Time (mean ± σ):     952.2 ms ±   8.5 ms    [User: 835.9 ms, System: 133.4 ms]
      Range (min … max):   944.6 ms … 974.9 ms    10 runs

    Benchmark 2: xelatex logosmall
      Time (mean ± σ):     566.4 ms ±   5.5 ms    [User: 471.8 ms, System: 111.8 ms]
      Range (min … max):   560.7 ms … 574.6 ms    10 runs

    Summary
      'xelatex logosmall' ran
        1.68 ± 0.02 times faster than 'xelatex logobig'

kyleam added 3 commits June 4, 2025 14:41
The scorecard and summary templates include header.tex, which is
responsible for adding the logo above the document title.  It's not
related to the logo inserted into the page headers.  Rename the file
to make this clearer.
Both a width and height is specified when inserting the logo above the
title, changing the aspect ratio and leading to noticeable distortion.
Avoid this by specifying only the width.

Increase the width a bit to push the height a little closer to what it
was before this change.  (A width of 3.6 cm would be needed to
maintain a height of 2 cm.)
Rendering scorecards on Metworx 25-02.00.00 has become slower compared
to rendering on Metworx 24-04.03.01 (e.g., rendering nmrec's scorecard
has gone from around 6 seconds to around 11 seconds).

The primary slowdown comes from the xelatex call.  In particular,
inserting the page header logo appears slower.  Perhaps this is due to
a change in XeLaTex (TeX Live 2023 versus Tex Live 2024) or an
underlying library (e.g., libpng).

The slowdown can be triggered by feeding xelatex a minimal tex file
(with only the fancyhdr setup and blank sections, for a total of 8
headers/pages) and can be decreased by using a smaller image (100x55
versus 2541x1401).  Here are timings (via hyperfine):

  25-02.00.00

    Benchmark 1: xelatex logobig
      Time (mean ± σ):      3.625 s ±  0.008 s    [User: 3.409 s, System: 0.233 s]
      Range (min … max):    3.612 s …  3.644 s    10 runs

    Benchmark 2: xelatex logosmall
      Time (mean ± σ):     662.7 ms ±   7.2 ms    [User: 575.2 ms, System: 105.6 ms]
      Range (min … max):   656.3 ms … 681.5 ms    10 runs

    Summary
      'xelatex logosmall' ran
        5.47 ± 0.06 times faster than 'xelatex logobig'

  24-04.03.01

    Benchmark 1: xelatex logobig
      Time (mean ± σ):     952.2 ms ±   8.5 ms    [User: 835.9 ms, System: 133.4 ms]
      Range (min … max):   944.6 ms … 974.9 ms    10 runs

    Benchmark 2: xelatex logosmall
      Time (mean ± σ):     566.4 ms ±   5.5 ms    [User: 471.8 ms, System: 111.8 ms]
      Range (min … max):   560.7 ms … 574.6 ms    10 runs

    Summary
      'xelatex logosmall' ran
        1.68 ± 0.02 times faster than 'xelatex logobig'

Notably the ~5x slowdown on 25-02 increases with the number of pages
and doesn't happen under pdflatex.

Switch to the smaller image to decrease the 25-02 render times.  There
should be no downside to doing so because 100x55 is sufficient
resolution for the small logo inserted into the header.
@kyleam kyleam requested a review from barrettk June 4, 2025 20:13
Copy link
Collaborator

@seth127 seth127 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me @kyleam . Thanks for making this change, and I'm glad it helped the slowdown. Also, the squished aspect ratio on the top logo had been bothering me, so it's nice that it's fixed too.

@barrettk no need to give this an official review, but please read through the PR description for awareness. Thanks.

@kyleam kyleam removed the request for review from barrettk June 5, 2025 16:38
@kyleam kyleam merged commit a7e82f0 into main Jun 5, 2025
5 checks passed
@kyleam kyleam deleted the logo-tweaks branch June 5, 2025 17:35
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

Successfully merging this pull request may close these issues.

2 participants