jhpratt,
@jhpratt@mastodon.social avatar

Hit an edge case in the #Rust compiler that appears to be quadratic at best and potentially exponential. Trivial to make happen with real-world code. Investigating...

#RustLang #programming

ekuber,
@ekuber@hachyderm.io avatar

@jhpratt looking forward to the repro and either finding out that it is a 2 line fix or requires a complete reimplementation of 2 stages of the compiler.

predrag,
@predrag@hachyderm.io avatar

@ekuber @jhpratt ah yes, the two bug flavors...

Hoping it's the first one! 🤞

jhpratt,
@jhpratt@mastodon.social avatar

@predrag @ekuber Me too! I'm going to use the self-profile feature to try to determine where time is being spent. Creating a minimal reproduction may be tricky, as the underlying library is relatively intertwined.

jhpratt,
@jhpratt@mastodon.social avatar

@predrag @ekuber Oh, I forgot to mention. This happens with cargo check, so it is unquestionably rustc and not LLVM.

jhpratt,
@jhpratt@mastodon.social avatar

@predrag @ekuber

Discarding the smallest checks as insignificant, it's certainly exponential. Best fit is an exponent of 1.27749 × the number of methods chained; correlation is 0.992.

A chain of 11 methods took 7m51s to type check, and I didn't dare to try 12 (which was my original code).

typeck: 28.941%
normalize_canonicalized_projection_ty 26.938%
type_op_prove_predicate 25.097%
codegen_select_candidate 12.080%
LLVM_passes 5.534%

Any tips on creating a minimal example for an issue?

ekuber,
@ekuber@hachyderm.io avatar

@jhpratt @predrag replacing bodies with loop {} is the first step I do, I'm guessing this is on some where bound or impl Trait return?

jhpratt,
@jhpratt@mastodon.social avatar

@ekuber @predrag Very much so — every part of the API is based around trait impls. Stubbing bodies is a good starting place.

ekuber,
@ekuber@hachyderm.io avatar

@jhpratt @predrag I'm sure @errs will be looking forward to the report 😀

  • All
  • Subscribed
  • Moderated
  • Favorites
  • rust
  • ngwrru68w68
  • rosin
  • GTA5RPClips
  • osvaldo12
  • love
  • Youngstown
  • slotface
  • khanakhh
  • everett
  • kavyap
  • mdbf
  • DreamBathrooms
  • thenastyranch
  • magazineikmin
  • anitta
  • InstantRegret
  • normalnudes
  • tacticalgear
  • cubers
  • ethstaker
  • modclub
  • cisconetworking
  • Durango
  • provamag3
  • tester
  • Leos
  • megavids
  • JUstTest
  • All magazines