Skip to content
Snippets Groups Projects
Commit e28df1a1 authored by Moe Jette's avatar Moe Jette
Browse files

Node hash function was using defunct HASH_BASE, resulting in very slow

performance. Now uses variable loaded from config file (or default).
parent 39d30a0d
No related branches found
No related tags found
No related merge requests found
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
log_options_t log_opts = LOG_OPTS_STDERR_ONLY ; log_options_t log_opts = LOG_OPTS_STDERR_ONLY ;
slurm_ctl_conf_t slurmctld_conf; slurm_ctl_conf_t slurmctld_conf;
int getnodename (char *name, size_t len);
int msg_from_root (void); int msg_from_root (void);
void slurmctld_req ( slurm_msg_t * msg ); void slurmctld_req ( slurm_msg_t * msg );
void fill_ctld_conf ( slurm_ctl_conf_t * build_ptr ); void fill_ctld_conf ( slurm_ctl_conf_t * build_ptr );
...@@ -88,8 +89,8 @@ main (int argc, char *argv[]) ...@@ -88,8 +89,8 @@ main (int argc, char *argv[])
fatal ("slurmctld: init_slurm_conf error %d", error_code); fatal ("slurmctld: init_slurm_conf error %d", error_code);
if ( ( error_code = read_slurm_conf ()) ) if ( ( error_code = read_slurm_conf ()) )
fatal ("slurmctld: error %d from read_slurm_conf reading %s", error_code, SLURM_CONFIG_FILE); fatal ("slurmctld: error %d from read_slurm_conf reading %s", error_code, SLURM_CONFIG_FILE);
if ( ( error_code = gethostname (node_name, MAX_NAME_LEN) ) ) if ( ( error_code = getnodename (node_name, MAX_NAME_LEN) ) )
fatal ("slurmctld: errno %d from gethostname", errno); fatal ("slurmctld: errno %d from getnodename", errno);
if ( strcmp (node_name, slurmctld_conf.control_machine) && if ( strcmp (node_name, slurmctld_conf.control_machine) &&
strcmp (node_name, slurmctld_conf.backup_controller) && strcmp (node_name, slurmctld_conf.backup_controller) &&
...@@ -889,3 +890,29 @@ usage (char *prog_name) ...@@ -889,3 +890,29 @@ usage (char *prog_name)
printf (" -s <errlev> Set syslog logging to the specified level\n"); printf (" -s <errlev> Set syslog logging to the specified level\n");
printf ("<errlev> is an integer between 0 and 7 with higher numbers providing more detail.\n"); printf ("<errlev> is an integer between 0 and 7 with higher numbers providing more detail.\n");
} }
/* getnodename - equivalent to gethostname, but return only the first component of the fully
* qualified name (e.g. "linux123.foo.bar" becomes "linux123") */
int
getnodename (char *name, size_t len)
{
int error_code, name_len;
char *dot_ptr, path_name[1024];
error_code = gethostname (path_name, sizeof(path_name));
if (error_code)
return error_code;
dot_ptr = strchr (path_name, '.');
if (dot_ptr == NULL)
dot_ptr = path_name + strlen(path_name);
else
dot_ptr[0] = '\0';
name_len = (dot_ptr - path_name);
if (name_len > len)
return ENAMETOOLONG;
strcpy (name, path_name);
return 0;
}
...@@ -553,45 +553,48 @@ hash_index (char *name) ...@@ -553,45 +553,48 @@ hash_index (char *name)
return 0; /* degenerate case */ return 0; /* degenerate case */
inx = 0; inx = 0;
#if ( HASH_BASE == 10 ) if ( slurmctld_conf.hash_base == 10 ) {
for (i = 0;; i++) { for (i = 0;; i++) {
tmp = (int) name[i]; tmp = (int) name[i];
if (tmp == 0) if (tmp == 0)
break; /* end if string */ break; /* end if string */
if ((tmp >= (int) '0') && (tmp <= (int) '9')) if ((tmp >= (int) '0') && (tmp <= (int) '9'))
inx = (inx * HASH_BASE) + (tmp - (int) '0'); inx = (inx * slurmctld_conf.hash_base) + (tmp - (int) '0');
} }
#elif ( HASH_BASE == 8 )
for (i = 0;; i++) {
tmp = (int) name[i];
if (tmp == 0)
break; /* end if string */
if ((tmp >= (int) '0') && (tmp <= (int) '7'))
inx = (inx * HASH_BASE) + (tmp - (int) '0');
} }
#else else if ( slurmctld_conf.hash_base == 8 ) {
for (i = 0; i < 5; i++) { for (i = 0;; i++) {
tmp = (int) name[i]; tmp = (int) name[i];
if (tmp == 0) if (tmp == 0)
break; /* end if string */ break; /* end if string */
if ((tmp >= (int) '0') && (tmp <= (int) '9')) { /* value 0-9 */ if ((tmp >= (int) '0') && (tmp <= (int) '7'))
tmp -= (int) '0'; inx = (inx * slurmctld_conf.hash_base) + (tmp - (int) '0');
} }
else if ((tmp >= (int) 'a') && (tmp <= (int) 'z')) { /* value 10-35 */ }
tmp -= (int) 'a';
tmp += 10; else {
} for (i = 0; i < 5; i++) {
else if ((tmp >= (int) 'a') && (tmp <= (int) 'z')) { /* value 10-35 */ tmp = (int) name[i];
tmp -= (int) 'a'; if (tmp == 0)
tmp += 10; break; /* end if string */
} if ((tmp >= (int) '0') && (tmp <= (int) '9')) { /* value 0-9 */
else { tmp -= (int) '0';
tmp = 36; }
else if ((tmp >= (int) 'a') && (tmp <= (int) 'z')) { /* value 10-35 */
tmp -= (int) 'a';
tmp += 10;
}
else if ((tmp >= (int) 'a') && (tmp <= (int) 'z')) { /* value 10-35 */
tmp -= (int) 'a';
tmp += 10;
}
else {
tmp = 36;
}
inx = (inx * 37) + tmp;
} }
inx = (inx * 37) + tmp;
} }
#endif
inx = inx % node_record_count; inx = inx % node_record_count;
return inx; return inx;
......
/* /*****************************************************************************\
* read_config.c - read the overall slurm configuration file * read_config.c - read the overall slurm configuration file
* see slurm.h for documentation on external functions and data structures *****************************************************************************
* * Copyright (C) 2002 The Regents of the University of California.
* author: moe jette, jette@llnl.gov * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
*/ * Written by moe jette <jette1@llnl.gov>.
* UCRL-CODE-2002-040.
*
* This file is part of SLURM, a resource management program.
* For details, see <http://www.llnl.gov/linux/slurm/>.
*
* SLURM is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along
* with SLURM; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
\*****************************************************************************/
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include <config.h> # include <config.h>
...@@ -24,6 +43,7 @@ ...@@ -24,6 +43,7 @@
#define BUF_SIZE 1024 #define BUF_SIZE 1024
int parse_config_spec (char *in_line);
int parse_node_spec (char *in_line); int parse_node_spec (char *in_line);
int parse_part_spec (char *in_line); int parse_part_spec (char *in_line);
...@@ -164,7 +184,7 @@ main (int argc, char *argv[]) { ...@@ -164,7 +184,7 @@ main (int argc, char *argv[]) {
/* /*
* report_leftover - report any un-parsed (non-whitespace) characters on the * report_leftover - report any un-parsed (non-whitespace) characters on the
* configuration input line. * configuration input line (we over-write parsed characters with whitespace).
* input: in_line - what is left of the configuration input line. * input: in_line - what is left of the configuration input line.
* line_num - line number of the configuration file. * line_num - line number of the configuration file.
* output: none * output: none
...@@ -245,7 +265,7 @@ build_bitmaps () { ...@@ -245,7 +265,7 @@ build_bitmaps () {
/* scan all nodes and identify which are up and idle and their configuration */ /* scan all nodes and identify which are up and idle and their configuration */
for (i = 0; i < node_record_count; i++) { for (i = 0; i < node_record_count; i++) {
if (strlen (node_record_table_ptr[i].name) == 0) if (node_record_table_ptr[i].name[0] == '\0')
continue; /* defunct */ continue; /* defunct */
if (node_record_table_ptr[i].node_state == NODE_STATE_IDLE) if (node_record_table_ptr[i].node_state == NODE_STATE_IDLE)
bit_set (idle_node_bitmap, i); bit_set (idle_node_bitmap, i);
...@@ -274,7 +294,7 @@ build_bitmaps () { ...@@ -274,7 +294,7 @@ build_bitmaps () {
/* check for each node in the partition */ /* check for each node in the partition */
if ((part_record_point->nodes == NULL) || if ((part_record_point->nodes == NULL) ||
(strlen (part_record_point->nodes) == 0)) (part_record_point->nodes[0] == '\0'))
continue; continue;
if ( (host_list = hostlist_create (part_record_point->nodes)) == NULL) { if ( (host_list = hostlist_create (part_record_point->nodes)) == NULL) {
...@@ -333,6 +353,131 @@ init_slurm_conf () { ...@@ -333,6 +353,131 @@ init_slurm_conf () {
} }
/*
* parse_config_spec - parse the overall configuration specifications, build table and set values
* output: 0 if no error, error code otherwise
*/
int
parse_config_spec (char *in_line)
{
int error_code;
int fast_schedule = 0, hash_base = 0, heartbeat_interval = 0, kill_wait = 0;
int slurmctld_timeout = 0, slurmd_timeout = 0;
char *backup_controller = NULL, *control_machine = NULL, *epilog = NULL;
char *prioritize = NULL, *prolog = NULL, *state_save_location = NULL, *tmp_fs = NULL;
char *slurmctld_port = NULL, *slurmd_port = NULL;
long first_job_id = 0;
struct servent *servent;
error_code = slurm_parser(in_line,
"BackupController=", 's', &backup_controller,
"ControlMachine=", 's', &control_machine,
"Epilog=", 's', &epilog,
"FastSchedule=", 'd', &fast_schedule,
"FirstJobId=", 'l', &first_job_id,
"HashBase=", 'd', &hash_base,
"HeartbeatInterval=", 'd', &heartbeat_interval,
"KillWait=", 'd', &kill_wait,
"Prioritize=", 's', &prioritize,
"Prolog=", 's', &prolog,
"SlurmctldPort=", 's', &slurmctld_port,
"SlurmctldTimeout=", 'd', &slurmctld_timeout,
"SlurmdPort=", 's', &slurmd_port,
"SlurmdTimeout=", 'd', &slurmd_timeout,
"StateSaveLocation=", 's', &state_save_location,
"TmpFS=", 's', &tmp_fs,
"END");
if (error_code)
return error_code;
if ( backup_controller ) {
if ( slurmctld_conf.backup_controller )
xfree (slurmctld_conf.backup_controller);
slurmctld_conf.backup_controller = backup_controller;
}
if ( control_machine ) {
if ( slurmctld_conf.control_machine )
xfree (slurmctld_conf.control_machine);
slurmctld_conf.control_machine = control_machine;
}
if ( epilog ) {
if ( slurmctld_conf.epilog )
xfree (slurmctld_conf.epilog);
slurmctld_conf.epilog = epilog;
}
if ( fast_schedule ) {
slurmctld_conf.fast_schedule = fast_schedule;
}
if ( first_job_id ) {
slurmctld_conf.first_job_id = first_job_id;
}
if ( hash_base ) {
slurmctld_conf.hash_base = hash_base;
}
if ( kill_wait ) {
slurmctld_conf.kill_wait = kill_wait;
}
if ( prioritize ) {
if ( slurmctld_conf.prioritize )
xfree (slurmctld_conf.prioritize);
slurmctld_conf.prioritize = prioritize;
}
if ( prolog ) {
if ( slurmctld_conf.prolog )
xfree (slurmctld_conf.prolog);
slurmctld_conf.prolog = prolog;
}
if ( slurmctld_port ) {
servent = getservbyname (slurmctld_port, NULL);
if (servent)
slurmctld_conf.slurmctld_port = servent -> s_port;
else
slurmctld_conf.slurmctld_port = strtol (slurmctld_port, (char **) NULL, 10);
endservent ();
}
if ( slurmctld_timeout ) {
slurmctld_conf.slurmctld_timeout = slurmctld_timeout;
}
if ( slurmd_port ) {
servent = getservbyname (slurmd_port, NULL);
if (servent)
slurmctld_conf.slurmd_port = servent -> s_port;
else
slurmctld_conf.slurmd_port = strtol (slurmd_port, (char **) NULL, 10);
endservent ();
}
if ( slurmd_timeout ) {
slurmctld_conf.slurmd_timeout = slurmd_timeout;
}
if ( state_save_location ) {
if ( slurmctld_conf.state_save_location )
xfree (slurmctld_conf.state_save_location);
slurmctld_conf.state_save_location = state_save_location;
}
if ( tmp_fs ) {
if ( slurmctld_conf.tmp_fs )
xfree (slurmctld_conf.tmp_fs);
slurmctld_conf.tmp_fs = tmp_fs;
}
return 0;
}
/* /*
* parse_node_spec - parse the node specification (per the configuration file format), * parse_node_spec - parse the node specification (per the configuration file format),
* build table and set values * build table and set values
...@@ -674,14 +819,6 @@ read_slurm_conf ( ) { ...@@ -674,14 +819,6 @@ read_slurm_conf ( ) {
int line_num; /* line number in input file */ int line_num; /* line number in input file */
char in_line[BUF_SIZE]; /* input line */ char in_line[BUF_SIZE]; /* input line */
int i, j, error_code; int i, j, error_code;
char *backup_controller = NULL, *control_machine = NULL, *epilog = NULL;
char *prioritize = NULL, *prolog = NULL, *state_save_location = NULL, *tmp_fs = NULL;
char *slurmctld_port = NULL, *slurmd_port = NULL;
int fast_schedule = 0, hash_base = 0, heartbeat_interval = 0, kill_wait = 0;
int slurmctld_timeout = 0;
int slurmd_timeout = 0;
long first_job_id = 0;
struct servent *servent;
/* initialization */ /* initialization */
start_time = clock (); start_time = clock ();
...@@ -695,7 +832,6 @@ read_slurm_conf ( ) { ...@@ -695,7 +832,6 @@ read_slurm_conf ( ) {
/* process the data file */ /* process the data file */
line_num = 0; line_num = 0;
while (fgets (in_line, BUF_SIZE, slurm_spec_file) != NULL) { while (fgets (in_line, BUF_SIZE, slurm_spec_file) != NULL) {
line_num++; line_num++;
if (strlen (in_line) >= (BUF_SIZE - 1)) { if (strlen (in_line) >= (BUF_SIZE - 1)) {
error ("read_slurm_conf line %d, of input file %s too long\n", error ("read_slurm_conf line %d, of input file %s too long\n",
...@@ -723,111 +859,11 @@ read_slurm_conf ( ) { ...@@ -723,111 +859,11 @@ read_slurm_conf ( ) {
} }
/* parse what is left */ /* parse what is left */
/* overall slurm configuration parameters */
error_code = slurm_parser(in_line, /* overall configuration parameters */
"BackupController=", 's', &backup_controller, if ((error_code = parse_config_spec (in_line))) {
"ControlMachine=", 's', &control_machine,
"Epilog=", 's', &epilog,
"FastSchedule=", 'd', &fast_schedule,
"FirstJobId=", 'l', &first_job_id,
"HashBase=", 'd', &hash_base,
"HeartbeatInterval=", 'd', &heartbeat_interval,
"KillWait=", 'd', &kill_wait,
"Prioritize=", 's', &prioritize,
"Prolog=", 's', &prolog,
"SlurmctldPort=", 's', &slurmctld_port,
"SlurmctldTimeout=", 'd', &slurmctld_timeout,
"SlurmdPort=", 's', &slurmd_port,
"SlurmdTimeout=", 'd', &slurmd_timeout,
"StateSaveLocation=", 's', &state_save_location,
"TmpFS=", 's', &tmp_fs,
"END");
if (error_code) {
fclose (slurm_spec_file); fclose (slurm_spec_file);
return error_code; return error_code;
}
if ( backup_controller ) {
if ( slurmctld_conf.backup_controller )
xfree (slurmctld_conf.backup_controller);
slurmctld_conf.backup_controller = backup_controller;
backup_controller = NULL;
}
if ( control_machine ) {
if ( slurmctld_conf.control_machine )
xfree (slurmctld_conf.control_machine);
slurmctld_conf.control_machine = control_machine;
control_machine = NULL;
}
if ( epilog ) {
if ( slurmctld_conf.epilog )
xfree (slurmctld_conf.epilog);
slurmctld_conf.epilog = epilog;
epilog = NULL;
}
if ( fast_schedule ) {
slurmctld_conf.fast_schedule = fast_schedule;
fast_schedule = 0;
}
if ( first_job_id ) {
slurmctld_conf.first_job_id = first_job_id;
first_job_id = 0;
}
if ( hash_base ) {
slurmctld_conf.hash_base = hash_base;
hash_base = 0;
}
if ( kill_wait ) {
slurmctld_conf.kill_wait = kill_wait;
kill_wait = 0;
}
if ( prioritize ) {
if ( slurmctld_conf.prioritize )
xfree (slurmctld_conf.prioritize);
slurmctld_conf.prioritize = prioritize;
prioritize = NULL;
}
if ( prolog ) {
if ( slurmctld_conf.prolog )
xfree (slurmctld_conf.prolog);
slurmctld_conf.prolog = prolog;
prolog = NULL;
}
if ( slurmctld_port ) {
servent = getservbyname (slurmctld_port, NULL);
if (servent)
slurmctld_conf.slurmctld_port = servent -> s_port;
else
slurmctld_conf.slurmctld_port = strtol (slurmctld_port, (char **) NULL, 10);
endservent ();
}
if ( slurmctld_timeout ) {
slurmctld_conf.slurmctld_timeout = slurmctld_timeout;
slurmctld_timeout = 0;
}
if ( slurmd_port ) {
servent = getservbyname (slurmd_port, NULL);
if (servent)
slurmctld_conf.slurmd_port = servent -> s_port;
else
slurmctld_conf.slurmd_port = strtol (slurmd_port, (char **) NULL, 10);
endservent ();
}
if ( slurmd_timeout ) {
slurmctld_conf.slurmd_timeout = slurmd_timeout;
slurmd_timeout = 0;
}
if ( state_save_location ) {
if ( slurmctld_conf.state_save_location )
xfree (slurmctld_conf.state_save_location);
slurmctld_conf.state_save_location = state_save_location;
state_save_location = NULL;
}
if ( tmp_fs ) {
if ( slurmctld_conf.tmp_fs )
xfree (slurmctld_conf.tmp_fs);
slurmctld_conf.tmp_fs = tmp_fs;
tmp_fs = NULL;
} }
/* node configuration parameters */ /* node configuration parameters */
...@@ -869,7 +905,5 @@ read_slurm_conf ( ) { ...@@ -869,7 +905,5 @@ read_slurm_conf ( ) {
info ("read_slurm_conf: finished loading configuration, time =%ld", info ("read_slurm_conf: finished loading configuration, time =%ld",
(long) (clock () - start_time)); (long) (clock () - start_time));
return SLURM_SUCCESS return SLURM_SUCCESS;
;
} }
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
extern slurm_ctl_conf_t slurmctld_conf; extern slurm_ctl_conf_t slurmctld_conf;
#define MAX_NAME_LEN 32
#define CONFIG_MAGIC 0xc065eded #define CONFIG_MAGIC 0xc065eded
#define NODE_MAGIC 0x0de575ed #define NODE_MAGIC 0x0de575ed
struct config_record { struct config_record {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment