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

Overleaf超时 #543

Open
yangpuhai opened this issue Jul 19, 2024 · 12 comments
Open

Overleaf超时 #543

yangpuhai opened this issue Jul 19, 2024 · 12 comments
Labels
🚀 enhancement New feature or request 🤔 help wanted Extra attention is needed

Comments

@yangpuhai
Copy link

yangpuhai commented Jul 19, 2024

发生了什么?

旧版本(yang yating等维护)在免费版本的Overleaf上可以正常完成编译。
而新版本(2024年推出,由Feng Kaiyu等维护)在Overleaf上内容较多(10万字,150+参考文献)时会造成超时,需要开通Overleaf会员才能完成编译,给学生带来了巨大困难。

你期望的结果

希望新版本可以适当改进以实现在内容较多时也可以在免费版本的Overleaf上完成编译

BIThesis 模板

graduate-thesis

@YDX-2147483647
Copy link
Collaborator

之前有同学反映 www.overleaf.com 换成 cn.overleaf.com 就行,有没有试过呢?

@YDX-2147483647 YDX-2147483647 added the 🚀 enhancement New feature or request label Jul 19, 2024
@yangpuhai
Copy link
Author

之前有同学反映 www.overleaf.com 换成 cn.overleaf.com 就行,有没有试过呢?

感谢帮助,尝试了一下,还是出现了超时的情况。目前,我已经采用了Ruifeng Ma等同学在Overleaf上发布的新模板Beijing Institute of Technology (BIT) 2024 version thesis template(源于yang yating等维护的旧版本),该版本可以正常编译。

@YDX-2147483647
Copy link
Collaborator

YDX-2147483647 commented Jul 19, 2024

@yangpuhai
Copy link
Author

好的。请问是 https://www.overleaf.com/latex/templates/beijing-institute-of-technology-bit-2024-version-thesis-template/bxjqynnmbjtk 吗?

是的

@YDX-2147483647
Copy link
Collaborator

YDX-2147483647 commented Jul 19, 2024

刚刚做了个十一万字的测试用例,还没有暴露问题。我之后加\cite试一下。

另:Beijing Institute of Technology (BIT) 2024 version thesis template - Overleafhttps://github.com/RuifMaxx/LaTeX-template 并不完全相同,Overleaf上的BIT-thesis-grd.cls似乎有更多刻意改动。


更新:加了十几个参考文献就会出现超时,但“从头开始重新编译”就不超了。

@fky2015
Copy link
Contributor

fky2015 commented Jul 19, 2024

texpage https://www.texpage.com/pricing 提供了每次一分钟的免费编译时长。

@fky2015
Copy link
Contributor

fky2015 commented Jul 19, 2024

减小包的依赖可能是唯一一个优化性能的手段。

@YDX-2147483647
Copy link
Collaborator

YDX-2147483647 commented Jul 22, 2024

texpage texpage.com/pricing 提供了每次一分钟的免费编译时长。

刚刚我在 #536 补充了一下各家情况。


更新: https://github.com/joaomlourenco/novathesis/blob/05f1a6fe2f2c4f3270ebee00fc54d15286b40b87/README.md?plain=1#L142-L146

WARNING: Overleaf reduced the compile time
image
There is no way you can compile your thesis/dissertation (using this template) within the new (20 seconds) time limit. This means you have two options:

@YDX-2147483647
Copy link
Collaborator

YDX-2147483647 commented Jul 24, 2024

result

benchmark.zip

Details
# 首先各自完整编译一遍,生成 *.aux 等

$ arara main-ctex.tex
(XeLaTeX) XeLaTeX engine ................................ SUCCESS
(Biber) The Biber reference management software ......... SUCCESS
(XeLaTeX) XeLaTeX engine ................................ SUCCESS
(XeLaTeX) XeLaTeX engine ................................ SUCCESS
(XDVIPDFMX) The XDVIPDFMX program ....................... SUCCESS
Total: 20.484 seconds

$ arara main-bithesis.tex
(XeLaTeX) XeLaTeX engine ................................ SUCCESS
(Biber) The Biber reference management software ......... SUCCESS
(XeLaTeX) XeLaTeX engine ................................ SUCCESS
(XeLaTeX) XeLaTeX engine ................................ SUCCESS
(XDVIPDFMX) The XDVIPDFMX program ....................... SUCCESS
Total: 26.893 seconds

