Compile is too slow
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I tried this code (issue code repo (c1421faeeb9b8a2775d3ce460ee56e42064ea709)):
let unit = neu::ascii_alphabetic()
.or(neu::ascii_alphanumeric())
.or('_');
let ident = unit.repeat_one_more();
let ty = neu::ascii_alphabetic()
.or('_')
.repeat_one()
.then(ident)
.pat();
// compile about 25s+
let layer1 = ty
.then(ty.quote("<", ">"))
.map(|(w, ty)| Ok(Ty::Layer1(w, ty)));
let layer2 = ty
.then(ty.then(ty.quote("<", ">")).quote("<", ">"))
.map(|(w1, (w2, ty))| Ok(Ty::Layer2(w1, w2, ty)));
let layer0 = ty.map(|ty| Ok(Ty::Layer0(ty)));
let field = ident.sep_once(":", layer2.or(layer1.or(layer0)));
// let layer1 = ty
// .then(ty.quote("<", ">"))
// .map(|(w, ty)| Ok(Ty::Layer1(w, ty)));
// let layer0 = ty.map(|ty| Ok(Ty::Layer0(ty)));
// let field = ident.sep_once(":", layer1.or(layer0));
// comment 55 ~ 62 and uncomment current block, compile about 2s+
let public = field
.padded("pub")
.map(|(name, ty_name)| Ok(Field::public(name, ty_name)));
let private = field.map(|(name, ty_name)| Ok(Field::private(name, ty_name)));
let parser = public.or(private).sep(",");
let data = "abc: Option<i32>";
let b_policy = re_policy(neu::whitespace().repeat_full());
dbg!(PolicyCtx::new(CharsCtx::new(data), b_policy).ctor(&parser)?);
I expected to see this happen: compile in several seconds.
Instead, this happened: compile in 27s+.
Compiling api-gen v0.1.0 (E:\Rust\issue-example)
warning: field `public` is never read
--> src\main.rs:23:5
|
| ----- field in this struct
...
23 | public: bool,
| ^^^^^^
|
= note: `Field` has derived impls for the traits `Clone` and `Debug`, but these are intentionally ignored during dead code analysis
= note: `#[warn(dead_code)]` on by default
warning: `api-gen` (bin "api-gen") generated 1 warning
Finished dev [unoptimized + debuginfo] target(s) in 27.29s
neure is a crate write for parsing string or binary data,
Meta
rustc --version --verbose:
rustc 1.77.0-nightly (3cdd004e5 2023-12-29)
binary: rustc
commit-hash: 3cdd004e55c869faa2b7b25efd3becf50346e7d6
commit-date: 2023-12-29
host: x86_64-pc-windows-msvc
release: 1.77.0-nightly
LLVM version: 17.0.6
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked example repository at commit c1421faeeb9b8a2775d3ce460ee56e42064ea709 and reproduce the compile-time difference in src/main.rs using the reported rustc nightly version. Compare the nested parser example with the reduced version and minimize the case further; done means a confirmed, actionable compiler performance reproduction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 32/100