Opened 6 months ago

Closed 6 months ago

#8474 closed bug (fixed)

Extremely slow compilation of a program with multiply implicit parameters

Reported by: akamaus Owned by:
Priority: normal Milestone:
Component: Compiler (Type checker) Version: 7.6.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty: Unknown
Test Case: typecheck/should_compile/T8474 Blocked By:
Blocking: Related Tickets:

Description (last modified by simonpj)

Adding yet another ?tstX variable in this snippet slows down compilation by a factor of ten or so. Giving an explicit type annotation to tst1 makes compilation instant.

{-# LANGUAGE ImplicitParams #-}

data D = D Int deriving Show

slow_to_compile :: IO ()
slow_to_compile = do
  tst1 <- return 1

  let ?tst1 = tst1
  let ?tst2 = tst1
  let ?tst3 = tst1
  let ?tst4 = tst1
  let ?tst5 = tst1
  let ?tst6 = tst1
  let ?tst7 = tst1

  print $ D ?tst1

Change History (4)

comment:1 Changed 6 months ago by simonpj

  • Description modified (diff)

Yes, you're right. We'll fix this!

Simon

comment:2 Changed 6 months ago by Simon Peyton Jones <simonpj@…>

In 54717c8218cb27b1f1f56ba019c17494556f766c/ghc:

Be more careful when iterating the constraint-simpifier loop (fixes Trac #8474)

We were (uselessly) iterating the simplification loop an exponential
number of times.  Lovely simple test case showed this up.

See Note [Cutting off simpl_loop] in TcSimplify

comment:3 Changed 6 months ago by Simon Peyton Jones <simonpj@…>

comment:4 Changed 6 months ago by simonpj

  • Resolution set to fixed
  • Status changed from new to closed
  • Test Case set to typecheck/should_compile/T8474

Terrific example, very insightful, thank you. Now fixed.

Simon

Note: See TracTickets for help on using tickets.