# 然后比较 xelatex 编译时间

$ hyperfine 'xelatex -no-pdf main-ctex.tex' 'xelatex -no-pdf main-bithesis.tex'
Benchmark 1: xelatex -no-pdf main-ctex.tex
  Time (mean ± σ):      5.357 s ±  0.614 s    [User: 4.228 s, System: 1.055 s]
  Range (min … max):    4.512 s …  6.415 s    10 runs

Benchmark 2: xelatex -no-pdf main-bithesis.tex
  Time (mean ± σ):      7.626 s ±  0.287 s    [User: 6.235 s, System: 1.333 s]
  Range (min … max):    7.249 s …  8.246 s    10 runs

Summary
  xelatex -no-pdf main-ctex.tex ran
    1.42 ± 0.17 times faster than xelatex -no-pdf main-bithesis.tex

空文档(只保留\begin{document}\end{document})的结果如下。

Benchmark 1: xelatex -no-pdf main-ctex.tex
  Time (mean ± σ):     857.7 ms ±  54.1 ms    [User: 730.3 ms, System: 101.2 ms]
  Range (min … max):   776.5 ms … 949.0 ms    10 runs

Benchmark 2: xelatex -no-pdf main-bithesis.tex
  Time (mean ± σ):      1.904 s ±  0.289 s    [User: 1.554 s, System: 0.328 s]
  Range (min … max):    1.590 s …  2.296 s    10 runs

Summary
  xelatex -no-pdf main-ctex.tex ran
    2.22 ± 0.36 times faster than xelatex -no-pdf main-bithesis.tex

再加上 biblatex 等宏包,结果如下。

Benchmark 1: xelatex -no-pdf main-ctex.tex
  Time (mean ± σ):      2.181 s ±  0.275 s    [User: 1.933 s, System: 0.209 s]
  Range (min … max):    1.696 s …  2.396 s    10 runs

Benchmark 2: xelatex -no-pdf main-bithesis.tex
  Time (mean ± σ):      3.659 s ±  0.124 s    [User: 3.196 s, System: 0.422 s]
  Range (min … max):    3.473 s …  3.874 s    10 runs

Summary
  xelatex -no-pdf main-ctex.tex ran
    1.68 ± 0.22 times faster than xelatex -no-pdf main-bithesis.tex

继续加上\frontmatter等,只保留% \input{./chapters/*.tex},结果如下。

Benchmark 1: xelatex -no-pdf main-ctex.tex
  Time (mean ± σ):      1.995 s ±  0.348 s    [User: 1.782 s, System: 0.193 s]
  Range (min … max):    1.624 s …  2.504 s    10 runs

Benchmark 2: xelatex -no-pdf main-bithesis.tex
  Time (mean ± σ):      3.779 s ±  0.185 s    [User: 3.284 s, System: 0.432 s]
  Range (min … max):    3.580 s …  4.203 s    10 runs

Summary
  xelatex -no-pdf main-ctex.tex ran
    1.89 ± 0.34 times faster than xelatex -no-pdf main-bithesis.tex
import marimo

__generated_with = "0.7.11"
app = marimo.App(width="medium")


@app.cell
def __():
    import numpy as np
    return np,


@app.cell
def __():
    from matplotlib.pyplot import subplots

    fig, ax = subplots(layout='constrained')
    return ax, fig, subplots


@app.cell
def __():
    tests = ["empty", "packages", "packages + hooks", "full"]
    return tests,


@app.cell
def __(np):
    data = {
        "ctex": np.array(
            [
                [0.8577, 54.1e-3],
                [2.181, 0.2],
                [1.995, 0.348],
                [5.357, 0.614],
            ]
        ),
        "bithesis": np.array(
            [
                [1.904, 0.289],
                [3.659, 0.124],
                [3.779, 0.185],
                [7.626, 0.287],
            ]
        ),
    }
    return data,


@app.cell
def __(ax, data, fig, tests):
    for k,v in data.items():
        ax.errorbar(x=tests, y=v[:,0], yerr=v[:,1], label=k)
    ax.legend()
    ax.grid(visible=True)
    ax.set_ylabel('时间 / s')
    fig
    return k, v


if __name__ == "__main__":
    app.run()

@YDX-2147483647
Copy link
Collaborator

YDX-2147483647 commented Jul 24, 2024

完整测试

result-3

  • 实线使用 biblatex,点划线使用 natbib。
  • empty 为空文档,packages 指 biblatex/natbib 等宏包,hooks 指\frontmatter等钩子,full 表示完整十一万字的文档。

一些特殊情况:

  • \MakeCover等命令 ctex 没有,测试时统一删去了,包括 full 版本。
  • BIT-thesis-grd.cls本身就引入了 natbib;而 bithesis 的*.cls并不引入,在*.tex中才引入。
  • 测试的是单次 xelatex 编译,而完整编译可能需要三次。

现象:

  • 增多字数时,各模板增加的时间都差不多。
  • \usepackage[backend=biber]{biblatex}远比\usepackage{natbib}耗时。
Details
import marimo

__generated_with = "0.7.11"
app = marimo.App(width="medium")


@app.cell
def __():
    import numpy as np
    return np,


@app.cell
def __():
    from matplotlib.pyplot import subplots

    fig, ax = subplots(layout='constrained')
    return ax, fig, subplots


@app.cell
def __():
    tests = ["empty", "packages", "packages + hooks", "full"]
    return tests,


@app.cell
def __(np):
    data = {
        "ctex + biblatex": np.array(
            [
                [0.8577, 54.1e-3],
                [2.181, 0.2],
                [1.995, 0.348],
                [5.357, 0.614],
            ]
        ),
        "bithesis (biblatex)": np.array(
            [
                [1.904, 0.289],
                [3.659, 0.124],
                [3.779, 0.185],
                [7.626, 0.287],
            ]
        ),
        "ctex + natbib": np.array(
            [
                [886.6e-3, 74.7e-3],
                [884.1e-3, 35.4e-3],
                [931.0e-3, 57.0e-3],
                [3.371, 0.276],
            ]
        ),
        "BIT-thesis-grd (natbib)": np.array(
            [
                [2.234, 0.388],
                [2.046, 0.330],
                [2.274, 0.447],
                [5.294, 0.418],
            ]
        ),
    }
    return data,


@app.cell
def __(ax, data, fig, tests):
    for k, v in data.items():
        ax.errorbar(
            x=tests,
            y=v[:, 0],
            yerr=v[:, 1],
            label=k,
            linestyle="-." if "natbib" in k else "-",
            capsize=5.,
        )
    ax.legend()
    ax.grid(visible=True)
    ax.set_ylabel("时间 / s")
    ax.set_ylim([0, None])
    fig
    return k, v


if __name__ == "__main__":
    app.run()

biblatex - Why is biber so slow? - TeX - LaTeX Stack Exchange

@YDX-2147483647 YDX-2147483647 added the 🤔 help wanted Extra attention is needed label Jul 25, 2024
@YDX-2147483647
Copy link
Collaborator

减小包的依赖可能是唯一一个优化性能的手段。

像这种\clist_item其实每编译一页都运行了一遍,如果改改,应该可以总共只运行一遍。(肯定是从 O(n) 变成 O(1),但实际效果我就不清楚了。)

BIThesis/bithesis.dtx

Lines 837 to 840 in 424e5b8

head .tl_set:N = \l_@@_style_head_tl,
head .initial:n = {
\clist_item:Nn \c_@@_bachelor_thesis_header_clist \g_@@_thesis_type_int
},

#548 (comment)

@fky2015
Copy link
Contributor

fky2015 commented Aug 29, 2024

减小包的依赖可能是唯一一个优化性能的手段。

像这种\clist_item其实每编译一页都运行了一遍,如果改改,应该可以总共只运行一遍。(肯定是从 O(n) 变成 O(1),但实际效果我就不清楚了。)

BIThesis/bithesis.dtx

Lines 837 to 840 in 424e5b8

head .tl_set:N = \l_@@_style_head_tl,
head .initial:n = {
\clist_item:Nn \c_@@_bachelor_thesis_header_clist \g_@@_thesis_type_int
},

#548 (comment)

不过因为这个 list 非常小,性能提升肯定不明显。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚀 enhancement New feature or request 🤔 help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants