projects
/
fio.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'evelu-peak' of https://github.com/ErwanAliasr1/fio
[fio.git]
/
profiles
/
act.c
diff --git
a/profiles/act.c
b/profiles/act.c
index 73cde8565c78236a6ddf258f6bf90eb4ad91c881..5d3bd2544ed9b714b5b769c2bbe7cf6bcb7c4a09 100644
(file)
--- a/
profiles/act.c
+++ b/
profiles/act.c
@@
-1,6
+1,7
@@
#include "../fio.h"
#include "../profile.h"
#include "../parse.h"
#include "../fio.h"
#include "../profile.h"
#include "../parse.h"
+#include "../optgroup.h"
/*
* 1x loads
/*
* 1x loads
@@
-37,7
+38,7
@@
struct act_slice {
};
struct act_run_data {
};
struct act_run_data {
- struct fio_
mutex *mutex
;
+ struct fio_
sem *sem
;
unsigned int pending;
struct act_slice *slices;
unsigned int pending;
struct act_slice *slices;
@@
-46,20
+47,12
@@
struct act_run_data {
static struct act_run_data *act_run_data;
struct act_prof_data {
static struct act_run_data *act_run_data;
struct act_prof_data {
- struct time
val
sample_tv;
+ struct time
spec
sample_tv;
struct act_slice *slices;
unsigned int cur_slice;
unsigned int nr_slices;
};
struct act_slice *slices;
unsigned int cur_slice;
unsigned int nr_slices;
};
-static char *device_names;
-static unsigned int load;
-static unsigned int prep;
-static unsigned int threads_per_queue;
-static unsigned int num_read_blocks;
-static unsigned int write_size;
-static unsigned long long test_duration;
-
#define ACT_MAX_OPTS 128
static const char *act_opts[ACT_MAX_OPTS] = {
"direct=1",
#define ACT_MAX_OPTS 128
static const char *act_opts[ACT_MAX_OPTS] = {
"direct=1",
@@
-74,21
+67,35
@@
static unsigned int org_idx;
static int act_add_opt(const char *format, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
static int act_add_opt(const char *format, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
+struct act_options {
+ unsigned int pad;
+ char *device_names;
+ unsigned int load;
+ unsigned int prep;
+ unsigned int threads_per_queue;
+ unsigned int num_read_blocks;
+ unsigned int write_size;
+ unsigned long long test_duration;
+};
+
+static struct act_options act_options;
+
static struct fio_option options[] = {
{
.name = "device-names",
.lname = "device-names",
.type = FIO_OPT_STR_STORE,
static struct fio_option options[] = {
{
.name = "device-names",
.lname = "device-names",
.type = FIO_OPT_STR_STORE,
- .
roff1 = &device_names
,
+ .
off1 = offsetof(struct act_options, device_names)
,
.help = "Devices to use",
.category = FIO_OPT_C_PROFILE,
.group = FIO_OPT_G_ACT,
.help = "Devices to use",
.category = FIO_OPT_C_PROFILE,
.group = FIO_OPT_G_ACT,
+ .no_free = true,
},
{
.name = "load",
.lname = "Load multiplier",
.type = FIO_OPT_INT,
},
{
.name = "load",
.lname = "Load multiplier",
.type = FIO_OPT_INT,
- .
roff1 = &load
,
+ .
off1 = offsetof(struct act_options, load)
,
.help = "ACT load multipler (default 1x)",
.def = "1",
.category = FIO_OPT_C_PROFILE,
.help = "ACT load multipler (default 1x)",
.def = "1",
.category = FIO_OPT_C_PROFILE,
@@
-98,7
+105,7
@@
static struct fio_option options[] = {
.name = "test-duration",
.lname = "Test duration",
.type = FIO_OPT_STR_VAL_TIME,
.name = "test-duration",
.lname = "Test duration",
.type = FIO_OPT_STR_VAL_TIME,
- .
roff1 = &test_duration
,
+ .
off1 = offsetof(struct act_options, test_duration)
,
.help = "How long the entire test takes to run",
.def = "24h",
.category = FIO_OPT_C_PROFILE,
.help = "How long the entire test takes to run",
.def = "24h",
.category = FIO_OPT_C_PROFILE,
@@
-108,7
+115,7
@@
static struct fio_option options[] = {
.name = "threads-per-queue",
.lname = "Number of read IO threads per device",
.type = FIO_OPT_INT,
.name = "threads-per-queue",
.lname = "Number of read IO threads per device",
.type = FIO_OPT_INT,
- .
roff1 = &threads_per_queue
,
+ .
off1 = offsetof(struct act_options, threads_per_queue)
,
.help = "Number of read IO threads per device",
.def = "8",
.category = FIO_OPT_C_PROFILE,
.help = "Number of read IO threads per device",
.def = "8",
.category = FIO_OPT_C_PROFILE,
@@
-116,21
+123,21
@@
static struct fio_option options[] = {
},
{
.name = "read-req-num-512-blocks",
},
{
.name = "read-req-num-512-blocks",
- .lname = "Number of 512
b
blocks to read",
+ .lname = "Number of 512
B
blocks to read",
.type = FIO_OPT_INT,
.type = FIO_OPT_INT,
- .
roff1 = &num_read_blocks
,
- .help = "Number of 512
b
blocks to read at the time",
+ .
off1 = offsetof(struct act_options, num_read_blocks)
,
+ .help = "Number of 512
B
blocks to read at the time",
.def = "3",
.category = FIO_OPT_C_PROFILE,
.group = FIO_OPT_G_ACT,
},
{
.name = "large-block-op-kbytes",
.def = "3",
.category = FIO_OPT_C_PROFILE,
.group = FIO_OPT_G_ACT,
},
{
.name = "large-block-op-kbytes",
- .lname = "Size of large block ops (writes)",
+ .lname = "Size of large block ops
in KiB
(writes)",
.type = FIO_OPT_INT,
.type = FIO_OPT_INT,
- .
roff1 = &write_size
,
- .help = "Size of large block ops (writes)",
- .def = "1
28k
",
+ .
off1 = offsetof(struct act_options, write_size)
,
+ .help = "Size of large block ops
in KiB
(writes)",
+ .def = "1
31072
",
.category = FIO_OPT_C_PROFILE,
.group = FIO_OPT_G_ACT,
},
.category = FIO_OPT_C_PROFILE,
.group = FIO_OPT_G_ACT,
},
@@
-138,7
+145,7
@@
static struct fio_option options[] = {
.name = "prep",
.lname = "Run ACT prep phase",
.type = FIO_OPT_STR_SET,
.name = "prep",
.lname = "Run ACT prep phase",
.type = FIO_OPT_STR_SET,
- .
roff1 = &prep
,
+ .
off1 = offsetof(struct act_options, prep)
,
.help = "Set to run ACT prep phase",
.category = FIO_OPT_C_PROFILE,
.group = FIO_OPT_G_ACT,
.help = "Set to run ACT prep phase",
.category = FIO_OPT_C_PROFILE,
.group = FIO_OPT_G_ACT,
@@
-171,6
+178,8
@@
static int act_add_opt(const char *str, ...)
static int act_add_rw(const char *dev, int reads)
{
static int act_add_rw(const char *dev, int reads)
{
+ struct act_options *ao = &act_options;
+
if (act_add_opt("name=act-%s-%s", reads ? "read" : "write", dev))
return 1;
if (act_add_opt("filename=%s", dev))
if (act_add_opt("name=act-%s-%s", reads ? "read" : "write", dev))
return 1;
if (act_add_opt("filename=%s", dev))
@@
-178,21
+187,21
@@
static int act_add_rw(const char *dev, int reads)
if (act_add_opt("rw=%s", reads ? "randread" : "randwrite"))
return 1;
if (reads) {
if (act_add_opt("rw=%s", reads ? "randread" : "randwrite"))
return 1;
if (reads) {
- int rload =
load * R_LOAD /
threads_per_queue;
+ int rload =
ao->load * R_LOAD / ao->
threads_per_queue;
- if (act_add_opt("numjobs=%u", threads_per_queue))
+ if (act_add_opt("numjobs=%u",
ao->
threads_per_queue))
return 1;
if (act_add_opt("rate_iops=%u", rload))
return 1;
return 1;
if (act_add_opt("rate_iops=%u", rload))
return 1;
- if (act_add_opt("bs=%u", num_read_blocks * 512))
+ if (act_add_opt("bs=%u",
ao->
num_read_blocks * 512))
return 1;
} else {
return 1;
} else {
- const int rsize =
write_size / (
num_read_blocks * 512);
- int wload = (load * W_LOAD + rsize - 1) / rsize;
+ const int rsize =
ao->write_size / (ao->
num_read_blocks * 512);
+ int wload = (
ao->
load * W_LOAD + rsize - 1) / rsize;
if (act_add_opt("rate_iops=%u", wload))
return 1;
if (act_add_opt("rate_iops=%u", wload))
return 1;
- if (act_add_opt("bs=%u", write_size))
+ if (act_add_opt("bs=%u",
ao->
write_size))
return 1;
}
return 1;
}
@@
-206,7
+215,7
@@
static int act_add_dev_prep(const char *dev)
return 1;
if (act_add_opt("filename=%s", dev))
return 1;
return 1;
if (act_add_opt("filename=%s", dev))
return 1;
- if (act_add_opt("bs=1
M
"))
+ if (act_add_opt("bs=1
048576
"))
return 1;
if (act_add_opt("zero_buffers"))
return 1;
return 1;
if (act_add_opt("zero_buffers"))
return 1;
@@
-220,7
+229,7
@@
static int act_add_dev_prep(const char *dev)
return 1;
if (act_add_opt("filename=%s", dev))
return 1;
return 1;
if (act_add_opt("filename=%s", dev))
return 1;
- if (act_add_opt("bs=4
k
"))
+ if (act_add_opt("bs=4
096
"))
return 1;
if (act_add_opt("ioengine=libaio"))
return 1;
return 1;
if (act_add_opt("ioengine=libaio"))
return 1;
@@
-234,10
+243,10
@@
static int act_add_dev_prep(const char *dev)
static int act_add_dev(const char *dev)
{
static int act_add_dev(const char *dev)
{
- if (prep)
+ if (
act_options.
prep)
return act_add_dev_prep(dev);
return act_add_dev_prep(dev);
- if (act_add_opt("runtime=%llus", test_duration))
+ if (act_add_opt("runtime=%llus",
act_options.
test_duration))
return 1;
if (act_add_opt("time_based=1"))
return 1;
return 1;
if (act_add_opt("time_based=1"))
return 1;
@@
-255,7
+264,7
@@
static int act_add_dev(const char *dev)
*/
static int act_prep_cmdline(void)
{
*/
static int act_prep_cmdline(void)
{
- if (!device_names) {
+ if (!
act_options.
device_names) {
log_err("act: you need to set IO target(s) with the "
"device-names option.\n");
return 1;
log_err("act: you need to set IO target(s) with the "
"device-names option.\n");
return 1;
@@
-266,7
+275,7
@@
static int act_prep_cmdline(void)
do {
char *dev;
do {
char *dev;
- dev = strsep(&device_names, ",");
+ dev = strsep(&
act_options.
device_names, ",");
if (!dev)
break;
if (!dev)
break;
@@
-279,14
+288,15
@@
static int act_prep_cmdline(void)
return 0;
}
return 0;
}
-static int act_io_u_lat(struct thread_data *td, uint64_t
u
sec)
+static int act_io_u_lat(struct thread_data *td, uint64_t
n
sec)
{
struct act_prof_data *apd = td->prof_data;
struct act_slice *slice;
{
struct act_prof_data *apd = td->prof_data;
struct act_slice *slice;
+ uint64_t usec = nsec / 1000ULL;
int i, ret = 0;
double perm;
int i, ret = 0;
double perm;
- if (prep)
+ if (
act_options.
prep)
return 0;
/*
return 0;
/*
@@
-327,9
+337,9
@@
static int act_io_u_lat(struct thread_data *td, uint64_t usec)
static void get_act_ref(void)
{
static void get_act_ref(void)
{
- fio_
mutex_down(act_run_data->mutex
);
+ fio_
sem_down(act_run_data->sem
);
act_run_data->pending++;
act_run_data->pending++;
- fio_
mutex_up(act_run_data->mutex
);
+ fio_
sem_up(act_run_data->sem
);
}
static int show_slice(struct act_slice *slice, unsigned int slice_num)
}
static int show_slice(struct act_slice *slice, unsigned int slice_num)
@@
-386,10
+396,10
@@
static void put_act_ref(struct thread_data *td)
struct act_prof_data *apd = td->prof_data;
unsigned int i, slice;
struct act_prof_data *apd = td->prof_data;
unsigned int i, slice;
- fio_
mutex_down(act_run_data->mutex
);
+ fio_
sem_down(act_run_data->sem
);
if (!act_run_data->slices) {
if (!act_run_data->slices) {
- act_run_data->slices = calloc(
sizeof(struct act_slice), apd->nr_slices
);
+ act_run_data->slices = calloc(
apd->nr_slices, sizeof(struct act_slice)
);
act_run_data->nr_slices = apd->nr_slices;
}
act_run_data->nr_slices = apd->nr_slices;
}
@@
-406,7
+416,7
@@
static void put_act_ref(struct thread_data *td)
if (!--act_run_data->pending)
act_show_all_stats();
if (!--act_run_data->pending)
act_show_all_stats();
- fio_
mutex_up(act_run_data->mutex
);
+ fio_
sem_up(act_run_data->sem
);
}
static int act_td_init(struct thread_data *td)
}
static int act_td_init(struct thread_data *td)
@@
-416,9
+426,9
@@
static int act_td_init(struct thread_data *td)
get_act_ref();
get_act_ref();
- apd = calloc(
sizeof(*apd), 1
);
- nr_slices = (test_duration + SAMPLE_SEC - 1) / SAMPLE_SEC;
- apd->slices = calloc(
sizeof(struct act_slice), nr_slices
);
+ apd = calloc(
1, sizeof(*apd)
);
+ nr_slices = (
act_options.
test_duration + SAMPLE_SEC - 1) / SAMPLE_SEC;
+ apd->slices = calloc(
nr_slices, sizeof(struct act_slice)
);
apd->nr_slices = nr_slices;
fio_gettime(&apd->sample_tv, NULL);
td->prof_data = apd;
apd->nr_slices = nr_slices;
fio_gettime(&apd->sample_tv, NULL);
td->prof_data = apd;
@@
-445,6
+455,7
@@
static struct profile_ops act_profile = {
.name = "act",
.desc = "ACT Aerospike like benchmark",
.options = options,
.name = "act",
.desc = "ACT Aerospike like benchmark",
.options = options,
+ .opt_data = &act_options,
.prep_cmd = act_prep_cmdline,
.cmdline = act_opts,
.io_ops = &act_io_ops,
.prep_cmd = act_prep_cmdline,
.cmdline = act_opts,
.io_ops = &act_io_ops,
@@
-452,8
+463,8
@@
static struct profile_ops act_profile = {
static void fio_init act_register(void)
{
static void fio_init act_register(void)
{
- act_run_data = calloc(
sizeof(*act_run_data), 1
);
- act_run_data->
mutex = fio_mutex_init(FIO_MUTEX
_UNLOCKED);
+ act_run_data = calloc(
1, sizeof(*act_run_data)
);
+ act_run_data->
sem = fio_sem_init(FIO_SEM
_UNLOCKED);
if (register_profile(&act_profile))
log_err("fio: failed to register profile 'act'\n");
if (register_profile(&act_profile))
log_err("fio: failed to register profile 'act'\n");
@@
-465,7
+476,7
@@
static void fio_exit act_unregister(void)
free((void *) act_opts[++org_idx]);
unregister_profile(&act_profile);
free((void *) act_opts[++org_idx]);
unregister_profile(&act_profile);
- fio_
mutex_remove(act_run_data->mutex
);
+ fio_
sem_remove(act_run_data->sem
);
free(act_run_data->slices);
free(act_run_data);
act_run_data = NULL;
free(act_run_data->slices);
free(act_run_data);
act_run_data = NULL;