... | @@ -12,10 +12,18 @@ GHC has a rich support for concurrency (forkIO, MVars, STM, Asynchronous excepti |
... | @@ -12,10 +12,18 @@ GHC has a rich support for concurrency (forkIO, MVars, STM, Asynchronous excepti |
|
But, why would we be interested in modifying GHC's concurrency environment? There are several good reasons to believe that a particular concurrent programming model, or a scheduling policy would not suit every application. With the emergence of many-core processors, we see NUMA effects becoming more prominent, and applications might benefit from NUMA aware scheduling and load balancing policies. Moreover, an application might have a better knowledge of the scheduling requirements -- a thread involved in user-interaction is expected to be given more priority over threads performing background processing. We might want to experiment with various work-stealing or work-sharing policies. More ambitiously, we might choose to build X10 style async-finish or Cilk style spawn-sync task parallel abstractions. Ideally, we would like allow the programmer to write an application that can seamlessly combine all of these different programming abstractions, with pluggable scheduling and load balancing policies.
|
|
But, why would we be interested in modifying GHC's concurrency environment? There are several good reasons to believe that a particular concurrent programming model, or a scheduling policy would not suit every application. With the emergence of many-core processors, we see NUMA effects becoming more prominent, and applications might benefit from NUMA aware scheduling and load balancing policies. Moreover, an application might have a better knowledge of the scheduling requirements -- a thread involved in user-interaction is expected to be given more priority over threads performing background processing. We might want to experiment with various work-stealing or work-sharing policies. More ambitiously, we might choose to build X10 style async-finish or Cilk style spawn-sync task parallel abstractions. Ideally, we would like allow the programmer to write an application that can seamlessly combine all of these different programming abstractions, with pluggable scheduling and load balancing policies.
|
|
|
|
|
|
|
|
|
|
While we want to provide flexibility to the Haskell programmer, this should not come at a cost of added complexity and decreased performance. This idea reflects in the synchronization abstractions exposed to the programmer ([PTM](lightweight-concurrency#)), and our decision to keep certain pieces of the concurrency puzzle in the RTS ([Safe FFI](lightweight-concurrency#),[Blackholes](lightweight-concurrency#)). The figure below captures the key design principles of the proposed system.
|
|
While we want to provide flexibility to the Haskell programmer, this should not come at a cost of added complexity and decreased performance. This idea reflects in the synchronization abstractions exposed to the programmer - [Primitive Transactional Memory(PTM)](lightweight-concurrency#)), and our decision to keep certain pieces of the concurrency puzzle in the RTS ([Safe FFI](lightweight-concurrency#),[Blackholes](lightweight-concurrency#)). One would think lifting parts of the runtime system to Haskell, and retaining other parts in C, would complicate the interactions between the concurrency primitives and schedulers. We abstract the scheduler interface using PTM monads, which simplifies the interactions. The figure below captures the key design principles of the proposed system.
|
|
|
|
|
|
[](/trac/ghc/attachment/wiki/LightweightConcurrency/GHC_LWC_Key.jpg)
|
|
[](/trac/ghc/attachment/wiki/LightweightConcurrency/GHC_LWC_Key.jpg)
|
|
|
|
|
|
|
|
|
|
|
|
Although implementing concurrency primitives as a library is hardly a novel idea, the aim of this work is to bring it to the GHC programmer, without having to give up any of the existing concurrency features in return.
|
|
|
|
|
|
|
|
## Background - GHC's Concurrency RTS
|
|
|
|
|
|
|
|
|
|
|
|
This section focuses on the concurrency part of the runtime system, and is intended to set a stage for subsequent discussions. This section also provides would-be GHC RTS hackers a summary of different parts of the system.
|
|
|
|
|
|
## Related Work
|
|
## Related Work
|
|
|
|
|
|
- [Concurrent Programming in GHC](lightweight-concurrency#)
|
|
- [Concurrent Programming in GHC](lightweight-concurrency#)
|
... | | ... | |