Opened 5 years ago

Last modified 3 years ago

#9717 new bug

More lazy orphan module loading

Reported by: ezyang Owned by: ezyang
Priority: normal Milestone:
Component: Compiler (Type checker) Version: 7.9
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s): Phab:D454
Wiki Page:

Description

Currently, when we import a module, we eagerly load all of the orphan modules transitively reachable from it (TcRnDriver:tcRnImports). This is a bit of bummer: as module import hierarchies get deeper and deeper, we'll collect more and more orphan instances and load more and more modules eagerly.

The idea is to try to arrange for an orphan module not to be loaded, unless we think that it might have a relevant instance. Instead of just recording a list of orphan modules transitively reachable from a module, we will also record a digest of what type classes and types the orphan provides instances for. (This will be similar to the data we record for ifInstTys in IfaceClsInst.)

Now, when we do any operation involving instances, we check and see if there are also orphans which could provide relevant instances (based on the digest) and load those. If an instance could never have been used, we avoid loading its interface file entirely.

This doesn't appear to help too much for type families, where we have to load all of the instances anyway in order to check for consistency.

A choice to make: Should we record just the class, or also the types involved? It would be best if we could quickly conclude that there are no more instances to load, but this may be difficult if matching against types as well.

Change History (7)

comment:1 Changed 5 years ago by simonpj

See also #9729

comment:2 Changed 5 years ago by thoughtpolice

Milestone: 7.10.17.12.1

Moving to 7.12.1 milestone; if you feel this is an error and should be addressed sooner, please move it back to the 7.10.1 milestone.

comment:3 Changed 5 years ago by ezyang

Differential Rev(s): D454

comment:4 Changed 5 years ago by ezyang

Differential Rev(s): D454Phab:D454

comment:5 Changed 4 years ago by thoughtpolice

Milestone: 7.12.18.0.1

Milestone renamed

comment:6 Changed 4 years ago by thomie

Milestone: 8.0.1

comment:7 Changed 3 years ago by ezyang

Keywords: backpack removed
Note: See TracTickets for help on using tickets.