Allocate less in plus_mod_dep
ClosedPublic

Authored by niteria on Jan 21 2018, 12:01 PM.

Details

Summary

This gives a 10% allocation improvement on MultiLayerModules.
The idea is to reuse existing tuples, instead of constantly
constructing new ones.
I'm not sure if the warning gives any value, I left it because
I don't understand why it would fire.

Test Plan

./validate

Diff Detail

Repository
rGHC Glasgow Haskell Compiler
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
niteria created this revision.Jan 21 2018, 12:01 PM
bgamari accepted this revision.Jan 21 2018, 2:19 PM

Wow, that is quite a difference.

This revision is now accepted and ready to land.Jan 21 2018, 2:19 PM
simonpj accepted this revision.Jan 22 2018, 3:15 AM

Good. Small refactoring suggestions

compiler/typecheck/TcRnTypes.hs
1402

I'd prefer

plus_mod_dep r1@(m1, boot1) r2@(m2, boot2)
  | WARN( ... )
    boot1       -> r2
  | otherwise -> r1
  -- If either side can "see" a non-hi-boot interface, use that
  -- Reusing existing tuples saves 10% on test perf/compiler/MultiLayerModules
1403

I think this can be an ASSERT. I think the idea is that in the imp_dep_mods finite map, we always have m :-> (m, blah), so when combining the m's should be the same.

niteria updated this revision to Diff 15207.Jan 23 2018, 4:55 PM

address comments

This revision was automatically updated to reflect the committed changes.