Skip to content

Commit 8ce4939

Browse files
chu11mergify[bot]
authored andcommitted
job-list: struct job cleanup
Problem: As time has gone on, the fields in 'struct job' have become a bit disorganized. Solution: Re-arrange fields so all 'job data' fields are grouped together, caches of information in grouped together, and comments are clearer. As a side effective, anal retentively update job_create() and job_destroy() to init / cleanup fields in similar organized order.
1 parent 1b1f873 commit 8ce4939

File tree

2 files changed

+28
-29
lines changed

2 files changed

+28
-29
lines changed

src/modules/job-list/job_state.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,14 @@ static void job_destroy (void *data)
118118
{
119119
struct job *job = data;
120120
if (job) {
121-
json_decref (job->exception_context);
121+
free (job->ranks);
122+
free (job->nodelist);
122123
json_decref (job->annotations);
124+
grudgeset_destroy (job->dependencies);
123125
json_decref (job->jobspec_job);
124126
json_decref (job->jobspec_cmd);
125127
json_decref (job->R);
126-
grudgeset_destroy (job->dependencies);
127-
free (job->ranks);
128-
free (job->nodelist);
128+
json_decref (job->exception_context);
129129
zlist_destroy (&job->next_states);
130130
free (job);
131131
}
@@ -145,18 +145,17 @@ static struct job *job_create (struct list_ctx *ctx, flux_jobid_t id)
145145
return NULL;
146146
job->ctx = ctx;
147147
job->id = id;
148-
job->state = FLUX_JOB_STATE_NEW;
149148
job->userid = FLUX_USERID_UNKNOWN;
150-
job->ntasks = -1;
151-
job->nnodes = -1;
152149
job->urgency = -1;
153-
job->expiration = -1.0;
154-
job->wait_status = -1;
155150
/* pending jobs that are not yet assigned a priority shall be
156151
* listed after those who do, so we set the job priority to MIN */
157152
job->priority = FLUX_JOB_PRIORITY_MIN;
153+
job->state = FLUX_JOB_STATE_NEW;
154+
job->ntasks = -1;
155+
job->nnodes = -1;
156+
job->expiration = -1.0;
157+
job->wait_status = -1;
158158
job->result = FLUX_JOB_RESULT_FAILED;
159-
job->eventlog_seq = -1;
160159

161160
if (!(job->next_states = zlist_new ())) {
162161
errno = ENOMEM;
@@ -166,7 +165,7 @@ static struct job *job_create (struct list_ctx *ctx, flux_jobid_t id)
166165

167166
job->states_mask = FLUX_JOB_STATE_NEW;
168167
job->states_events_mask = FLUX_JOB_STATE_NEW;
169-
168+
job->eventlog_seq = -1;
170169
return job;
171170
}
172171

src/modules/job-list/job_state.h

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,17 @@ struct job_state_ctx {
5959
flux_future_t *events;
6060
};
6161

62+
/* timestamp of when we enter the state
63+
*
64+
* associated eventlog entries when restarting
65+
*
66+
* t_depend - "submit"
67+
* t_priority - "priority" (not saved, can be entered multiple times)
68+
* t_sched - "depend" (not saved, can be entered multiple times)
69+
* t_run - "alloc"
70+
* t_cleanup - "finish" or "exception" w/ severity == 0
71+
* t_inactive - "clean"
72+
*/
6273
struct job {
6374
struct list_ctx *ctx;
6475

@@ -67,6 +78,11 @@ struct job {
6778
int urgency;
6879
int64_t priority;
6980
double t_submit;
81+
// t_depend is identical to t_submit
82+
// double t_depend;
83+
double t_run;
84+
double t_cleanup;
85+
double t_inactive;
7086
flux_job_state_t state;
7187
const char *name;
7288
int ntasks;
@@ -77,19 +93,18 @@ struct job {
7793
int wait_status;
7894
bool success;
7995
bool exception_occurred;
80-
json_t *exception_context;
8196
int exception_severity;
8297
const char *exception_type;
8398
const char *exception_note;
8499
flux_job_result_t result;
85100
json_t *annotations;
86101
struct grudgeset *dependencies;
87-
int eventlog_seq; /* last event seq read */
88102

89103
/* cache of job information */
90104
json_t *jobspec_job;
91105
json_t *jobspec_cmd;
92106
json_t *R;
107+
json_t *exception_context;
93108

94109
/* Track which states we have seen and have completed transition
95110
* to. We do not immediately update to the new state and place
@@ -108,22 +123,7 @@ struct job {
108123
unsigned int states_events_mask;
109124
void *list_handle;
110125

111-
/* timestamp of when we enter the state
112-
*
113-
* associated eventlog entries when restarting
114-
*
115-
* depend - "submit"
116-
* priority - "priority" (not saved, can be entered multiple times)
117-
* sched - "depend" (not saved, can be entered multiple times)
118-
* run - "alloc"
119-
* cleanup - "finish" or "exception" w/ severity == 0
120-
* inactive - "clean"
121-
*/
122-
// t_depend is identical to t_submit above, use that
123-
// double t_depend;
124-
double t_run;
125-
double t_cleanup;
126-
double t_inactive;
126+
int eventlog_seq; /* last event seq read */
127127
};
128128

129129
struct job_state_ctx *job_state_create (struct list_ctx *ctx);

0 commit comments

Comments
 (0)