[GHC] #15997: EventManager could benefit from Data.Primitive.UnliftedArray

GHC ghc-devs at haskell.org
Wed Dec 5 16:00:33 UTC 2018


#15997: EventManager could benefit from Data.Primitive.UnliftedArray
-------------------------------------+-------------------------------------
           Reporter:  chessai        |             Owner:  (none)
               Type:  feature        |            Status:  new
  request                            |
           Priority:  normal         |         Milestone:  8.6.3
          Component:                 |           Version:  8.6.2
  libraries/base                     |
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 {{{#!hs
 -- | The event manager state.
 data EventManager = EventManager
     { emBackend      :: !Backend
     , emFds          :: {-# UNPACK #-} !(Array Int (MVar (IntTable
 [FdData])))
     , emState        :: {-# UNPACK #-} !(IORef State)
     , emUniqueSource :: {-# UNPACK #-} !UniqueSource
     , emControl      :: {-# UNPACK #-} !Control
     , emLock         :: {-# UNPACK #-} !(MVar ())
     }
 }}}

 the field in question is an `Array Int (MVar (IntTable [FdData]))`.

 `EventManager` could instead be:

 {{{#!hs

 type MVarIO = MVar# RealWorld -- type synonym for brevity

 -- | The event manager state.
 data EventManager = EventManager
     { emBackend      :: !Backend
     , emFds          :: {-# UNPACK #-} !(UnliftedArray (MVarIO (IntTable
 [FdData])))
     , emState        :: {-# UNPACK #-} !(IORef State)
     , emUniqueSource :: {-# UNPACK #-} !UniqueSource
     , emControl      :: {-# UNPACK #-} !Control
     , emLock         :: {-# UNPACK #-} !(MVar ())
     }
 }}}

 now the `UnliftedArray` contains non-thunks.

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


More information about the ghc-tickets mailing list