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

feat: accelerate doc build #75

Merged
merged 22 commits into from
Nov 25, 2021
Merged

feat: accelerate doc build #75

merged 22 commits into from
Nov 25, 2021

Conversation

LogCreative
Copy link
Contributor

@LogCreative LogCreative commented Nov 24, 2021

采用 mylatexformat 进行单元测试导言区预编译

单元测试项目的个数很多,而且很多的导言区是重复加载的。通过 mylatexformat 可以 dump 一些可以被缓存的头文件,这样构建时就可以减少不必要的重复工作。

header1->content1->header2->content2->header3->content3->...

-预编译后->

header->content1->content2->content3->...

当然这种方法不太适合一些使用 OpenType 字体的宏包,比如 ctex,这个时候

\documentclass{ctexbeamer}

就会被拆分

%--- static -----
\RequirePackage[OT1]{fontenc}   % old 7-bit to dump
\documentclass{beamer}
%--- dynamic ---
\endofdump
\usepackage{ctex}

这种预编译可以存储选项信息,但是过于零碎的预存就失去了减少时间的作用,所以如果第一行不匹配就会不会使用静态库(.fmt)链接。以后将会考虑整合这种方法到主文件编译。

任何的版本更新(MikTeX 内核、TeX Live 升级)都会使这个 .fmt 静态链接失效。静态链接的大小一般在 8M 左右。
TikZEdt 使用了类似的技术实现了接近实时预览的 TikZ 编译速度。
该部分稳定后会被加入开发文档。

现在默认不启用单元测试结果缓存,开发者需要在 build.lua 中打开 cachedemo。现在本地的编译速度已经跟服务器编译速度基本相同(之前需要 15min+,受制于硬盘读取速度等)。

杂项

  • sjtucover 已经变成静态库,不涉及判断。
  • cache/ 文件夹现在被合并入 build/,两者有些重复。
  • fix VSC Snippets 环境补全 bug #74 .
  • 删除了 min 的标题页背景,因为 fadings 库不稳定,以及之前的错位现象 封面合集及用户文档中背景图片位置异常 #55 ,并且不能被用作缓存,在这版删除,如果需要这个背景,可以手动在 sjtucover.sty 中开启。 构建文档时通过下面避免。
  • 取消 compatible 预编译选项在加载前定义 \sjtubeamer@compatiblefalse 以避免兼容问题。
点击查看预存储信息

==============================================================================
JOB NAME         : "tmpstep2shadow"
CUSTOMISED FORMAT: "commonheader"
PRELOADED FILES:
 fontenc.sty
  ot1lmr.fd    2015/05/01 v1.6.1 Font defs for Latin Modern
  beamer.cls    2021/03/19 v3.62 A class for typesetting presentations
beamerbasemodes.sty
etoolbox.sty    2020/10/05 v2.5k e-TeX tools for LaTeX (JAW)
beamerbasedecode.sty
   ifpdf.sty    2019/10/25 v3.4 ifpdf legacy package. Use iftex instead.
   iftex.sty    2020/03/06 v1.0d TeX engine tests
beamerbaseoptions.sty
  keyval.sty    2014/10/28 v1.15 key=value parser (DPC)
geometry.sty    2020/01/02 v5.9 Page Geometry
  ifvtex.sty    2019/10/25 v1.7 ifvtex legacy package. Use iftex instead.
  size11.clo    2020/04/10 v1.4m Standard LaTeX file (size option)
 pgfcore.sty    2020/12/27 v3.1.8b (3.1.8b)
graphicx.sty    2020/09/09 v1.2b Enhanced LaTeX Graphics (DPC,SPQR)
graphics.sty    2020/08/30 v1.4c Standard LaTeX Graphics (DPC,SPQR)
    trig.sty    2016/01/03 v1.10 sin cos tan (DPC)
graphics.cfg    2016/06/04 v1.11 sample graphics configuration
   xetex.def    2021/03/18 v5.0k Graphics/color driver for xetex
  pgfsys.sty    2020/12/27 v3.1.8b (3.1.8b)
  pgfrcs.sty    2020/12/27 v3.1.8b (3.1.8b)
pgfrcs.code.tex
pgfsys.code.tex
pgfsyssoftpath.code.tex    2020/12/27 v3.1.8b (3.1.8b)
pgfsysprotocol.code.tex    2020/12/27 v3.1.8b (3.1.8b)
  xcolor.sty    2016/05/11 v2.12 LaTeX color extensions (UK)
   color.cfg    2016/01/02 v1.6 sample color configuration
