diff --git a/c_src/bdberl_drv.c b/c_src/bdberl_drv.c index 1b30514..f1d5b46 100644 --- a/c_src/bdberl_drv.c +++ b/c_src/bdberl_drv.c @@ -97,8 +97,8 @@ static unsigned int G_DEADLOCK_CHECK_INTERVAL = 100; /* Milliseconds between che */ static ErlDrvTid G_TRICKLE_THREAD = 0; static unsigned int G_TRICKLE_ACTIVE = 1; -static unsigned int G_TRICKLE_INTERVAL = 60 * 15; /* Seconds between trickle writes */ -static unsigned int G_TRICKLE_PERCENTAGE = 10; /* Desired % of clean pages in cache */ +static unsigned int G_TRICKLE_INTERVAL = 60 * 5; /* Seconds between trickle writes */ +static unsigned int G_TRICKLE_PERCENTAGE = 50; /* Desired % of clean pages in cache */ /** @@ -214,6 +214,28 @@ DRIVER_INIT(bdberl_drv) } } + // Use the BDBERL_TRICKLE_TIME and BDBERL_TRICKLE_PERCENTAGE to control how often + // the trickle writer runs and what percentage of pages should be flushed. + char* trickle_time_str = getenv("BDBERL_TRICKLE_TIME"); + if (trickle_time_str != 0) + { + G_TRICKLE_INTERVAL = atoi(trickle_time_str); + if (G_TRICKLE_INTERVAL <= 0) + { + G_TRICKLE_INTERVAL = 60 * 5; + } + } + + char* trickle_percentage_str = getenv("BDBERL_TRICKLE_PERCENTAGE"); + if (trickle_percentage_str != 0) + { + G_TRICKLE_PERCENTAGE = atoi(trickle_percentage_str); + if (G_TRICKLE_PERCENTAGE <= 0) + { + G_TRICKLE_PERCENTAGE = 50; + } + } + // Make sure we can distiguish between lock timeouts and deadlocks G_DB_ENV->set_flags(G_DB_ENV, DB_TIME_NOTGRANTED, 1);