Browse Source

ckdb - allow changing CULL_TRANSFER

master
kanoi 8 years ago
parent
commit
9b8aaaf038
  1. 9
      src/ckdb.c
  2. 12
      src/ckdb.h
  3. 21
      src/ckdb_dbio.c

9
src/ckdb.c

@ -624,6 +624,7 @@ K_STORE *heartbeatqueue_store;
// TRANSFER
K_LIST *transfer_free;
int cull_transfer = CULL_TRANSFER;
// SEQSET
K_LIST *seqset_free;
@ -2059,7 +2060,7 @@ static void alloc_storage()
transfer_free = k_new_list_cull(Transfer, sizeof(TRANSFER),
ALLOC_TRANSFER, LIMIT_TRANSFER, true,
CULL_TRANSFER);
cull_transfer);
transfer_free->dsp_func = dsp_transfer;
users_free = k_new_list("Users", sizeof(USERS),
@ -2277,6 +2278,9 @@ static void alloc_storage()
userinfo_root = new_ktree(NULL, cmp_userinfo, userinfo_free);
#if LOCK_CHECK
// Above all needed for optioncontrol_trigger()
DLPRIO(optioncontrol, 96);
DLPRIO(seqset, 91);
DLPRIO(transfer, 90);
@ -2302,9 +2306,6 @@ static void alloc_storage()
DLPRIO(userinfo, 50);
// Uses event_limits
DLPRIO(optioncontrol, 49);
// Needs to check users and ips and uses events_limits
DLPRIO(events, 48);
DLPRIO(ovents, 47);

12
src/ckdb.h

@ -58,7 +58,7 @@
#define DB_VLOCK "1"
#define DB_VERSION "1.0.7"
#define CKDB_VERSION DB_VERSION"-2.601"
#define CKDB_VERSION DB_VERSION"-2.602"
#define WHERE_FFL " - from %s %s() line %d"
#define WHERE_FFL_HERE __FILE__, __func__, __LINE__
@ -1563,14 +1563,18 @@ typedef struct transfer {
// Suggest malloc use MMAP = largest under 2MB
#define ALLOC_TRANSFER ((int)(2*1024*1024/sizeof(TRANSFER)))
#define LIMIT_TRANSFER 0
/* ALLOC_TRANSFER is ~14k, but it should only ever get this big during a reload
* so set it a bit above that */
#define CULL_TRANSFER 32768
// ALLOC_TRANSFER is ~14k, allocated often is 3
#define CULL_TRANSFER (4 * ALLOC_TRANSFER)
#define INIT_TRANSFER(_item) INIT_GENERIC(_item, transfer)
#define DATA_TRANSFER(_var, _item) DATA_GENERIC(_var, _item, transfer, true)
extern K_LIST *transfer_free;
/* Allow defining and adjusting it on a running system
* cull_limit is set to the optionvalue * ALLOC_TRANSFER */
#define CULL_TRANSFER_NAME "CullTransfer"
extern int cull_transfer;
#define transfer_data(_item) _transfer_data(_item, WHERE_FFL_HERE)
extern const char Transfer[];

21
src/ckdb_dbio.c

@ -2786,12 +2786,33 @@ void oc_ips(OPTIONCONTROL *oc, const char *from)
}
}
void oc_trf(OPTIONCONTROL *oc, const char *from)
{
int ct;
ct = atoi(oc->optionvalue);
if (ct < 0 || ct > 64) {
LOGERR("%s(%s) ERR set cull_transfer ignored '%s' (%d)"
" must be 0..64",
from, __func__, oc->optionvalue, ct);
} else {
K_WLOCK(transfer_free);
// ct isn't the value, it's the multiplier
cull_transfer = ct * ALLOC_TRANSFER;
transfer_free->cull_limit = cull_transfer;
K_WUNLOCK(transfer_free);
LOGWARNING("%s(%s) set cull_transfer to %d->%d",
from, __func__, ct, cull_transfer);
}
}
OC_TRIGGER oc_trigger[] = {
{ SWITCH_STATE_NAME, true, oc_switch_state },
{ DIFF_PERCENT_NAME, true, oc_diff_percent },
{ OC_LIMITS, false, oc_event_limits },
{ OC_OLIMITS, false, oc_ovent_limits },
{ OC_IPS, false, oc_ips },
{ CULL_TRANSFER_NAME, true, oc_trf },
{ NULL, 0, NULL }
};

Loading…
Cancel
Save