refactor(controller): extract init_controller_tunables() for perf params
Add ctrl_tunables struct to cluster_t with per-table fields: jobmgr_nhash/delta, workermgr_nhash/delta, qmgr_nhash/delta, resmgr_nhash/delta/inst, xstrings_nhash init_controller_tunables() sets defaults (jobs=512, others=128) and is called from cluster_init_phase1 so values are available before cluster_init_phase2. Phase2 reads from c->tunables instead of cluster_config or local #defines. Each table gets its own values since they hold different item counts: jobs can scale to hundreds, workers/queues/resources are typically single-digit to tens.
This commit is contained in:
parent
5f1af48d57
commit
c42e1e0cb4
2 changed files with 54 additions and 14 deletions
|
|
@ -647,6 +647,32 @@ static void config_obj_killer(void* arg)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* init_controller_tunables: set performance-tuning defaults on c->tunables.
|
||||
*
|
||||
* Called early in cluster_init_phase1 so the values are available throughout
|
||||
* the startup sequence (including pre-election and phase2).
|
||||
*
|
||||
* TODO: wire these to cluster_config fields once the config generation tool
|
||||
* supports jobmgr/workermgr/qmgr/resmgr/xstrings (@13–@17).
|
||||
*/
|
||||
static void init_controller_tunables(cluster_t *c)
|
||||
{
|
||||
/* Jobs can be numerous; workers/queues/resources are typically smaller.
|
||||
* TODO: replace with config-driven values once the config generation tool
|
||||
* supports cluster_config fields @13–@17 (jobmgr/workermgr/qmgr/resmgr/xstrings). */
|
||||
c->tunables.jobmgr_nhash = 512;
|
||||
c->tunables.jobmgr_delta = 128;
|
||||
c->tunables.workermgr_nhash = 128;
|
||||
c->tunables.workermgr_delta = 32;
|
||||
c->tunables.qmgr_nhash = 128;
|
||||
c->tunables.qmgr_delta = 32;
|
||||
c->tunables.resmgr_nhash = 128;
|
||||
c->tunables.resmgr_delta = 32;
|
||||
c->tunables.resmgr_inst = 64;
|
||||
c->tunables.xstrings_nhash = 512;
|
||||
}
|
||||
|
||||
int cluster_init_phase1(cluster_t* c)
|
||||
{
|
||||
int rc;
|
||||
|
|
@ -728,6 +754,8 @@ int cluster_init_phase1(cluster_t* c)
|
|||
* cluster_open_listener() uses this for its idempotency guard. */
|
||||
c->ep.fd = -1;
|
||||
|
||||
init_controller_tunables(c);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -820,23 +848,19 @@ int cluster_init_phase2(cluster_t* c)
|
|||
mylock_init(&(c->sched.lock));
|
||||
c->sched.ep = NULL;
|
||||
|
||||
/* TODO: replace with config-driven values once config generation tool is ready */
|
||||
#define CTRL_PERF_NHASH 512
|
||||
#define CTRL_PERF_DELTA 64
|
||||
#define CTRL_PERF_INST 64
|
||||
resmgr_params.nslots = CTRL_PERF_NHASH;
|
||||
resmgr_params.delta = CTRL_PERF_DELTA;
|
||||
jobmgr_params.nslots = CTRL_PERF_NHASH;
|
||||
jobmgr_params.delta = CTRL_PERF_DELTA;
|
||||
workermgr_params.nslots = CTRL_PERF_NHASH;
|
||||
workermgr_params.delta = CTRL_PERF_DELTA;
|
||||
qmgr_params.nslots = CTRL_PERF_NHASH;
|
||||
qmgr_params.delta = CTRL_PERF_DELTA;
|
||||
resmgr_params.nslots = c->tunables.resmgr_nhash;
|
||||
resmgr_params.delta = c->tunables.resmgr_delta;
|
||||
jobmgr_params.nslots = c->tunables.jobmgr_nhash;
|
||||
jobmgr_params.delta = c->tunables.jobmgr_delta;
|
||||
workermgr_params.nslots = c->tunables.workermgr_nhash;
|
||||
workermgr_params.delta = c->tunables.workermgr_delta;
|
||||
qmgr_params.nslots = c->tunables.qmgr_nhash;
|
||||
qmgr_params.delta = c->tunables.qmgr_delta;
|
||||
|
||||
c->configmgr = makeInstance(&xkvmgr_type, &config_mgr_params);
|
||||
c->jobmgr = makeInstance(&xkvmgr_type, &jobmgr_params);
|
||||
c->resmgr = makeInstance(&xkvmgr_type, &resmgr_params);
|
||||
zarray_init(&(c->sharedinst), CTRL_PERF_INST,
|
||||
zarray_init(&(c->sharedinst), c->tunables.resmgr_inst,
|
||||
(zarray_item_killer_t)resval_obj_killer);
|
||||
c->workermgr = makeInstance(&xkvmgr_type, &workermgr_params);
|
||||
c->qmgr = makeInstance(&xkvmgr_type, &qmgr_params);
|
||||
|
|
@ -852,7 +876,7 @@ int cluster_init_phase2(cluster_t* c)
|
|||
iomgr_set_ssl_ctx(&(c->iomgr), ssl_ctx);
|
||||
}
|
||||
|
||||
xstring_table_init(CTRL_PERF_NHASH);
|
||||
xstring_table_init(c->tunables.xstrings_nhash);
|
||||
job_obj_init(5381, 5381);
|
||||
|
||||
zarray_init(&(c->endpoints), 16, endpoint_killer);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue