save works

This commit is contained in:
Rongsong Shen 2026-03-06 18:20:30 +08:00
parent 47fc32b02c
commit 43dc12a36c
19 changed files with 80 additions and 72 deletions

View file

@ -8,6 +8,7 @@ endif
apiserver_ext_deps = [
libxce_dep,
librtti_dep,
c_capnproto_dep,
ssl_dep,
tinylog_dep,

View file

@ -376,14 +376,6 @@ int cluster_build_resources(cluster_t* c)
if (res == NULL) {
return -errno;
}
if ((res->flags & XCE_RESF_GLOBAL) != 0) {
res->idx = c->n_shared_res;
c->n_shared_res++;
} else {
res->idx = c->n_host_res;
c->n_host_res++;
}
}
return 0;

View file

@ -4,6 +4,18 @@
#include <stdint.h>
#if defined(__has_c_attribute) && __has_c_attribute(gnu::constructor)
#define CONSTRUCTOR(prio) [[gnu::constructor(prio)]]
#define DESTRUCTOR(prio) [[gnu::destructor(prio)]]
#elif defined(__GNUC__) || defined(__clang__)
#define CONSTRUCTOR(prio) __attribute__((constructor(prio)))
#define DESTRUCTOR(prio) __attribute__((destructor(prio)))
#else
#define CONSTRUCTOR(prio)
#define DESTRUCTOR(prio)
#warning "No constructor support found"
#endif
typedef uint64_t jobid_t;
#define BUG_EMAIL "rshen@shenrs.eu"

View file

