Changes between Version 1 and Version 2 of Commentary/Rts/Sanity


Ignore:
Timestamp:
Oct 20, 2006 9:20:46 AM (7 years ago)
Author:
simonmar
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Commentary/Rts/Sanity

    v1 v2  
    55The purpose of sanity checking is to catch bugs in the RTS as early as possible; if the program is going to crash, we want it to crash as soon as possible after the error occurred.  The problem with debugging the RTS is that heap corruption can go unnoticed through several GC cycles, making it particularly difficult to trace back to the erroneous code. 
    66 
    7 Sanity checking is turned on by the `+RTS -DS` option.  We treat it like an expensive assertion: normal assertions are allowed to take a few extra percent of runtime, so we don't mind having them on all the time in a `DEBUG` runtime, but sanity checking may double the run time of the program or worse.  So the rule of thumb is that expensive assertions go into sanity checking, cheap assertions are on in `DEBUG`, or possibly even on all the time. 
     7Sanity checking is turned on by the `+RTS -DS` option.  We treat it like an expensive assertion: normal assertions are allowed to take a few extra percent of run time, so we don't mind having them on all the time in a `DEBUG` RTS, but sanity checking may double the run time of the program or worse.  So the rule of thumb is that expensive assertions go into sanity checking, cheap assertions are on in `DEBUG`, or possibly even on all the time. 
    88 
    99Sanity checking does a complete traversal of the heap after each GC to look for dangling pointers (see `checkHeap` in [[GhcFile(rts/Sanity.c)]]).  For this it needs to ensure that there is no [wiki:Commentary/Rts/Storage/Slop slop], which is why we can only do this in a `DEBUG` runtime: the slop-avoiding machinery is only on with `DEBUG`.