Skip to content

Too much memory used when building pages with diagrams #231

@lost-melody

Description

@lost-melody

Description:

When writing pages with diagrams of fletcher or chronos, the time and memory needed for building grows a lot.
With the example below, building a single file takes over 10 seconds and occupies over 4 GiB memory. When more files are included, shiroa is likely to crash.

If this is unavoidable, I wonder whether shiroa can add an option to limit the parallel tasks instead of always building all files at once, so that the process will not crash because of out of memory.

Reproduce:

pages/diagrams.typ
#import "@preview/chronos:0.2.1"

#let lorem-diagram() = {
  figure(caption: [])[
    #chronos.diagram({
      import chronos: *

      let (a, b, c) = ("a", "b", "c")
      _par(a, display-name: lorem(2))
      _par(b, display-name: lorem(3))
      _par(c, display-name: lorem(4))

      _seq(a, b, enable-dst: true, comment: lorem(4))
      _seq(b, c, enable-dst: true, comment: lorem(4))
      _seq(a, c, comment: lorem(4))
      _seq(c, a, comment: lorem(4), dashed: true)
      _seq(a, c, comment: lorem(4))
      _seq(c, b, disable-src: true, comment: lorem(4))
      _loop(lorem(4), {
        _seq(b, c, enable-dst: true, comment: lorem(4))
        _seq(c, b, comment: lorem(4))
        _seq(b, c, comment: lorem(4))
        _seq(c, b, disable-src: true, comment: lorem(4))
      })
      _seq(b, b, comment: lorem(4))
      _seq(b, a, disable-src: true, comment: lorem(4))
    })
  ]
}

#let l() = {
  lorem(128)
  lorem-diagram()
  lorem(128)
}

#for i in range(1, 32) {
  l()
}

Duplicate this file and include them in book.typ:

book-meta
#book-meta(
  title: "shiroa",
  summary: [
    #prefix-chapter("sample-page.typ")[Hello, typst]
    = 圖表測試頁
    - #chapter("pages/diagrams.typ")[圖表頁面]
    - #chapter("pages/diagrams2.typ")[圖表頁面二]
    - #chapter("pages/diagrams3.typ")[圖表頁面三]
    - #chapter("pages/diagrams4.typ")[圖表頁面四]
  ],
)

System Information:

shiroa version 0.3.1-rc4
features: embedded_fonts

NAME="Arch Linux"
PRETTY_NAME="Arch Linux"
ID=arch
BUILD_ID=rolling
ANSI_COLOR="38;2;23;147;209"
HOME_URL="https://archlinux.org/"
DOCUMENTATION_URL="https://wiki.archlinux.org/"
SUPPORT_URL="https://bbs.archlinux.org/"
BUG_REPORT_URL="https://gitlab.archlinux.org/groups/archlinux/-/issues"
PRIVACY_POLICY_URL="https://terms.archlinux.org/docs/privacy-policy/"
LOGO=archlinux-logo

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions