Compress TrieMap leaves with SingletonTM, fixes #9960
ClosedPublic

Authored by ezyang on Jan 6 2015, 3:34 PM.

Details

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.
ezyang updated this revision to Diff 2066.Jan 6 2015, 3:34 PM
ezyang retitled this revision from to Compress TrieMap leaves with SingletonTM, fixes #9960.
ezyang updated this object.
ezyang edited the test plan for this revision. (Show Details)
ezyang added a reviewer: simonpj.
ezyang updated the Trac tickets for this revision.
ezyang updated this revision to Diff 2067.Jan 6 2015, 3:56 PM
ezyang edited edge metadata.

Fix a bug

simonpj accepted this revision.Jan 6 2015, 4:29 PM
simonpj edited edge metadata.

Cool! Needs comments to explain the motivation.

Does the performance change? Of a test scenario? Of GHC?

This would be equally valuable for CoreExpr and Coercion.

Maybe we could wrap the generic stuff like this

type TypeMap a = GenMap Type TypeMapX a

data GenMap xmap key val
  = Empty
  | Singleton (CmEnv, key) val
  | Multi (xmap val)

data TypeMapX =
  = TM { tm_var   :: VarMap a
       , tm_app    :: TypeMap (TypeMap a)
       , tm_fun    :: TypeMap (TypeMap a)
   ... etc

That would share more code, admittedly at the expense of an extra Multi box at every level. Feels cleaner though.

Simon

Simon

compiler/coreSyn/TrieMap.hs
756

The else case can be better

case f Nothing of
   Nothing -> SingletonTM env_ty v
   Just v' -> xtT env ty (const (Just v)) $
                   xtT env' ty' (const (Just v'))
This revision is now accepted and ready to land.Jan 6 2015, 4:29 PM
ezyang planned changes to this revision.Jan 6 2015, 5:15 PM

I need to fix the coreView bug. If we're going to apply this to other constructors, we should definitely genericize it. I'll do that too.

ezyang updated this revision to Diff 2068.Jan 6 2015, 7:37 PM
ezyang edited edge metadata.

Normalize by coreView on equality test.

This revision is now accepted and ready to land.Jan 6 2015, 7:37 PM
ezyang updated this revision to Diff 2069.Jan 6 2015, 7:43 PM

Improve else case.

ezyang updated this revision to Diff 2070.Jan 6 2015, 9:00 PM

Get my ticks right

austin accepted this revision.Jan 6 2015, 10:52 PM
austin edited edge metadata.

LGTM.

This revision was automatically updated to reflect the committed changes.