Skip to content

Commit

Permalink
c0cp: fix default unit size setting
Browse files Browse the repository at this point in the history
Currently, the default unit size is set to 1MB which means
that all writes with buffer sizes less than 1MB * units in
parity group will do RMWs (read-modify-writes) and the
resulting performance will be degraded.

Solution: 1) set default unit size to 4K. 2) Add -u option
to allow user to specify the optimal unit size.

Change the format of block size from bytes to KiBs also
to align with the format of unit size and for convenience.
  • Loading branch information
andriytk committed Jul 16, 2020
1 parent 3ba9dfc commit 2eeac88
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 79 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,19 @@ SRC = perf.c buffer.c qos.c c0appz.c pool.c
all: $(EXE1) $(EXE2) $(EXE3) $(EXE5) $(ISC_REG)
.PHONY: all

$(EXE1):
$(EXE1): $(SRC) c0cp.c help_c0cp.txt
xxd -i help_c0cp.txt > help.h
gcc $(SRC) c0cp.c -I/usr/include/mero $(CFLAGS) $(LFLAGS) -o $(EXE1)

$(EXE2):
$(EXE2): $(SRC) c0ct.c help_c0ct.txt
xxd -i help_c0ct.txt > help.h
gcc $(SRC) c0ct.c -I/usr/include/mero $(CFLAGS) $(LFLAGS) -o $(EXE2)

$(EXE3):
$(EXE3): $(SRC) c0rm.c help_c0rm.txt
xxd -i help_c0rm.txt > help.h
gcc $(SRC) c0rm.c -I/usr/include/mero $(CFLAGS) $(LFLAGS) -o $(EXE3)

$(EXE5):
$(EXE5): $(SRC) c0cp_async.c
gcc $(SRC) c0cp_async.c -I/usr/include/mero $(CFLAGS) $(LFLAGS) -o $(EXE5)

test: $(EXE1) $(EXE2) $(EXE3) $(EXE5)
Expand Down
14 changes: 11 additions & 3 deletions c0appz.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ static void clovis_aio_failed_cb(struct m0_clovis_op *op);
* GLOBAL VARIABLES
******************************************************************************
*/
unsigned unit_size = 4;
int perf=0; /* performance option */
extern int qos_total_weight; /* total bytes read or written */
extern pthread_mutex_t qos_lock; /* lock qos_total_weight */
Expand Down Expand Up @@ -448,7 +449,7 @@ int c0appz_ct(uint64_t idhi,uint64_t idlo,char *filename,uint64_t bsz,uint64_t c
read_time = m0_time_add(read_time,
m0_time_sub(m0_time_now(), st));
if (rc != 0) {
fprintf(stderr, "writing to object failed!\n");
fprintf(stderr, "reading from object failed!\n");
goto free_vecs;
}

Expand Down Expand Up @@ -790,10 +791,11 @@ int c0appz_init(int idx)
{
int i;
int rc;
int lid;
FILE *fp;
char *str = NULL;
char buf[SZC0RCSTR];
char* filename = C0RCFLE;
char buf[SZC0RCSTR];

/* read c0rc file */
filename = c0rcfile;
Expand Down Expand Up @@ -858,7 +860,13 @@ int c0appz_init(int idx)
/* set to Sage cluster specific values */
clovis_conf.cc_tm_recv_queue_min_len = 64;
clovis_conf.cc_max_rpc_msg_size = 65536;
clovis_conf.cc_layout_id = 9;
lid = m0_clovis_obj_unit_size_to_layout_id(unit_size * 1024);
if (lid == 0) {
fprintf(stderr, "invalid unit size %u, it should be: "
"power of 2, >= 4 and <= 4096\n", unit_size);
return -EINVAL;
}
clovis_conf.cc_layout_id = lid;

/* IDX_MERO */
clovis_conf.cc_idx_service_id = M0_CLOVIS_IDX_DIX;
Expand Down
2 changes: 2 additions & 0 deletions c0appz.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#include "clovis/clovis.h"
#include "lib/types.h" /* uint32_t */

extern unsigned unit_size; /* in KiBs, default 4 */

int c0appz_init(int idx);
int c0appz_free(void);
int c0appz_cr(uint64_t idhi,uint64_t idlo);
Expand Down
36 changes: 19 additions & 17 deletions c0cp.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,22 @@ int help()
/* main */
int main(int argc, char **argv)
{
uint64_t idh; /* object id high */
uint64_t idl; /* object is low */
uint64_t bsz; /* block size */
uint64_t cnt; /* count */
uint64_t pos; /* starting position */
uint64_t fsz; /* initial file size */
char *fname; /* input filename */
struct stat64 fs; /* file statistics */
int opt; /* options */
int rc=0; /* return code */
char *fbuf=NULL; /* file buffer */
int laps=0; /* number of writes */
int pool=0; /* default pool ID */
uint64_t idh; /* object id high */
uint64_t idl; /* object is low */
uint64_t bsz; /* block size */
uint64_t cnt; /* count */
uint64_t pos; /* starting position */
uint64_t fsz; /* initial file size */
char *fname; /* input filename */
struct stat64 fs; /* file statistics */
int opt; /* options */
int rc=0; /* return code */
char *fbuf=NULL; /* file buffer */
int laps=0; /* number of writes */
int pool=0; /* default pool ID */

/* getopt */
while((opt = getopt(argc, argv, ":pfc:x:"))!=-1){
while((opt = getopt(argc, argv, ":pfc:x:u:"))!=-1){
switch(opt){
case 'p':
perf = 1;
Expand All @@ -82,11 +82,14 @@ int main(int argc, char **argv)
force = 1;
break;
case 'c':
cont = 1;
cont = atoi(optarg);
if(cont<0) cont=0;
if(!cont) help();
break;
case 'u':
if (sscanf(optarg, "%i", &unit_size) != 1)
help();
break;
case 'x':
pool = atoi(optarg);
if(!isdigit(optarg[0])) pool = -1;
Expand Down Expand Up @@ -124,9 +127,8 @@ int main(int argc, char **argv)
idh = atoll(argv[optind+0]);
idl = atoll(argv[optind+1]);
fname = argv[optind+2];
bsz = atoll(argv[optind+3]);
bsz = atoll(argv[optind+3]) * 1024;
assert(bsz>0);
assert(!(bsz%1024));

/* extend */
stat64(fname, &fs);
Expand Down
3 changes: 1 addition & 2 deletions c0ct.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,10 @@ int main(int argc, char **argv)
idh = atoll(argv[optind+0]);
idl = atoll(argv[optind+1]);
fname = argv[optind+2];
bsz = atoll(argv[optind+3]);
bsz = atoll(argv[optind+3]) * 1024;
fsz = atoll(argv[optind+4]);
cnt = (fsz+bsz-1)/bsz;
assert(bsz>0);
assert(!(bsz%1024));
assert(!(fsz>cnt*bsz));

/* init */
Expand Down
39 changes: 0 additions & 39 deletions help.h

This file was deleted.

20 changes: 12 additions & 8 deletions help_c0cp.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
usage:

c0cp [options] idh idl filename bsz
c0cp 1234 56789 ./256MB 4096
c0cp 1234 56789 256KB-file 64

idh - Mero fid high
idl - Mero fid low
bsz - Clovis block size
bsz - Clovis block size (in KiBs)

options are:
-u | unit size (in KiBs, default 4),
| must be power of 2, >= 4 and <= 4096
-f | force
-p | performance
-c | contiguous mode.
Expand All @@ -17,21 +19,23 @@ options are:

The -f option forces rewriting on an object if that object already exists.
It creates a new object if the object does not exist.
c0cp -f 1234 56789 ./256MB 4096
c0cp -f 1234 56789 256MB-file 8096 -u 1024

The -p option enables performance monitoring. It collects performance parameters
such as bandwidth and displays them at the end of the execution.It also outputs
realtime storage bandwith consumption.
c0cp -p 1234 56789 ./256MB 4096
c0cp -p 1234 56789 256MB-file 8096 -u 1024

The -c <n> option takes <n> a positive number as an argument and creates an
object with <n> contiguous copies of the same file.
c0cp -c 10 1234 56789 ./256MB 4096
c0cp -c 10 1234 56789 256MB-file 8096 -u 1024

The -x option takes <n> a positive number as an argument and selects the pool
with ID <n> for creating the object. Without this option objects are created
in the default pool.
c0cp 1234 56789 ./256MB 4096 -x 3
c0cp -x 3 1234 56789 256MB-file 8096 -u 1024

The options can also be combined.
c0cp 1234 56789 ./256MB 4096 -f -p -c 10
Note: to get maximum performance block_size should be unit_size * units_number
in the parity group configuration of the pool. For example, in 8+2 parity
configuration (8 data + 2 parity units in the group) and 1MiB unit size -
block_size should be 8MiB.
12 changes: 6 additions & 6 deletions help_c0ct.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
usage:

c0ct [options] idh idl filename bsz fsz
c0cp 1234 56789 ./256MB 4096 268435456
c0ct 1234 56789 256MB-file 1024 268435456

idh - Mero fid high
idl - Mero fid low
bsz - Clovis block size
fsz - File size
bsz - Clovis block size (in KiBs)
fsz - File size (in bytes)

options are:
-p | performance
Expand All @@ -16,11 +16,11 @@ options are:
The -p option enables performance monitoring. It collects performance parameters
such as bandwidth and displays them at the end of the execution.It also outputs
realtime storage bandwith consumption.
c0ct -p 1234 56789 ./256MB 4096 268435456
c0ct -p 1234 56789 256MB-file 1024 268435456

The -c <n> option takes <n> a positive number as an argument and reads from an
object with <n> contiguous copies of the same file.
c0ct -c 10 1234 56789 ./256MB 4096 268435456
c0ct -c 10 1234 56789 256MB-file 1024 268435456

The options can also be combined.
c0ct 1234 56789 ./256MB 4096 268435456 -p -c 10
c0ct 1234 56789 256MB-file 1024 268435456 -p -c 10

0 comments on commit 2eeac88

Please sign in to comment.