Opened 6 years ago

Closed 5 years ago

#8174 closed bug (duplicate)

GHC should not load packages for TH if they are not used

Reported by: nh2 Owned by:
Priority: normal Milestone: 7.10.1
Component: Compiler Version: 7.6.3
Keywords: Cc: mail@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Compile-time performance bug Test Case:
Blocked By: Blocking:
Related Tickets: #2437 Differential Rev(s):
Wiki Page:

Description

https://github.com/nh2/ghc-bug-th-loading

When you call

ghc --make -package mypackage

on a module that uses TH, you will see

Loading package mypackage-1.2.3.4 ... linking ... done.

even if no code uses it. This slows down builds, especially cabal ones.

GHCI does this better and only loads what is needed.

Change History (8)

comment:1 Changed 6 years ago by hvr

fwiw, when I call ghci -package vector, it gets loaded eagerly too:

$ ghci -package vector 
GHCi, version 7.6.3: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package array-0.4.0.1 ... linking ... done.
Loading package deepseq-1.3.0.1 ... linking ... done.
Loading package primitive-0.5.0.1 ... linking ... done.
Loading package vector-0.10.0.1 ... linking ... done.
Prelude> 

comment:2 Changed 6 years ago by nh2

Hmm, you are right. I wonder from what I got the impression that GHCI didn't do this.

Still, do you think it is possible to make them load the packages lazily, when needed?

comment:3 Changed 6 years ago by ezyang

In some sense, GHCi is already loading the packages semi-lazily; GHC won't resolve any objects until you actually attempt to use an object.

comment:4 in reply to:  3 Changed 6 years ago by nh2

Replying to ezyang:

In some sense, GHCi is already loading the packages semi-lazily; GHC won't resolve any objects until you actually attempt to use an object.

What does "resolving objects" mean? Could you elaborate a bit?

comment:5 Changed 6 years ago by ezyang

Sorry, it looks like I was mistaken.

comment:6 Changed 6 years ago by akio

#2437 and #3560 seem to be related to this.

comment:7 Changed 6 years ago by thoughtpolice

Milestone: 7.8.37.10.1

Moving to 7.10.1

comment:8 Changed 5 years ago by thomie

Resolution: duplicate
Status: newclosed

This seems to be covered by #2437. I added a link back to this ticket.

Note: See TracTickets for help on using tickets.