Skip to content

Commit c0ffdf4

Browse files
committed
Workbench API improved.
1 parent d9c74af commit c0ffdf4

File tree

2 files changed

+94
-49
lines changed

2 files changed

+94
-49
lines changed

src/md-workbench.c

+81-14
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,50 @@ It follows the hierarchical file system semantics in contrast to the md-workbenc
2626

2727
#define oprintf(...) do { fprintf(o.logfile, __VA_ARGS__); fflush(o.logfile); } while(0);
2828

29+
// successfull, errors
30+
typedef struct {
31+
int suc;
32+
int err;
33+
} op_stat_t;
34+
35+
// A runtime for an operation and when the operation was started
36+
typedef struct{
37+
float time_since_app_start;
38+
float runtime;
39+
} time_result_t;
40+
41+
42+
// statistics for running a single phase
43+
typedef struct{ // NOTE: if this type is changed, adjust end_phase() !!!
44+
double t; // maximum time
45+
double * t_all;
46+
47+
op_stat_t dset_create;
48+
op_stat_t dset_delete;
49+
50+
op_stat_t obj_create;
51+
op_stat_t obj_read;
52+
op_stat_t obj_stat;
53+
op_stat_t obj_delete;
54+
55+
// time measurements of individual runs, these are not returned for now by the API!
56+
uint64_t repeats;
57+
time_result_t * time_create;
58+
time_result_t * time_read;
59+
time_result_t * time_stat;
60+
time_result_t * time_delete;
61+
62+
time_statistics_t stats_create;
63+
time_statistics_t stats_read;
64+
time_statistics_t stats_stat;
65+
time_statistics_t stats_delete;
66+
67+
// the maximum time for any single operation
68+
double max_op_time;
69+
double phase_start_timer;
70+
int stonewall_iterations;
71+
} phase_stat_t;
72+
2973
struct benchmark_options{
3074
ior_aiori_t const * backend;
3175
void * backend_options;
@@ -38,7 +82,7 @@ struct benchmark_options{
3882
int precreate;
3983
int dset_count;
4084

41-
int result_position; // in the global structure
85+
mdworkbench_results_t * results; // the results
4286

4387
int offset;
4488
int iterations;
@@ -211,10 +255,13 @@ static void print_p_stat(char * buff, const char * name, phase_stat_t * p, doubl
211255
ioops_per_iter = 2;
212256
}
213257

258+
double rate;
259+
214260
switch(name[0]){
215261
case('b'):
262+
rate = p->obj_read.suc * ioops_per_iter / t;
216263
pos += sprintf(buff + pos, "rate:%.1f iops/s objects:%d rate:%.1f obj/s tp:%.1f MiB/s op-max:%.4es",
217-
p->obj_read.suc * ioops_per_iter / t, // write, stat, read, delete
264+
rate, // write, stat, read, delete
218265
p->obj_read.suc,
219266
p->obj_read.suc / t,
220267
tp,
@@ -225,8 +272,9 @@ static void print_p_stat(char * buff, const char * name, phase_stat_t * p, doubl
225272
}
226273
break;
227274
case('p'):
275+
rate = (p->dset_create.suc + p->obj_create.suc) / t;
228276
pos += sprintf(buff + pos, "rate:%.1f iops/s dsets: %d objects:%d rate:%.3f dset/s rate:%.1f obj/s tp:%.1f MiB/s op-max:%.4es",
229-
(p->dset_create.suc + p->obj_create.suc) / t,
277+
rate,
230278
p->dset_create.suc,
231279
p->obj_create.suc,
232280
p->dset_create.suc / t,
@@ -235,8 +283,9 @@ static void print_p_stat(char * buff, const char * name, phase_stat_t * p, doubl
235283
p->max_op_time);
236284
break;
237285
case('c'):
286+
rate = (p->obj_delete.suc + p->dset_delete.suc) / t;
238287
pos += sprintf(buff + pos, "rate:%.1f iops/s objects:%d dsets: %d rate:%.1f obj/s rate:%.3f dset/s op-max:%.4es",
239-
(p->obj_delete.suc + p->dset_delete.suc) / t,
288+
rate,
240289
p->obj_delete.suc,
241290
p->dset_delete.suc,
242291
p->obj_delete.suc / t,
@@ -248,6 +297,16 @@ static void print_p_stat(char * buff, const char * name, phase_stat_t * p, doubl
248297
break;
249298
}
250299

300+
if(print_global){
301+
mdworkbench_result_t * res = & o.results->result[o.results->count];
302+
res->errors = errs;
303+
o.results->errors += errs;
304+
res->rate = rate;
305+
res->max_op_time = p->max_op_time;
306+
res->runtime = t;
307+
res->iterations_done = p->repeats;
308+
}
309+
251310
if(! o.quiet_output || errs > 0){
252311
pos += sprintf(buff + pos, " (%d errs", errs);
253312
if(errs > 0){
@@ -341,7 +400,7 @@ static void compute_histogram(const char * name, time_result_t * times, time_sta
341400
stats->max = times[repeats - 1].runtime;
342401
}
343402

344-
static void end_phase(const char * name, phase_stat_t * p, phase_stat_t * result){
403+
static void end_phase(const char * name, phase_stat_t * p){
345404
int ret;
346405
char buff[MAX_PATHLEN];
347406

@@ -452,8 +511,13 @@ static void end_phase(const char * name, phase_stat_t * p, phase_stat_t * result
452511
}
453512

454513
// copy the result back for the API
455-
memcpy(& result[o.result_position], & g_stat, sizeof(g_stat));
456-
o.result_position++;
514+
mdworkbench_result_t * res = & o.results->result[o.results->count];
515+
memcpy(& res->stats_create, & g_stat.stats_create, sizeof(time_statistics_t));
516+
memcpy(& res->stats_read, & g_stat.stats_read, sizeof(time_statistics_t));
517+
memcpy(& res->stats_stat, & g_stat.stats_stat, sizeof(time_statistics_t));
518+
memcpy(& res->stats_delete, & g_stat.stats_delete, sizeof(time_statistics_t));
519+
520+
o.results->count++;
457521

458522
// allocate memory if necessary
459523
// ret = mem_preallocate(& limit_memory_P, o.limit_memory_between_phases, o.verbosity >= 3);
@@ -783,7 +847,7 @@ static void store_position(int position){
783847
fclose(f);
784848
}
785849

786-
phase_stat_t* md_workbench_run(int argc, char ** argv, MPI_Comm world_com, FILE * out_logfile){
850+
mdworkbench_results_t* md_workbench_run(int argc, char ** argv, MPI_Comm world_com, FILE * out_logfile){
787851
int ret;
788852
int printhelp = 0;
789853
char * limit_memory_P = NULL;
@@ -873,7 +937,10 @@ phase_stat_t* md_workbench_run(int argc, char ** argv, MPI_Comm world_com, FILE
873937
double bench_start;
874938
bench_start = GetTimeStamp();
875939
phase_stat_t phase_stats;
876-
phase_stat_t* all_phases_stats = malloc(sizeof(phase_stat_t) * (2 + o.iterations));
940+
size_t result_count = (2 + o.iterations) * (o.adaptive_waiting_mode ? 7 : 1);
941+
o.results = malloc(sizeof(mdworkbench_results_t) + sizeof(mdworkbench_result_t) * result_count);
942+
memset(o.results, 0, sizeof(mdworkbench_results_t) + sizeof(mdworkbench_result_t) * result_count);
943+
o.results->count = 0;
877944

878945
if(o.rank == 0 && o.print_detailed_stats && ! o.quiet_output){
879946
print_detailed_stat_header();
@@ -892,7 +959,7 @@ phase_stat_t* md_workbench_run(int argc, char ** argv, MPI_Comm world_com, FILE
892959
phase_stats.phase_start_timer = GetTimeStamp();
893960
run_precreate(& phase_stats, current_index);
894961
phase_stats.t = GetTimeStamp() - phase_stats.phase_start_timer;
895-
end_phase("precreate", & phase_stats, all_phases_stats);
962+
end_phase("precreate", & phase_stats);
896963
}
897964

898965
if (o.phase_benchmark){
@@ -905,7 +972,7 @@ phase_stat_t* md_workbench_run(int argc, char ** argv, MPI_Comm world_com, FILE
905972
MPI_Barrier(o.com);
906973
phase_stats.phase_start_timer = GetTimeStamp();
907974
run_benchmark(& phase_stats, & current_index);
908-
end_phase("benchmark", & phase_stats, all_phases_stats);
975+
end_phase("benchmark", & phase_stats);
909976

910977
if(o.adaptive_waiting_mode){
911978
o.relative_waiting_factor = 0.0625;
@@ -914,7 +981,7 @@ phase_stat_t* md_workbench_run(int argc, char ** argv, MPI_Comm world_com, FILE
914981
MPI_Barrier(o.com);
915982
phase_stats.phase_start_timer = GetTimeStamp();
916983
run_benchmark(& phase_stats, & current_index);
917-
end_phase("benchmark", & phase_stats, all_phases_stats);
984+
end_phase("benchmark", & phase_stats);
918985
o.relative_waiting_factor *= 2;
919986
}
920987
}
@@ -927,7 +994,7 @@ phase_stat_t* md_workbench_run(int argc, char ** argv, MPI_Comm world_com, FILE
927994
phase_stats.phase_start_timer = GetTimeStamp();
928995
run_cleanup(& phase_stats, current_index);
929996
phase_stats.t = GetTimeStamp() - phase_stats.phase_start_timer;
930-
end_phase("cleanup", & phase_stats, all_phases_stats);
997+
end_phase("cleanup", & phase_stats);
931998

932999
if (o.rank == 0){
9331000
if (o.backend->rmdir(o.prefix, o.backend_options) != 0) {
@@ -947,5 +1014,5 @@ phase_stat_t* md_workbench_run(int argc, char ** argv, MPI_Comm world_com, FILE
9471014
printTime();
9481015
}
9491016
//mem_free_preallocated(& limit_memory_P);
950-
return all_phases_stats;
1017+
return o.results;
9511018
}

src/md-workbench.h

+13-35
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,6 @@
55
#include <stdio.h>
66
#include <mpi.h>
77

8-
// successfull, errors
9-
typedef struct {
10-
int suc;
11-
int err;
12-
} op_stat_t;
13-
14-
// A runtime for an operation and when the operation was started
15-
typedef struct{
16-
float time_since_app_start;
17-
float runtime;
18-
} time_result_t;
19-
208
typedef struct{
219
float min;
2210
float q1;
@@ -27,38 +15,28 @@ typedef struct{
2715
float max;
2816
} time_statistics_t;
2917

18+
3019
// statistics for running a single phase
3120
typedef struct{ // NOTE: if this type is changed, adjust end_phase() !!!
32-
double t; // maximum time
33-
double * t_all;
34-
35-
op_stat_t dset_create;
36-
op_stat_t dset_delete;
37-
38-
op_stat_t obj_create;
39-
op_stat_t obj_read;
40-
op_stat_t obj_stat;
41-
op_stat_t obj_delete;
42-
43-
// time measurements of individual runs, these are not returned for now by the API!
44-
uint64_t repeats;
45-
time_result_t * time_create;
46-
time_result_t * time_read;
47-
time_result_t * time_stat;
48-
time_result_t * time_delete;
49-
5021
time_statistics_t stats_create;
5122
time_statistics_t stats_read;
5223
time_statistics_t stats_stat;
5324
time_statistics_t stats_delete;
5425

55-
// the maximum time for any single operation
26+
int errors;
27+
double rate;
5628
double max_op_time;
57-
double phase_start_timer;
58-
int stonewall_iterations;
59-
} phase_stat_t;
29+
double runtime;
30+
uint64_t iterations_done;
31+
} mdworkbench_result_t;
32+
33+
typedef struct{
34+
int count; // the number of results
35+
int errors;
36+
mdworkbench_result_t result[];
37+
} mdworkbench_results_t;
6038

6139
// @Return The first statistics returned are precreate, then iteration many benchmark runs, the last is cleanup
62-
phase_stat_t* md_workbench_run(int argc, char ** argv, MPI_Comm world_com, FILE * out_logfile);
40+
mdworkbench_results_t* md_workbench_run(int argc, char ** argv, MPI_Comm world_com, FILE * out_logfile);
6341

6442
#endif

0 commit comments

Comments
 (0)