[GHC] #12706: Collecting type info is slow

#12706: Collecting type info is slow -------------------------------------+------------------------------------- Reporter: vshabanov | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 8.0.1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- With `:set +c` option in GHCi, I'm waiting for 10-15 seconds for {{{ Collecting type info for 34 module(s) ... }}} after both first load and subsequent reloads, even if only top-level module was modified. And GHCi uses about 1.5-2x more memory than it uses without `:set +c`. My app has about 30k lines of code. Is it expected behavior and some performance improvements are planned or it's a bug? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12706 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12706: Collecting type info is slow -------------------------------------+------------------------------------- Reporter: vshabanov | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by nomeata):
Is it expected behavior and some performance improvements are planned or it's a bug?
I would not be surprised to find that this is a rather rarely used feature and may not have gotten the necessary attention. But this might also mean that there is some low-hanging fruit. I would recommend building a profiled compiler and get a profile for this bit, just to see if there are obvious hotspots. vshabanov, are you interested in working on this, or just reporting it for now? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12706#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12706: Collecting type info is slow -------------------------------------+------------------------------------- Reporter: vshabanov | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by vshabanov): Latest haskell-mode for Emacs uses ":set +c" by default. So it's not that rarely used. I will try to build a profiled compiler and look whether there is something obvious. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12706#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12706: Collecting type info is slow -------------------------------------+------------------------------------- Reporter: vshabanov | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by vshabanov): I tried profiled compiler. Unfortunately I don't know GHC internals well enough to fix it but, anyway, here are my findings. Most time is spent in source:ghc/ghc/GHCi/UI/Info.hs Half time is spent in `typecheckModule` call and another half in `everythingAllSpans`. First problem here is a bad `cacheInvalid` function. It checks file time of object file, but there are no object files in GHCi. So types are always collected for all modules instead of new/modified ones. I don't know how to correctly check what files were recompiled but it's the first thing to do to shorten "Collecting type info" phase. Clearing cache on `:l` in GHCi is also necessary to free memory. I'm also not sure about call to `typecheckModule`. Aren't modules already type checked? Maybe it's possible to get type check results that were already calculated. Harder thing to do is to optimize `everythingAllSpans`. It uses SYB approach to extract `LHsBind`, `LHsExpr` and `LPat` from `TypecheckedSource = Bag (Located HsBindLR)`. It could be rewritten using direct recursion over `HsBindLR` without `cast` and `gmapQ`. But it looks like quite a big task. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12706#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12706: Collecting type info is slow -------------------------------------+------------------------------------- Reporter: vshabanov | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by lelf): * cc: lelf (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12706#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12706: Collecting type info is slow -------------------------------------+------------------------------------- Reporter: vshabanov | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): D4459 Wiki Page: | -------------------------------------+------------------------------------- Changes (by alexbiehl): * differential: => D4459 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12706#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12706: Collecting type info is slow -------------------------------------+------------------------------------- Reporter: vshabanov | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D4459 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * differential: D4459 => Phab:D4459 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12706#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12706: Collecting type info is slow
-------------------------------------+-------------------------------------
Reporter: vshabanov | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: GHCi | Version: 8.0.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D4459
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#12706: Collecting type info is slow -------------------------------------+------------------------------------- Reporter: vshabanov | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D4459 Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): comment:7 should help significantly but there is still more to be done here. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12706#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC