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:
Rongsong Shen 2026-05-30 01:14:40 +00:00
parent 5f1af48d57
commit c42e1e0cb4
2 changed files with 54 additions and 14 deletions

View file

@ -124,6 +124,22 @@ typedef struct cluster_s {
pthread_t heartbeat_listener_tid; /* pre-Phase-2 SSL listener thread */
_Atomic int heartbeat_listener_running;
_Atomic int lost_and_found_job_count; /* incremented during persist_recover() */
/* Performance-tuning parameters — initialized by init_controller_tunables()
* in cluster_init_phase1 so they are available before cluster_init_phase2.
* TODO: wire to cluster_config once config generation tool supports @13-@17. */
struct {
int jobmgr_nhash; /* hash slots for job table */
int jobmgr_delta; /* growth step for job table */
int workermgr_nhash; /* hash slots for worker table */
int workermgr_delta; /* growth step for worker table */
int qmgr_nhash; /* hash slots for queue table */
int qmgr_delta; /* growth step for queue table */
int resmgr_nhash; /* hash slots for resource table */
int resmgr_delta; /* growth step for resource table */
int resmgr_inst; /* growth step for shared-instance array */
int xstrings_nhash; /* hash slots for xstring table */
} tunables;
} cluster_t;
#endif /* XCE_CLUSTER_DEF_H */