Per-thread allocation counters and limits
This tracks the amount of memory allocation by each thread in a counter stored in the TSO. Optionally, when the counter drops below zero (it counts down), the thread can be sent an asynchronous exception: AllocationLimitExceeded. When this happens, given a small additional limit so that it can handle the exception. See documentation in GHC.Conc for more details. Allocation limits are similar to timeouts, but - timeouts use real time, not CPU time. Allocation limits do not count anything while the thread is blocked or in foreign code. - timeouts don't re-trigger if the thread catches the exception, allocation limits do. - timeouts can catch non-allocating loops, if you use -fno-omit-yields. This doesn't work for allocation limits. I couldn't measure any impact on benchmarks with these changes, even for nofib/smp.
Showing
- compiler/cmm/CmmLayoutStack.hs 6 additions, 3 deletionscompiler/cmm/CmmLayoutStack.hs
- compiler/codeGen/StgCmmForeign.hs 196 additions, 72 deletionscompiler/codeGen/StgCmmForeign.hs
- includes/CodeGen.Platform.hs 1 addition, 3 deletionsincludes/CodeGen.Platform.hs
- includes/rts/Constants.h 6 additions, 0 deletionsincludes/rts/Constants.h
- includes/rts/Flags.h 8 additions, 0 deletionsincludes/rts/Flags.h
- includes/rts/Threads.h 6 additions, 2 deletionsincludes/rts/Threads.h
- includes/rts/storage/TSO.h 22 additions, 9 deletionsincludes/rts/storage/TSO.h
- libraries/base/Control/Exception.hs 1 addition, 0 deletionslibraries/base/Control/Exception.hs
- libraries/base/Control/Exception/Base.hs 1 addition, 0 deletionslibraries/base/Control/Exception/Base.hs
- libraries/base/GHC/Conc.lhs 6 additions, 0 deletionslibraries/base/GHC/Conc.lhs
- libraries/base/GHC/Conc/Sync.lhs 87 additions, 5 deletionslibraries/base/GHC/Conc/Sync.lhs
- libraries/base/GHC/IO/Exception.hs 20 additions, 1 deletionlibraries/base/GHC/IO/Exception.hs
- rts/HeapStackCheck.cmm 3 additions, 1 deletionrts/HeapStackCheck.cmm
- rts/Linker.c 4 additions, 0 deletionsrts/Linker.c
- rts/Prelude.h 2 additions, 0 deletionsrts/Prelude.h
- rts/RaiseAsync.c 54 additions, 0 deletionsrts/RaiseAsync.c
- rts/RaiseAsync.h 5 additions, 1 deletionrts/RaiseAsync.h
- rts/RtsFlags.c 10 additions, 0 deletionsrts/RtsFlags.c
- rts/RtsStartup.c 1 addition, 0 deletionsrts/RtsStartup.c
- rts/Schedule.c 19 additions, 0 deletionsrts/Schedule.c
Loading
Please register or sign in to comment