Skip to content

Commit

Permalink
pbuf - performance buffer added.
Browse files Browse the repository at this point in the history
  • Loading branch information
nezzzu committed May 26, 2020
1 parent 9ef268e commit 374c3e2
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 88 deletions.
88 changes: 19 additions & 69 deletions c0appz.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <sys/time.h>
#include <assert.h>
#include <time.h>
#include <unistd.h>
#include <errno.h>
#include <lib/semaphore.h>
Expand All @@ -44,9 +42,9 @@
#define DEBUG 0
#endif

#define MAXC0RC 4
#define SZC0RCSTR 256
#define SZC0RCFILE 256
#define MAXC0RC 4
#define SZC0RCSTR 256
#define SZC0RCFILE 256
#define C0RCFLE "./.cappzrc"

/* static variables */
Expand All @@ -58,8 +56,6 @@ static struct m0_idx_dix_config dix_conf;

static char c0rc[8][SZC0RCSTR];
static char c0rcfile[SZC0RCFILE] = C0RCFLE;
static struct timeval wclk_t = {0, 0};
static clock_t cput_t = 0;

struct clovis_aio_op;
struct clovis_aio_opgrp {
Expand Down Expand Up @@ -121,46 +117,6 @@ extern pthread_mutex_t qos_lock; /* lock qos_total_weight */
******************************************************************************
*/

/*
* c0appz_timeout()
* time out execution.
*/
int c0appz_timeout(uint64_t sz)
{
double ct; /* cpu time in seconds */
double wt; /* wall time in seconds */
double bw_ctime; /* bandwidth in MBs */
double bw_wtime; /* bandwidth in MBs */
struct timeval tv;

/* cpu time */
ct = (double)(clock() - cput_t) / CLOCKS_PER_SEC;
bw_ctime = (double)(sz) / 1000000.0 / ct;

/* wall time */
gettimeofday(&tv, 0);
wt = (double)(tv.tv_sec - wclk_t.tv_sec);
wt += (double)(tv.tv_usec - wclk_t.tv_usec)/1000000;
bw_wtime = (double)(sz) / 1000000.0 / wt;


fprintf(stderr,"[ cput: %10.4lf s %10.4lf MB/s ]", ct, bw_ctime);
fprintf(stderr,"[ wclk: %10.4lf s %10.4lf MB/s ]", wt, bw_wtime);
fprintf(stderr,"\n");
return 0;
}

/*
* c0appz_timein()
* time in execution.
*/
int c0appz_timein()
{
cput_t = clock();
gettimeofday(&wclk_t, 0);
return 0;
}

/*
* c0appz_cp()
* copy to an object.
Expand Down Expand Up @@ -268,17 +224,14 @@ int c0appz_cp(uint64_t idhi,uint64_t idlo,char *filename,uint64_t bsz,uint64_t c
fclose(fp);

if(perf){
if (rc == 0) {
time = (double) read_time / M0_TIME_ONE_SECOND;
fs_bw = last_index / 1000000.0 / time;
fprintf(stderr," i/o[ OSFS: %10.4lf s %10.4lf MB/s ]",
time, fs_bw);

time = (double) write_time / M0_TIME_ONE_SECOND;
clovis_bw = last_index / 1000000.0 / time;
fprintf(stderr,"[ MERO: %10.4lf s %10.4lf MB/s ]\n",
time, clovis_bw);
}
if (rc == 0) {
time = (double) read_time / M0_TIME_ONE_SECOND;
fs_bw = last_index / 1000000.0 / time;
ppf(" i/o[ OSFS: %10.4lf s %10.4lf MB/s ]",time, fs_bw);
time = (double) write_time / M0_TIME_ONE_SECOND;
clovis_bw = last_index / 1000000.0 / time;
ppf("[ MERO: %10.4lf s %10.4lf MB/s ]\n",time, clovis_bw);
}
}

return rc;
Expand Down Expand Up @@ -511,17 +464,14 @@ int c0appz_ct(uint64_t idhi,uint64_t idlo,char *filename,uint64_t bsz,uint64_t c
m0_time_sub(m0_time_now(), st));

if(perf){
if (rc == 0) {
time = (double) read_time / M0_TIME_ONE_SECOND;
clovis_bw = last_index / 1000000.0 / time;
fprintf(stderr," i/o[ MERO: %10.4lf s %10.4lf MB/s ]",
time, clovis_bw);

time = (double) write_time / M0_TIME_ONE_SECOND;
fs_bw = last_index / 1000000.0 / time;
fprintf(stderr,"[ OSFS: %10.4lf s %10.4lf MB/s ]\n",
time, fs_bw);
}
if (rc == 0) {
time = (double) read_time / M0_TIME_ONE_SECOND;
clovis_bw = last_index / 1000000.0 / time;
ppf(" i/o[ MERO: %10.4lf s %10.4lf MB/s ]",time, clovis_bw);
time = (double) write_time / M0_TIME_ONE_SECOND;
fs_bw = last_index / 1000000.0 / time;
ppf("[ OSFS: %10.4lf s %10.4lf MB/s ]\n",time, fs_bw);
}
}
return rc;
}
Expand Down
3 changes: 3 additions & 0 deletions c0appz.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ int c0appz_setrc(char *rcfile);
int c0appz_putrc(void);
int c0appz_timeout(uint64_t sz);
int c0appz_timein();
int c0appz_dump_perf(void);

int qos_pthread_start(void);
int qos_pthread_stop(int s);
Expand All @@ -55,6 +56,8 @@ int write_data_to_object(struct m0_uint128 id, struct m0_indexvec *ext,
int read_data_from_object(struct m0_uint128 id, struct m0_indexvec *ext,
struct m0_bufvec *data,struct m0_bufvec *attr);

int ppf(const char *fmt, ...);


/*
** ECMWF REQUIREMENTS
Expand Down
7 changes: 4 additions & 3 deletions c0cp.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ int main(int argc, char **argv)

/* time out/in */
if(perf){
fprintf(stderr,"%4s","init");
ppf("%4s","init");
c0appz_timeout(0);
c0appz_timein();
}
Expand Down Expand Up @@ -192,7 +192,7 @@ int main(int argc, char **argv)

/* time out/in */
if((perf)&&(!rc)){
fprintf(stderr,"%4s","i/o");
ppf("%4s","i/o");
c0appz_timeout((uint64_t)bsz * (uint64_t)cnt * (uint64_t)laps);
c0appz_timein();
}
Expand All @@ -202,7 +202,7 @@ int main(int argc, char **argv)

/* time out */
if((perf)&&(!rc)){
fprintf(stderr,"%4s","free");
ppf("%4s","free");
c0appz_timeout(0);
}

Expand All @@ -214,6 +214,7 @@ int main(int argc, char **argv)
}

