Opened 4 years ago

Closed 4 years ago

#11597 closed task (fixed)

Optimize cmpTypeX

Reported by: goldfire Owned by: goldfire
Priority: highest Milestone: 8.0.1
Component: Compiler Version: 7.10.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Compile-time performance bug Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s): Phab:D1944
Wiki Page:


Simon and I observed that we could skip the kind-check in cmpTypeX if the type has no casts, which is the vastly common case. I will collect this information while checking the type and omit the kind check if possible.

Putting on "highest" priority basically because this is so easy to do.

Change History (4)

comment:1 Changed 4 years ago by simonpj

Also see Bartosz's data in #11371, comment 43. Data here:

 346492   piResultTys Levity -> *
 308771   piResultTys * -> * -> *
 147177   piResultTys * -> *
  18410   piResultTys * -> * -> * -> *
  10407   piResultTys *
    142   piResultTys * -> #
     70   piResultTys Levity
     66   piResultTys * -> Constraint
     24   piResultTys (* -> *) -> Constraint

(Relevance: piResultTys is called by typeKind, which is called by cmpTypeX.)

comment:2 Changed 4 years ago by Ben Gamari <ben@…>

In 073e20e/ghc:

cmpTypeX: Avoid kind comparison when possible

This comparison is only necessary when the types being compared contain
casts. Otherwise the structural equality of the types implies that their
kinds are equal.

Test Plan: Validate

Reviewers: goldfire, austin, simonpj

Reviewed By: simonpj

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #11597

comment:3 Changed 4 years ago by bgamari

Differential Rev(s): Phab:D1944
Status: newmerge
Type of failure: None/UnknownCompile-time performance bug

comment:4 Changed 4 years ago by bgamari

Resolution: fixed
Status: mergeclosed
Note: See TracTickets for help on using tickets.