#4262: GHC's runtime never terminates unused worker threads
---------------------------------+------------------------------------------
    Reporter:  Remi              |       Owner:                                 
         
        Type:  bug               |      Status:  new                            
         
    Priority:  normal            |   Component:  Runtime System                 
         
     Version:  6.12.3            |    Keywords:  worker thread foreign function 
interface
    Testcase:                    |   Blockedby:                                 
         
          Os:  Unknown/Multiple  |    Blocking:                                 
         
Architecture:  Unknown/Multiple  |     Failure:  Runtime performance bug        
         
---------------------------------+------------------------------------------
 When concurrently calling safe FFI functions, worker OS threads are
 created. These threads then never quit.

 The following toy program creates 30k OS threads (which is fine because
 that's exactly what it asks for) which are then never "garbage collected":
 30k threads and over 230g of VM are hanging around until the program
 exits.

 {{{
 {-# LANGUAGE ForeignFunctionInterface #-}
 module Main where

 import Control.Concurrent
 import Control.Monad
 import Foreign.C.Types
 import System.Mem

 foreign import ccall safe sleep :: CUInt -> IO ()

 main = do
     replicateM_ 30000 $ forkIO $ sleep 2
     getLine
     -- do other stuff
 }}}

 P.S. Of course I should simply use threadDelay in this case. The real
 program performs up to a few hundred concurrent fdatasync calls.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4262>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to