feat(controller): compute the LSF CPU peak and efficiency fields (bug-1736)

update_job_cpu_stats() (misc.c), run after each usage report:
- each host's cpu_rate = CPU-seconds gained / wall seconds since its
  previous report; the job's cores = the sum over hosts
- peak_cpu = highest job cores seen (peak_cpu_time = it rounded, the
  wire field is an integer); peak_cpu_duration = the interval that set it
- avg_cpu_efficiency = cpu_time / elapsed / slots, peak_cpu_efficiency =
  peak_cpu / slots, mem_efficiency = highest used_mem / rusage[mem]
  request (job-wide total, per task by default), all in percent
aggregate_job_runusage() no longer treats cumulative cpu_time as a peak.

New fields host sample_time/cpu_rate and job peak_cpu are appended to
the capnp structs (old WAL entries still decode) and copied by
merge_job_runusage(), so a promoted standby keeps the rate baselines.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Rongsong Shen 2026-10-02 04:14:35 +00:00
parent 77b5102b3e
commit 6df644e6d5
Signed by untrusted user: rshen
GPG key ID: 80533536B0EB651C
8 changed files with 325 additions and 50 deletions

View file

@ -451,6 +451,10 @@ typedef struct {
double mem_usage;
double mem_swap;
int tasks_current;
/* bug-1736: this host's last report (epoch seconds) and its CPU rate
* over the interval that report closed (cores busy) */
int64_t sample_time;
float cpu_rate;
} xce_host_runusage_t;
typedef struct {
@ -465,6 +469,7 @@ typedef struct {
float peak_cpu_efficiency;
int num_hosts;
xce_host_runusage_t** host_runusage;
float peak_cpu; /* bug-1736: peak cores, unrounded */
} xce_job_runusage_t;
typedef struct {