make expensive checks in asserts optional (#125)

This adds an Internal/EnableExpensiveChecks setting for enabling some or all expensive run-time checks to avoid a massive slowdown when assertions are enabled at compile-time. Currently these cover only the writer and reader-history cache checking.

Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
Erik Boasson 2019-03-23 13:10:53 +01:00
parent a39701fc2e
commit 7540ac8229
4 changed files with 93 additions and 29 deletions

View file

@ -2625,6 +2625,9 @@ int dds_rhc_takecdr
#define CHECK_MAX_CONDS 64
static int rhc_check_counts_locked (struct rhc *rhc, bool check_conds, bool check_qcmask)
{
if (!(config.enabled_xchecks & DDS_XCHECK_RHC))
return 1;
const uint32_t ncheck = rhc->nconds < CHECK_MAX_CONDS ? rhc->nconds : CHECK_MAX_CONDS;
unsigned n_instances = 0, n_nonempty_instances = 0;
unsigned n_not_alive_disposed = 0, n_not_alive_no_writers = 0, n_new = 0;

View file

@ -258,6 +258,7 @@ static void check_whc (const struct whc_impl *whc)
assert (whc->maxseq_node == whc_findmax_procedurally (whc));
#if !defined(NDEBUG)
if (config.enabled_xchecks & DDS_XCHECK_WHC)
{
struct whc_intvnode *firstintv;
struct whc_node *cur;