/* success */
c0appz_dump_perf();
printf("%s %" PRIu64 "\n",fname,fs.st_size);
fprintf(stderr,"%s success\n",basename(argv[0]));
return 0;
Expand Down
15 changes: 8 additions & 7 deletions c0cp_async.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ int main(int argc, char **argv)
if(argc-optind!=5){
fprintf(stderr,"Usage:\n");
fprintf(stderr,"%s [options] idh idl filename bsz opcnt\n", basename(argv[0]));
return -11;
return 111;
}

/* time in */
Expand All @@ -105,7 +105,7 @@ int main(int argc, char **argv)
/* initialize resources */
if(c0appz_init(0)!=0){
fprintf(stderr,"error! clovis initialization failed.\n");
return -22;
return 222;
}

/* extend */
Expand All @@ -118,7 +118,7 @@ int main(int argc, char **argv)

/* time out/in */
if(perf){
fprintf(stderr,"%4s","init");
ppf("%4s","init");
c0appz_timeout(0);
c0appz_timein();
}
Expand All @@ -130,7 +130,7 @@ int main(int argc, char **argv)
stat64(fname,&fs);
assert(fsz==fs.st_size);
c0appz_free();
return -33;
return 333;
}

qos_pthread_start();
Expand All @@ -142,14 +142,14 @@ int main(int argc, char **argv)
stat64(fname,&fs);
assert(fsz==fs.st_size);
c0appz_free();
return -44;
return 444;
};

qos_pthread_stop(0);

/* time out/in */
if(perf){
fprintf(stderr,"%4s","i/o");
ppf("%4s","i/o");
c0appz_timeout((uint64_t)bsz * (uint64_t)cnt);
c0appz_timein();
}
Expand All @@ -164,11 +164,12 @@ int main(int argc, char **argv)

/* time out */
if(perf){
fprintf(stderr,"%4s","free");
ppf("%4s","free");
c0appz_timeout(0);
}

/* success */
c0appz_dump_perf();
printf("%s %" PRIu64 "\n",fname,fs.st_size);
fprintf(stderr,"%s success\n", basename(argv[0]));
return 0;
Expand Down
7 changes: 4 additions & 3 deletions c0ct.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ int main(int argc, char **argv)

/* time out/in */
if(perf){
fprintf(stderr,"%4s","init");
ppf("%4s","init");
c0appz_timeout(0);
c0appz_timein();
}
Expand Down Expand Up @@ -176,7 +176,7 @@ int main(int argc, char **argv)

/* time out/in */
if(perf){
fprintf(stderr,"%4s","i/o");
ppf("%4s","i/o");
c0appz_timeout((uint64_t)bsz * (uint64_t)cnt * (uint64_t)laps);
c0appz_timein();
}
Expand All @@ -186,7 +186,7 @@ int main(int argc, char **argv)

/* time out */
if(perf){
fprintf(stderr,"%4s","free");
ppf("%4s","free");
c0appz_timeout(0);
}

Expand All @@ -198,6 +198,7 @@ int main(int argc, char **argv)
}

/* success */
c0appz_dump_perf();
printf("%s %" PRIu64 "\n",fname,fsz);
fprintf(stderr,"%s success\n",basename(argv[0]));
return 0;
Expand Down
13 changes: 7 additions & 6 deletions c0rm.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ int main(int argc, char **argv)
if(argc-optind!=2){
fprintf(stderr,"Usage:\n");
fprintf(stderr,"%s [options] idh idl\n", basename(argv[0]));
return -1;
return 111;
}

/* time in */
Expand All @@ -82,12 +82,12 @@ int main(int argc, char **argv)
/* initialize resources */
if(c0appz_init(0) != 0){
fprintf(stderr,"error! clovis initialization failed.\n");
return -2;
return 222;
}

/* time out/in */
if(perf){
fprintf(stderr,"%4s","init");
ppf("%4s","init");
c0appz_timeout(0);
c0appz_timein();
}
Expand All @@ -96,12 +96,12 @@ int main(int argc, char **argv)
if(c0appz_rm(idh,idl) != 0){
fprintf(stderr,"error! delete object failed.\n");
c0appz_free();
return -3;
return 333;
};

/* time out/in */
if(perf){
fprintf(stderr,"%4s","i/o");
ppf("%4s","i/o");
c0appz_timeout(0);
c0appz_timein();
}
Expand All @@ -111,11 +111,12 @@ int main(int argc, char **argv)

/* time out */
if(perf){
fprintf(stderr,"%4s","free");
ppf("%4s","free");
c0appz_timeout(0);
}

/* success */
c0appz_dump_perf();
fprintf(stderr,"%s success\n",basename(argv[0]));
return 0;
}
Expand Down

0 comments on commit 374c3e2

Please sign in to comment.