pgfcore.code.tex
 xxcolor.sty    2003/10/24 ver 0.1
atbegshi-ltx.sty    2020/08/17 v1.0a Emulation of the original atbegshi package

with kernel methods
hyperref.sty    2021-02-27 v7.00k Hypertext links for LaTeX
 ltxcmds.sty    2020-05-10 v1.25 LaTeX kernel commands for general use (HO)
pdftexcmds.sty    2020-06-27 v0.33 Utility functions of pdfTeX for LuaTeX (HO)
infwarerr.sty    2019/12/03 v1.5 Providing info/warning/error messages (HO)
kvsetkeys.sty    2019/12/15 v1.18 Key value parser (HO)
kvdefinekeys.sty    2019-12-19 v1.6 Define keys (HO)
pdfescape.sty    2019/12/09 v1.15 Implements pdfTeX's escape features (HO)
 hycolor.sty    2020-01-27 v1.10 Color options for hyperref/bookmark (HO)
letltxmacro.sty    2019/12/03 v1.6 Let assignment for LaTeX macros (HO)
 auxhook.sty    2019-12-17 v1.6 Hooks for auxiliary files (HO)
kvoptions.sty    2020-10-07 v3.14 Key value format for package options (HO)
  pd1enc.def    2021-02-27 v7.00k Hyperref: PDFDocEncoding definition (HO)
hyperref-langpatches.def    2021-02-27 v7.00k Hyperref: patches for babel langu
ages
 intcalc.sty    2019/12/15 v1.3 Expandable calculations with integers (HO)
etexcmds.sty    2019/12/15 v1.7 Avoid name clashes with e-TeX commands (HO)
   puenc.def    2021-02-27 v7.00k Hyperref: PDF Unicode definition (HO)
     url.sty    2013/09/16  ver 3.4  Verb mode for urls, etc.
  bitset.sty    2019/12/09 v1.3 Handle bit-vector datatype (HO)
bigintcalc.sty    2019/12/15 v1.5 Expandable calculations on big integers (HO)
  hxetex.def    2021-02-27 v7.00k Hyperref driver for XeTeX
stringenc.sty    2019/11/29 v1.12 Convert strings between diff. encodings (HO)
rerunfilecheck.sty    2019/12/05 v1.9 Rerun checks for auxiliary files (HO)
atveryend-ltx.sty    2020/08/19 v1.0a Emulation of the original atvery package
with kernel methods
uniquecounter.sty    2019/12/15 v1.4 Provide unlimited unique counter (HO)
beamerbaserequires.sty
beamerbasecompatibility.sty
beamerbasefont.sty
 amssymb.sty    2013/01/14 v3.01 AMS font symbols
amsfonts.sty    2013/01/14 v3.01 Basic AMSFonts support
sansmathaccent.sty    2020/01/31
scrlfile.sty    2021/03/17 v3.33 KOMA-Script package (file load hooks)
scrlfile-hook.sty    2021/03/17 v3.33 KOMA-Script package (using LaTeX hooks)
 scrlogo.sty    2021/03/17 v3.33 KOMA-Script package (logo)
beamerbasetranslator.sty
translator.sty    2020-08-03 v1.12c Easy translation of strings in LaTeX
beamerbasemisc.sty
beamerbasetwoscreens.sty
beamerbaseoverlay.sty
beamerbasetitle.sty
beamerbasesection.sty
beamerbaseframe.sty
beamerbaseverbatim.sty
beamerbaseframesize.sty
beamerbaseframecomponents.sty
beamerbasecolor.sty
beamerbasenotes.sty
beamerbasetoc.sty
beamerbasetemplates.sty
beamerbaseauxtemplates.sty
beamerbaseboxes.sty
beamerbaselocalstructure.sty
enumerate.sty    2015/07/23 v3.00 enumerate extensions (DPC)
beamerbasenavigation.sty
beamerbasetheorems.sty
 amsmath.sty    2020/09/23 v2.17i AMS math features
 amstext.sty    2000/06/29 v2.01 AMS text
  amsgen.sty    1999/11/30 v2.0 generic functions
  amsbsy.sty    1999/11/29 v1.2d Bold Symbols
  amsopn.sty    2016/03/08 v2.02 operator names
  amsthm.sty    2020/05/29 v2.20.6
beamerbasethemes.sty
 ot1lmss.fd    2015/05/01 v1.6.1 Font defs for Latin Modern
