[GHC] #15019: Fix performance regressions from #14737

GHC ghc-devs at haskell.org
Tue Apr 24 14:13:26 UTC 2018


#15019: Fix performance regressions from #14737
-------------------------------------+-------------------------------------
        Reporter:  tdammers          |                Owner:  tdammers
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:  8.6.1
       Component:  Compiler          |              Version:
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Compile-time      |  Unknown/Multiple
  performance bug                    |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #14737            |  Differential Rev(s):  phab:D4568
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by tdammers):

 Looking at one of the regressions, T9010, I set up a trap to catch only
 those coercions that are found to be equal by `eqType`, but don't match on
 `isReflCo`. And they're all the same: `(State# RealWorld -> (# State#
 RealWorld, () #), State# RealWorld -> (# State# RealWorld, () #))`. So
 this one looks like it would be relatively easy to detect.

 Unfortunately, the other one, T12707, paints a different picture; here,
 the matches look like these:
 {{{
   (forall a. K1 R Bool a -> [String] -> [String],
    forall a. K1 R Bool a -> [String] -> [String])
 }}}

 {{{
   (forall a.
    M1
      S
      ('MetaSel
         ('Just "foo3Field08")
         'NoSourceUnpackedness
         'SourceStrict
         'DecidedStrict)
      (K1 R (Maybe Bool))
      a
    -> [String] -> [String],
    forall a.
    M1
      S
      ('MetaSel
         ('Just "foo3Field08")
         'NoSourceUnpackedness
         'SourceStrict
         'DecidedStrict)
      (Rec0 (Maybe Bool))
      a
    -> [String] -> [String])
 }}}

 {{{
   (forall a.
    (:*:)
      (((S1
           ('MetaSel
              ('Just "foo0Field00")
              'NoSourceUnpackedness
              'SourceStrict
              'DecidedStrict)
           (Rec0 String)
         :*: S1
               ('MetaSel
                  ('Just "foo0Field01")
                  'NoSourceUnpackedness
                  'SourceStrict
                  'DecidedUnpack)
               (Rec0 Int))
        :*: (S1
               ('MetaSel
                  ('Just "foo0Field02")
                  'NoSourceUnpackedness
                  'SourceStrict
                  'DecidedStrict)
               (Rec0 [Int])
             :*: (S1
                    ('MetaSel
                       ('Just "foo0Field03")
                       'NoSourceUnpackedness
                       'SourceStrict
                       'DecidedStrict)
                    (Rec0 (Maybe Bool))
                  :*: S1
                        ('MetaSel
                           ('Just "foo0Field04")
                           'NoSourceUnpackedness
                           'SourceStrict
                           'DecidedStrict)
                        (Rec0 Bool))))
       :*: ((S1
               ('MetaSel
                  ('Just "foo0Field05")
                  'NoSourceUnpackedness
                  'SourceStrict
                  'DecidedStrict)
               (Rec0 String)
             :*: S1
                   ('MetaSel
                      ('Just "foo0Field06")
                      'NoSourceUnpackedness
                      'SourceStrict
                      'DecidedUnpack)
                   (Rec0 Int))
            :*: (S1
                   ('MetaSel
                      ('Just "foo0Field07")
                      'NoSourceUnpackedness
                      'SourceStrict
                      'DecidedStrict)
                   (Rec0 [Int])
                 :*: (S1
                        ('MetaSel
                           ('Just "foo0Field08")
                           'NoSourceUnpackedness
                           'SourceStrict
                           'DecidedStrict)
                        (Rec0 (Maybe Bool))
                      :*: S1
                            ('MetaSel
                               ('Just "foo0Field09")
                               'NoSourceUnpackedness
                               'SourceStrict
                               'DecidedStrict)
                            (Rec0 Bool)))))
      (((S1
           ('MetaSel
              ('Just "foo0Field10")
              'NoSourceUnpackedness
              'SourceStrict
              'DecidedStrict)
           (Rec0 String)
         :*: S1
               ('MetaSel
                  ('Just "foo0Field11")
                  'NoSourceUnpackedness
                  'SourceStrict
                  'DecidedUnpack)
               (Rec0 Int))
        :*: (S1
               ('MetaSel
                  ('Just "foo0Field12")
                  'NoSourceUnpackedness
                  'SourceStrict
                  'DecidedStrict)
               (Rec0 [Int])
             :*: (S1
                    ('MetaSel
                       ('Just "foo0Field13")
                       'NoSourceUnpackedness
                       'SourceStrict
                       'DecidedStrict)
                    (Rec0 (Maybe Bool))
                  :*: S1
                        ('MetaSel
                           ('Just "foo0Field14")
                           'NoSourceUnpackedness
                           'SourceStrict
                           'DecidedStrict)
                        (Rec0 Bool))))
       :*: ((S1
               ('MetaSel
                  ('Just "foo0Field15")
                  'NoSourceUnpackedness
                  'SourceStrict
                  'DecidedStrict)
               (Rec0 String)
             :*: S1
                   ('MetaSel
                      ('Just "foo0Field16")
                      'NoSourceUnpackedness
                      'SourceStrict
                      'DecidedUnpack)
                   (Rec0 Int))
            :*: (S1
                   ('MetaSel
                      ('Just "foo0Field17")
                      'NoSourceUnpackedness
                      'SourceStrict
                      'DecidedStrict)
                   (Rec0 [Int])
                 :*: (S1
                        ('MetaSel
                           ('Just "foo0Field18")
                           'NoSourceUnpackedness
                           'SourceStrict
                           'DecidedStrict)
                        (Rec0 (Maybe Bool))
                      :*: S1
                            ('MetaSel
                               ('Just "foo0Field19")
                               'NoSourceUnpackedness
                               'SourceStrict
                               'DecidedStrict)
                            (Rec0 Bool)))))
      a
    -> [String] -> [String],
    forall a.
    (:*:)
      (((S1
           ('MetaSel
              ('Just "foo0Field00")
              'NoSourceUnpackedness
              'SourceStrict
              'DecidedStrict)
           (Rec0 String)
         :*: S1
               ('MetaSel
                  ('Just "foo0Field01")
                  'NoSourceUnpackedness
                  'SourceStrict
                  'DecidedUnpack)
               (Rec0 Int))
        :*: (S1
               ('MetaSel
                  ('Just "foo0Field02")
                  'NoSourceUnpackedness
                  'SourceStrict
                  'DecidedStrict)
               (Rec0 [Int])
             :*: (S1
                    ('MetaSel
                       ('Just "foo0Field03")
                       'NoSourceUnpackedness
                       'SourceStrict
                       'DecidedStrict)
                    (Rec0 (Maybe Bool))
                  :*: S1
                        ('MetaSel
                           ('Just "foo0Field04")
                           'NoSourceUnpackedness
                           'SourceStrict
                           'DecidedStrict)
                        (Rec0 Bool))))
       :*: ((S1
               ('MetaSel
                  ('Just "foo0Field05")
                  'NoSourceUnpackedness
                  'SourceStrict
                  'DecidedStrict)
               (Rec0 String)
             :*: S1
                   ('MetaSel
                      ('Just "foo0Field06")
                      'NoSourceUnpackedness
                      'SourceStrict
                      'DecidedUnpack)
                   (Rec0 Int))
            :*: (S1
                   ('MetaSel
                      ('Just "foo0Field07")
                      'NoSourceUnpackedness
                      'SourceStrict
                      'DecidedStrict)
                   (Rec0 [Int])
                 :*: (S1
                        ('MetaSel
                           ('Just "foo0Field08")
                           'NoSourceUnpackedness
                           'SourceStrict
                           'DecidedStrict)
                        (Rec0 (Maybe Bool))
                      :*: S1
                            ('MetaSel
                               ('Just "foo0Field09")
                               'NoSourceUnpackedness
                               'SourceStrict
                               'DecidedStrict)
                            (Rec0 Bool)))))
      (((S1
           ('MetaSel
              ('Just "foo0Field10")
              'NoSourceUnpackedness
              'SourceStrict
              'DecidedStrict)
           (Rec0 String)
         :*: S1
               ('MetaSel
                  ('Just "foo0Field11")
                  'NoSourceUnpackedness
                  'SourceStrict
                  'DecidedUnpack)
               (Rec0 Int))
        :*: (S1
               ('MetaSel
                  ('Just "foo0Field12")
                  'NoSourceUnpackedness
                  'SourceStrict
                  'DecidedStrict)
               (Rec0 [Int])
             :*: (S1
                    ('MetaSel
                       ('Just "foo0Field13")
                       'NoSourceUnpackedness
                       'SourceStrict
                       'DecidedStrict)
                    (Rec0 (Maybe Bool))
                  :*: S1
                        ('MetaSel
                           ('Just "foo0Field14")
                           'NoSourceUnpackedness
                           'SourceStrict
                           'DecidedStrict)
                        (Rec0 Bool))))
       :*: ((S1
               ('MetaSel
                  ('Just "foo0Field15")
                  'NoSourceUnpackedness
                  'SourceStrict
                  'DecidedStrict)
               (Rec0 String)
             :*: S1
                   ('MetaSel
                      ('Just "foo0Field16")
                      'NoSourceUnpackedness
                      'SourceStrict
                      'DecidedUnpack)
                   (Rec0 Int))
            :*: (S1
                   ('MetaSel
                      ('Just "foo0Field17")
                      'NoSourceUnpackedness
                      'SourceStrict
                      'DecidedStrict)
                   (Rec0 [Int])
                 :*: (S1
                        ('MetaSel
                           ('Just "foo0Field18")
                           'NoSourceUnpackedness
                           'SourceStrict
                           'DecidedStrict)
                        (Rec0 (Maybe Bool))
                      :*: S1
                            ('MetaSel
                               ('Just "foo0Field19")
                               'NoSourceUnpackedness
                               'SourceStrict
                               'DecidedStrict)
                            (Rec0 Bool)))))
      a
    -> [String] -> [String])
 }}}

 Further digging, however, reveals that these are all `Sym` coercions, so I
 think I can figure out a faster way to detect these.

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15019#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list