You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Exponential performance cliff compiling associated types with equality constraints #22204
I am not 100% sure we are hitting this - I believe that when we were investigating the perf regressions we suspected this, but I am not certain. Is there something we can do to verify we're hitting it? (assuming you would postpone it if it's not an issue for Servo).
#21694 demonstrates that if you're hitting it, it should show up in the type checking phase, which is otherwise quite lean. Should show up pretty clearly.
Same as Ralle, I came here from combine. It seems like a really nice parsing library for my project, but even the simple demonstration test that was in their docs took alarmingly long to compile, so I hope this gets fixed soon.
fnmain(){let iter = (0..2).chain(0..2).chain(0..2).chain(0..2).chain(0..2).chain(0..2).chain(0..2).chain(0..2).chain(0..2).chain(0..2).chain(0..2);for i in iter {println!("{:?}", i);}}
On my machine, chaining 15 iterators takes 1min to typecheck, and uses about 500M of memory.
@asajeffrey It would unfortunately be a backwards incompatible change so I am afraid I cannot do it at the moment for combine. I may do it for 2.0 though I am not inclinded to rush towards that at the moment.
(I did test compiling a branch I already had where combine's Input type is a parameter instead of associated and it cut compiling the tests into half 1m10s -> 32s)
Activity
huonw commentedon Feb 12, 2015
This also applies for trait bounds, e.g. replacing the
equalityimplwithgives similar results.
jdm commentedon Feb 12, 2015
cc me
brson commentedon Feb 12, 2015
Nominating because this seems to impact servo.
pnkfelix commentedon Feb 12, 2015
1.0 beta, P-high.
larsbergstrom commentedon Feb 13, 2015
I am not 100% sure we are hitting this - I believe that when we were investigating the perf regressions we suspected this, but I am not certain. Is there something we can do to verify we're hitting it? (assuming you would postpone it if it's not an issue for Servo).
Gankra commentedon Feb 13, 2015
#21694 demonstrates that if you're hitting it, it should show up in the type checking phase, which is otherwise quite lean. Should show up pretty clearly.
gereeter commentedon Feb 22, 2015
A slightly more minimal test case:
8 remaining items
TheZalli commentedon Feb 24, 2016
Same as Ralle, I came here from combine. It seems like a really nice parsing library for my project, but even the simple demonstration test that was in their docs took alarmingly long to compile, so I hope this gets fixed soon.
asajeffrey commentedon Feb 25, 2016
Ditto, coming here from perf issues with my parser library (#31849). My minimal example is just chaining iterators (https://play.rust-lang.org/?gist=a0c05fbf5c43234fb7c3):
On my machine, chaining 15 iterators takes 1min to typecheck, and uses about 500M of memory.
asajeffrey commentedon Feb 25, 2016
Separating out the projection trait (
HasItem) as a separate trait seems to be a work-around... https://play.rust-lang.org/?gist=1cf9886dd074e073cd6aasajeffrey commentedon Mar 1, 2016
The work-around does scale up to the Parsell parser library (see, e.g. http://asajeffrey.github.io/parsell/target/doc/parsell/trait.StatefulInfer.html). It may be that combine can use a similar work-around? cc @Marwes.
Marwes commentedon Mar 1, 2016
@asajeffrey It would unfortunately be a backwards incompatible change so I am afraid I cannot do it at the moment for combine. I may do it for 2.0 though I am not inclinded to rush towards that at the moment.
(I did test compiling a branch I already had where combine's
Inputtype is a parameter instead of associated and it cut compiling the tests into half 1m10s -> 32s)asajeffrey commentedon Mar 1, 2016
@Marwes indeed, Parsell has the luxury of still being at v0.x.x so I can make changes like this more easily.
nikomatsakis commentedon Mar 21, 2016
Just FYI, my projection caching branch (PR coming soon) totally solves this problem, from what I can tell.
nikomatsakis commentedon Mar 21, 2016
hmm, although actually maybe it's already been solved. At least stage0 seems to run fine too.
nikomatsakis commentedon Mar 21, 2016
I take it back, the chained iterator case is still quite slow.
arielb1 commentedon Jun 9, 2016
This looks fixed with the projection cache.
ishitatsuyuki commentedon Apr 2, 2018
#48296 should have solved this completely. Closing as obsolete.
Merge pull request rust-lang#22204 from Shourya742/2026-04-21-migrate…