beamerthemedefault.sty
beamerfontthemedefault.sty
beamercolorthemedefault.sty
beamerinnerthemedefault.sty
beamerouterthemedefault.sty
  sjtuvi.sty    2021/11/22 Visual Identity System library for sjtubeamer v2.3.2

    tikz.sty    2020/12/27 v3.1.8b (3.1.8b)
     pgf.sty    2020/12/27 v3.1.8b (3.1.8b)
pgfcomp-version-0-65.sty    2020/12/27 v3.1.8b (3.1.8b)
pgfcomp-version-1-18.sty    2020/12/27 v3.1.8b (3.1.8b)
  pgffor.sty    2020/12/27 v3.1.8b (3.1.8b)
 pgfkeys.sty
pgfkeys.code.tex
 pgfmath.sty
pgfmath.code.tex
pgffor.code.tex
tikz.code.tex
vi/sjtubadge.pdf
vi/cnlogo.pdf
vi/enlogo.pdf
vi/dlogo.pdf
vi/vlogo.pdf
vi/sjtubg.png
sjtucover.sty    2021/11/22 cover library for sjtubeamer v2.3.2
tcolorbox.sty    2020/10/09 version 4.42 text color boxes
verbatim.sty    2020-07-07 v1.5u LaTeX2e package for verbatim enhancements
 environ.sty    2014/05/04 v0.3 A new way to define environments
trimspaces.sty    2009/09/17 v1.1 Trim spaces around a token list
listings.sty    2020/03/24 1.8d (Carsten Heinz)
 lstmisc.sty    2020/03/24 1.8d (Carsten Heinz)
listings.cfg    2020/03/24 1.8d listings configuration
shellesc.sty    2019/11/08 v1.0c unified shell escape interface for LaTeX
    umsa.fd    2013/01/14 v3.01 AMS symbols A
    umsb.fd    2013/01/14 v3.01 AMS symbols B
 ot1lmtt.fd    2015/05/01 v1.6.1 Font defs for Latin Modern

==============================================================================
(mylatexformat)Info: start reading document "tmpstep2shadow"
(mylatexformat)      on input line 2. (\endofdump)
==============================================================================

@LogCreative LogCreative mentioned this pull request Nov 24, 2021
4 tasks
@LogCreative
Copy link
Contributor Author

CTeX 如果使用 pdflatex 的话是可以被缓存的,在 xelatex 中因为用了 fontspec 而暂时不能(以后会尝试更多的方法)。所以这种缓存行文还是在小范围内用于开发加速,以后想推广得等类似的方法出现。

Copy link
Member

@skyzh skyzh left a comment

Choose a reason for hiding this comment

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

Rest LGTM

(0.2*\the\paperwidth,0) circle [radius=\the\paperwidth];
\end{tikzpicture}
\fi%
% \ifbeamer@draftmode%
Copy link
Member

Choose a reason for hiding this comment

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

感觉是不是最好不要改变模版的默认行为和样式?可以考虑开启 cache 的时候把 overlay disable 掉(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

我思考一下 改改看

@LogCreative
Copy link
Contributor Author

LogCreative commented Nov 25, 2021

改为添加下面的代码使不兼容的代码失效:

\makeatletter
\def\sjtubeamer@compatible{false}
\makeatother
\usetheme{sjtubeamer}

end

typesetopts = "-interaction=nonstopmode -shell-escape"
typesetfiles = {"sjtubeamerdevguide.tex","sjtubeamer.tex"}
-- typesetfiles = {"sjtubeamer.tex"}
-- typesetruns = 1 -- for debug. Some reference may not be linked.
-- typesetdemofiles = {"min.tex"}
-- cachedemo = true -- cache the demo
Copy link
Contributor Author

Choose a reason for hiding this comment

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

修改 build.lua 里的 cachedemo 变量可以调整是否需要缓存demo,现在默认还是先关上吧,下面也有对应的提示。

@@ -73,8 +73,8 @@ see https://vi.sjtu.edu.cn/index.php/articles/bulletin/16.
\from{sjtucover.dtx}{package\preserveoption}}
}
\generate{\file{sjtuvi.sty}{%
\from{sjtuvi.dtx}{package,compatible}}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

compatible 选项已经被移除,使用上面的方法代替。

@LogCreative LogCreative merged commit ec3d9d8 into main Nov 25, 2021
@LogCreative LogCreative deleted the logcreative-speedup branch November 25, 2021 05:06
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.

VSC Snippets 环境补全 bug
2 participants