Skip to content

Extremely slow while compiling pulldown-cmark #199

@Neutron3529

Description

@Neutron3529

With cargo new pd && cd pd && cargo add pulldown-cmark && cargo check, it tooks ~10 minutes for finishing checking crate pulldown-cmark.

Test Code

[neutron@3060 pd]$ cargo clean && cargo check --timings && mv target/cargo-timings/cargo-timing.html ./cargo-timing-native.html
     Removed 69 files, 10.1MiB total
   Compiling pulldown-cmark v0.13.0
    Checking unicode-width v0.1.14
    Checking unicase v2.8.1
    Checking bitflags v2.9.0
    Checking pulldown-cmark-escape v0.11.0
    Checking memchr v2.7.4
    Checking getopts v0.2.21
    Checking pd v0.1.0 (/me/pd)
      Timing report saved to /me/pd/target/cargo-timings/cargo-timing-20250306T125131Z.html
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.18s
[neutron@3060 pd]$ vi ~/.cargo/config.toml # adding -Zpolonius
[neutron@3060 pd]$ cargo clean && cargo check --timings && mv target/cargo-timings/cargo-timing.html ./cargo-timing-polonius.html
     Removed 69 files, 10.1MiB total
    Checking unicode-width v0.1.14
   Compiling pulldown-cmark v0.13.0
    Checking bitflags v2.9.0
    Checking memchr v2.7.4
    Checking pulldown-cmark-escape v0.11.0
    Checking unicase v2.8.1
    Checking getopts v0.2.21
    Checking pd v0.1.0 (/me/pd)
      Timing report saved to /me/pd/target/cargo-timings/cargo-timing-20250306T125213Z.html
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 10m 12s

Compiled file and System Informations:

[neutron@3060 pd]$ rustc --version
rustc 1.87.0-nightly (f4a216d28 2025-03-02)
[neutron@3060 pd]$ cat Cargo.toml 
[package]
name = "pd"
version = "0.1.0"
edition = "2024"
publish = ["crates-io"]

[dependencies]
pulldown-cmark = "0.13.0"
[neutron@3060 pd]$ cat ~/.cargo/config.toml 
[cargo-new]
vcs = "none"

[registry]
default = 'crates-io'
token = '(...Omit...)'

[source.crates-io]
replace-with = 'ustc'

[source.ustc]
registry = "sparse+https://mirrors.ustc.edu.cn/crates.io-index/"

[source.tuna]
registry = "sparse+https://mirrors.tuna.tsinghua.edu.cn/crates.io-index/"

[http]
#multiplexing = false

[net]
retry = 5 # network retries
#git-fetch-with-cli = true

[profile.release]
opt-level = 3
strip = true
codegen-units = 1

[profile.lto]
inherits = "release"
lto = true

[profile.thin]
inherits = "lto"
lto = "thin"

[alias]
rr = "run --release"
rl = "run --profile lto"
rt = "run --profile thin"
br = "build --release"
bl = "build --profile lto"
bt = "build --profile thin"
p = "publish --registry crates-io"

[target.'cfg(all())']
rustflags = ["-C", "link-arg=-fuse-ld=mold", "-C", "target-cpu=native", "-Zpolonius"]

[term]
color = 'auto'
progress.when = 'auto'
progress.width = 160

Native result (generating by cargo check --timings)

Unit Total Codegen Features
1. pulldown-cmark v0.13.0 lib (check) 0.7s 0.0s (2%) default, getopts, html, pulldown-cmark-escape
2. memchr v2.7.4 lib (check) 0.3s 0.0s (3%) alloc, default, std
3. unicode-width v0.1.14 lib (check) 0.2s 0.0s (4%) cjk, default
4. unicase v2.8.1 lib (check) 0.1s 0.0s (5%)
5. bitflags v2.9.0 lib (check) 0.1s 0.0s (6%)
6. getopts v0.2.21 lib (check) 0.1s 0.0s (6%)
7. pulldown-cmark v0.13.0 build script 0.1s default, getopts, html, pulldown-cmark-escape
8. pulldown-cmark-escape v0.11.0 lib (check) 0.1s 0.0s (13%)
9. pd v0.1.0 bin "pd" (check) 0.0s 0.0s (22%)
10. pulldown-cmark v0.13.0 build script (run) 0.0s default, getopts, html, pulldown-cmark-escape

pulldown-cmark result

Unit Total Codegen Features
1. pulldown-cmark v0.13.0 lib (check) 609.7s 0.0s (0%) default, getopts, html, pulldown-cmark-escape
2. memchr v2.7.4 lib (check) 2.5s 0.0s (1%) alloc, default, std
3. unicase v2.8.1 lib (check) 2.3s 0.0s (0%)
4. unicode-width v0.1.14 lib (check) 1.6s 0.0s (0%) cjk, default
5. getopts v0.2.21 lib (check) 0.9s 0.0s (1%)
6. bitflags v2.9.0 lib (check) 0.2s 0.0s (3%)
7. pulldown-cmark-escape v0.11.0 lib (check) 0.1s 0.0s (4%)
8. pulldown-cmark v0.13.0 build script 0.1s default, getopts, html, pulldown-cmark-escape
9. pd v0.1.0 bin "pd" (check) 0.0s 0.0s (21%)
10. pulldown-cmark v0.13.0 build script (run) 0.0s default, getopts, html, pulldown-cmark-escape

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions