Skip to content
Snippets Groups Projects
Commit cb6589da authored by Danny Auble's avatar Danny Auble
Browse files

Handle timers differently to give us the delta_t without having to call

and extra function
parent 56781f49
No related branches found
No related tags found
No related merge requests found
...@@ -49,21 +49,20 @@ ...@@ -49,21 +49,20 @@
* IN len_tv_str - size of tv_str in bytes * IN len_tv_str - size of tv_str in bytes
* IN from - where the function was called form * IN from - where the function was called form
*/ */
extern void slurm_diff_tv_str(struct timeval *tv1,struct timeval *tv2, extern void slurm_diff_tv_str(struct timeval *tv1, struct timeval *tv2,
char *tv_str, int len_tv_str, char *from, char *tv_str, int len_tv_str, char *from,
long limit) long limit, long *delta_t)
{ {
char p[64] = ""; char p[64] = "";
struct tm tm; struct tm tm;
long delta_t;
delta_t = (tv2->tv_sec - tv1->tv_sec) * 1000000; (*delta_t) = (tv2->tv_sec - tv1->tv_sec) * 1000000;
delta_t += tv2->tv_usec - tv1->tv_usec; (*delta_t) += tv2->tv_usec - tv1->tv_usec;
snprintf(tv_str, len_tv_str, "usec=%ld", *delta_t);
if (from) { if (from) {
if (!limit) if (!limit)
limit = 1000000; limit = 1000000;
if (delta_t > limit) { if (*delta_t > limit) {
snprintf(tv_str, len_tv_str, "usec=%ld", delta_t);
if (!localtime_r(&tv2->tv_sec, &tm)) if (!localtime_r(&tv2->tv_sec, &tm))
fprintf(stderr, "localtime_r() failed\n"); fprintf(stderr, "localtime_r() failed\n");
if (strftime(p, sizeof(p), "%T", &tm) == 0) if (strftime(p, sizeof(p), "%T", &tm) == 0)
...@@ -74,17 +73,3 @@ extern void slurm_diff_tv_str(struct timeval *tv1,struct timeval *tv2, ...@@ -74,17 +73,3 @@ extern void slurm_diff_tv_str(struct timeval *tv1,struct timeval *tv2,
} }
} }
} }
/*
* slurm_diff_tv - return the difference between two times
* IN tv1 - start of event
* IN tv2 - end of event
* RET time in micro-seconds
*/
extern long slurm_diff_tv(struct timeval *tv1, struct timeval *tv2)
{
long delta_t;
delta_t = (tv2->tv_sec - tv1->tv_sec) * 1000000;
delta_t += tv2->tv_usec - tv1->tv_usec;
return delta_t;
}
...@@ -41,15 +41,15 @@ ...@@ -41,15 +41,15 @@
#include <sys/time.h> #include <sys/time.h>
#define DEF_TIMERS struct timeval tv1, tv2; char tv_str[20] = "" #define DEF_TIMERS struct timeval tv1, tv2; char tv_str[20] = ""; long delta_t;
#define START_TIMER gettimeofday(&tv1, NULL) #define START_TIMER gettimeofday(&tv1, NULL)
#define END_TIMER gettimeofday(&tv2, NULL); \ #define END_TIMER gettimeofday(&tv2, NULL); \
slurm_diff_tv_str(&tv1, &tv2, tv_str, 20, NULL, 0) slurm_diff_tv_str(&tv1, &tv2, tv_str, 20, NULL, 0, &delta_t)
#define END_TIMER2(from) gettimeofday(&tv2, NULL); \ #define END_TIMER2(from) gettimeofday(&tv2, NULL); \
slurm_diff_tv_str(&tv1, &tv2, tv_str, 20, from, 0) slurm_diff_tv_str(&tv1, &tv2, tv_str, 20, from, 0, &delta_t)
#define END_TIMER3(from, limit) gettimeofday(&tv2, NULL); \ #define END_TIMER3(from, limit) gettimeofday(&tv2, NULL); \
slurm_diff_tv_str(&tv1, &tv2, tv_str, 20, from, limit) slurm_diff_tv_str(&tv1, &tv2, tv_str, 20, from, limit, &delta_t)
#define DELTA_TIMER slurm_diff_tv(&tv1, &tv2) #define DELTA_TIMER delta_t
#define TIME_STR tv_str #define TIME_STR tv_str
/* /*
...@@ -61,17 +61,10 @@ ...@@ -61,17 +61,10 @@
* IN len_tv_str - size of tv_str in bytes * IN len_tv_str - size of tv_str in bytes
* IN from - Name to be printed on long diffs * IN from - Name to be printed on long diffs
* IN limit - limit to wait * IN limit - limit to wait
* OUT delta_t - raw time difference in usec
*/ */
extern void slurm_diff_tv_str(struct timeval *tv1,struct timeval *tv2, extern void slurm_diff_tv_str(struct timeval *tv1,struct timeval *tv2,
char *tv_str, int len_tv_str, char *from, char *tv_str, int len_tv_str, char *from,
long limit); long limit, long *delta_t);
/*
* slurm_diff_tv - return the difference between two times
* IN tv1 - start of event
* IN tv2 - end of event
* RET time in micro-seconds
*/
extern long slurm_diff_tv(struct timeval *tv1, struct timeval *tv2);
#endif #endif
...@@ -401,14 +401,13 @@ static bool _failed_partition(struct part_record *part_ptr, ...@@ -401,14 +401,13 @@ static bool _failed_partition(struct part_record *part_ptr,
return false; return false;
} }
static void do_diag_stats(struct timeval tv1, struct timeval tv2) static void _do_diag_stats(long delta_t)
{ {
if (slurm_diff_tv(&tv1,&tv2) > slurmctld_diag_stats.schedule_cycle_max) if (delta_t > slurmctld_diag_stats.schedule_cycle_max)
slurmctld_diag_stats.schedule_cycle_max = slurm_diff_tv(&tv1, slurmctld_diag_stats.schedule_cycle_max = delta_t;
&tv2);
slurmctld_diag_stats.schedule_cycle_sum += slurm_diff_tv(&tv1, &tv2); slurmctld_diag_stats.schedule_cycle_sum += delta_t;
slurmctld_diag_stats.schedule_cycle_last = slurm_diff_tv(&tv1, &tv2); slurmctld_diag_stats.schedule_cycle_last = delta_t;
slurmctld_diag_stats.schedule_cycle_counter++; slurmctld_diag_stats.schedule_cycle_counter++;
} }
...@@ -1080,7 +1079,7 @@ next_part: part_ptr = (struct part_record *) ...@@ -1080,7 +1079,7 @@ next_part: part_ptr = (struct part_record *)
unlock_slurmctld(job_write_lock); unlock_slurmctld(job_write_lock);
END_TIMER2("schedule"); END_TIMER2("schedule");
do_diag_stats(tv1, tv2); _do_diag_stats(DELTA_TIMER);
return job_cnt; return job_cnt;
} }
......
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