@ -102,8 +102,6 @@ typedef struct {
int myidx;
int master;
int ncontrollers;
int n_shared_res;
int n_host_res;
delaymgr_t delaymgr;
scheduler_t sched;
var jobmgr;

View file

@ -8,10 +8,10 @@
#include "jobj.h"
#include "kv.h"
#include "mylock.h"
#include "preason.h"
#include "utils.h"
#include "xce/types.h"
#include "xstring.h"
#include "preason.h"
static struct {
mylock_t lock;
@ -588,11 +588,11 @@ static void job_destroy(meta_obj_t* obj)
if (j->job.run_usage != NULL) {
int i;
for(i = 0; i < j->job.run_usage->num_hosts; i ++) {
for (i = 0; i < j->job.run_usage->num_hosts; i++) {
if (j->job.run_usage->host_runusage[i] != NULL) {
FREEUP(j->job.run_usage->host_runusage[i]->host_name);
}
FREEUP(j->job.run_usage->host_runusage[i]);
}

View file

@ -126,13 +126,15 @@ static xce_resource_t* makeResource_(var resmgr, xce_resource_t* r)
resobj = makeInstance(&resobj_type, r);
if (resobj != NULL) {
rc = key_add(resmgr, (void*)resobj->name, (void*)resobj);
if (rc < 0) {
destroy(resobj);
errno = -rc;
return NULL;
}
resobj->idx = rc;
}
return resobj;
}

View file

@ -75,6 +75,8 @@ int parse_section(xce_resreq_data_t* resreq, char* data, char** errmsg)
*errmsg = NULL;
ctx.input = data;
memset(resreq, 0x0, sizeof(*resreq));
p = xce_section_create(&ctx);
if (p == NULL) {
return -errno;

View file

@ -281,8 +281,6 @@ static void test_job_create(void)
&& (j2->job.submit->mintasks == 1) && (j2->job.submit->maxtasks == 5)
&& (j2->job.submit->user_group == NULL));
dereference(j2);
destroy(jobmgr);
job_obj_fini();

View file

@ -37,8 +37,6 @@ static void test_queue_create(void)
TEST_ASSERT_TRUE(q != NULL);
dereference(q);
destroy(qmgr);
xstring_table_fini();
}

View file

@ -52,7 +52,7 @@ void test_parse_section_fail(void)
"same[type] same[abcd] affinity[core(20)]";
char* errmsg = NULL;
int rc = 0;
xce_resreq_data_t data;
xce_resreq_data_t data = {0};
rc = parse_section(&data, (char*)resreq, &errmsg);
TEST_ASSERT_TRUE(rc < 0);

View file

@ -47,7 +47,6 @@ static void test_worker_create(void)
&& (w->host.attrs->cpufactor == attrs1.cpufactor)
&& (w->host.attrs->maxcpus == attrs1.maxcpus));
dereference(w);
destroy(workermgr);
xstring_table_fini();

View file

@ -305,10 +305,10 @@ int match_limit(xce_limit_t* limit, int global, ...)
int build_vres_name(char** vname, xce_limit_t* limit, char* user, char* queue,
char* project)
{
char resname[2 * XCE_MAXNAME_LEN + 1];
xce_consumer_t* c = NULL;
char* p = NULL;
int rc = 0;
size_t bufsize = 0;
FILE* fp = NULL;
xce_consumer_t* c = NULL;
int rc = 0;
*vname = NULL;
if ((vname == NULL) || (limit == NULL) || (user == NULL) || (queue == NULL)
@ -316,50 +316,33 @@ int build_vres_name(char** vname, xce_limit_t* limit, char* user, char* queue,
return -EINVAL;
}
memset(resname, 0x0, sizeof(resname));
p = &resname[0];
rc = sprintf(p, "limit=%s", limit->name);
if (rc < 0) {
return rc;
fp = open_memstream(vname, &bufsize);
if (fp == NULL) {
return -errno;
}
p += rc;
fprintf(fp, "limit=%s", limit->name);
c = limit->consumers[CONSUMER_USER];
if ((c != NULL) && (c->per_consumer == 1)) {
rc = sprintf(p, "/u=%s", user);
if (rc < 0) {
return rc;
}
p += rc;
fprintf(fp, "/u=%s", user);
}
c = limit->consumers[CONSUMER_QUEUE];
if ((c != NULL) && (c->per_consumer == 1)) {
rc = sprintf(p, "/q=%s", queue);
if (rc < 0) {
return rc;
}
p += rc;
fprintf(fp, "/q=%s", queue);
}
c = limit->consumers[CONSUMER_PROJECT];
if ((c != NULL) && (c->per_consumer == 1)) {
rc = sprintf(p, "/p=%s", project);
if (rc < 0) {
return rc;
}
p += rc;
fprintf(fp, "/p=%s", project);
}
*vname = strdup(resname);
fflush(fp);
fclose(fp);
if ((*vname) != NULL) {
return 1;
}

View file

@ -444,7 +444,10 @@ static int xzarray_ensure_items(xzarray_t* array, int mincap)
/* this will make we can get next free
* location quickly
*/
array->pos = array->caps;
if (array->data[array->pos].inuse) {
array->pos = array->caps;
}
array->caps = nc;
return 1;

View file

@ -11,14 +11,18 @@ if get_option('buildtype') == 'debug'
# add -DWITH_DEBUG=1
add_project_arguments(['-DWITH_DEBUG=1',
'-DDEBUG',
'-O0',
'-fno-lto',
'-Wno-cpp',
'-fno-inline',
'-fno-omit-frame-pointer',
'-ggdb',
'-gdwarf-4',
'-g3',
'-fvar-tracking',
'-fvar-tracking-assignments',
], language: ['c', 'cpp'])
add_project_link_arguments('-fno-lto', language: ['c', 'cpp'])
with_debug=true
endif

View file

@ -57,7 +57,13 @@ stdenv.mkDerivation {
separateDebugInfo = true;
}))
packcc
] ++ (if withDebug then [librtti_debug] else [librtti]);
] ++ (if withDebug then [
(librtti_debug.overrideAttrs (oldattrs: {
separateDebugInfo = true;
}))
] else [
librtti
]);
build-system = [ pkgs.meson ];

View file

@ -11,6 +11,7 @@
#include "utils.h"
#include "xcelimit.h"
#include "xlist.h"
#include "xstring.h"
typedef struct {
var limits;
@ -398,7 +399,7 @@ static int build_limit_vres_requests(xce_scheduler_t* sched,
continue;
}
rq->res = strdup(vres->vres->name);
rq->res = makeString(vres->vres->name);
rq->value = get_vres_value(ctx, vres);
xlist_store(requests, rq);

View file

@ -342,8 +342,8 @@ static int sched_update_res_accounts(xce_scheduler_t* sched, zarray_t* array,
for (i = 0; i < naccounts; i++) {
float val = accounts[i]->used + accounts[i]->reserved;
TRACE("%s resource %d old %f delta %f charge %d", __func__, vals[i],
val, charge);
TRACE("%s resource %d old %f delta %f charge %d", __func__, idxs[i],
vals[i], val, charge);
if (charge) {
vals[i] += val;
} else {

View file

@ -12,6 +12,7 @@
#include "xcealloc.h"
#include "xlist.h"
#include "xvec.h"
#include "xstring.h"
void kill_sched_job(void* arg)
{
@ -29,7 +30,7 @@ request_res_t* make_resource_request(char* res, float value)
return NULL;
}
req->res = strdup(res);
req->res = makeString(res);
req->value = value;
return req;
@ -111,9 +112,9 @@ static int make_sched_obj(xce_sched_obj_t* obj, xce_scheduler_t* sched,
{
int rc = 0;
obj->user = strdup(j->submit->user);
obj->queue = strdup(j->submit->queue);
obj->project = strdup(j->submit->project_name);
obj->user = makeString(j->submit->user);
obj->queue = makeString(j->submit->queue);
obj->project = makeString(j->submit->project_name);
xlist_init(&(obj->glimits), 8);
zarray_init(&(obj->hlimits), 32, NULL);
@ -218,7 +219,7 @@ xce_sched_queue_t* make_sched_queue(void* arg, xce_queue_t* q)
return NULL;
}
queue->name = strdup(q->queue);
queue->name = makeString(q->queue);
queue->attrs = q->attrs;
queue->status = q->status;
queue->priority = q->priority;
@ -259,7 +260,7 @@ xce_sched_worker_t* make_sched_worker(void* arg, xce_worker_t* w)
return NULL;
}
worker->name = strdup(w->name);
worker->name = makeString(w->name);
worker->status = w->status;
worker->idx = -1;
@ -288,7 +289,7 @@ void kill_sched_user(void* arg)
return;
}
FREEUP(user->name);
dereference(user->name);
FREEUP(user);
}
@ -302,7 +303,7 @@ xce_sched_user_t* make_sched_user(void* arg, char* name)
return NULL;
}
user->name = strdup(name);
user->name = makeString(name);
sched_add_user(sched, user);
@ -317,7 +318,7 @@ void kill_sched_project(void* arg)
return;
}
FREEUP(project->name);
dereference(project->name);
FREEUP(project);
}
@ -332,9 +333,9 @@ xce_sched_project_t* make_sched_project(void* arg, char* name)
}
if ((name == NULL) || (strlen(name) == 0)) {
project->name = strdup("default");
project->name = makeString("default");
} else {
project->name = strdup(name);
project->name = makeString(name);
}
sched_add_project(sched, project);

View file

@ -13,6 +13,7 @@
#include "misc.h"
#include "plugin.h"
#include "preason.h"
#include "resobj.h"
#include "scheduler.h"
#include "utils.h"
#include "xcealloc.h"
@ -465,11 +466,18 @@ static int sched_init_resources(xce_scheduler_t* sched)
xce_conf4sched_t* config = sched->config;
for (i = 0; i < config->n_resources; i++) {
xce_resource_t* r = config->resources[i];
xce_resource_t* r = config->resources[i];
xce_resource_t* r1 = NULL;
lock(sched->resmgr, RTTI_LOCK_WRITE);
key_add(sched->resmgr, (void*)r->name, (void*)r);
unlock(sched->resmgr);
if (r == NULL) {
continue;
}
r1 = makeResource(sched->resmgr, r);
if (r1 == NULL) {
ERROR("%s add resource %s failed", __func__, r->name);
}
}
return 0;
}