Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to record alternate_epoch but keep zero-based timestamps #1353

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions HOWTO.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3699,20 +3699,27 @@ Measurements and reporting

If set, fio will log Unix timestamps to the log files produced by enabling
write_type_log for each log type, instead of the default zero-based
timestamps.
timestamps. alternate_epoch will also be set as a Unix timestamp.

.. option:: log_alternate_epoch=bool

If set, fio will log timestamps based on the epoch used by the clock specified
in the log_alternate_epoch_clock_id option, to the log files produced by
enabling write_type_log for each log type, instead of the default zero-based
timestamps.
If set, fio will set alternate_epoch based on the clock specified
in :option:`alternate_epoch_clock_id`. Further, fio will add alternate_epoch
to the timestamps in the log files produced by enabling write_type_log for
each log type. Fio will also report the alternate_epoch in its json output.

.. option:: log_alternate_epoch_clock_id=int
.. option:: record_alternate_epoch=bool

If set, fio will set alternate_epoch based on the clock specified
in :option:`alternate_epoch_clock_id`, but timestamps in log files produced
by enabling write_type_log for each log type will not be affected. Fio will
report the alternate_epoch in its json output.

.. option:: alternate_epoch_clock_id=int

Specifies the clock_id to be used by clock_gettime to obtain the alternate epoch
if either log_unix_epoch or log_alternate_epoch are true. Otherwise has no
effect. Default value is 0, or CLOCK_REALTIME.
if log_unix_epoch, log_alternate_epoch, or record_alternate_epoch are true.
Otherwise has no effect. Default value is 0, or CLOCK_REALTIME.

.. option:: block_error_percentiles=bool

Expand Down
6 changes: 5 additions & 1 deletion backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -1808,7 +1808,11 @@ static void *thread_main(void *data)
if (rate_submit_init(td, sk_out))
goto err;

set_epoch_time(td, o->log_unix_epoch | o->log_alternate_epoch, o->log_alternate_epoch_clock_id);
set_epoch_time(td,
o->log_unix_epoch |
o->log_alternate_epoch |
o->record_alternate_epoch,
o->alternate_epoch_clock_id);
fio_getrusage(&td->ru_start);
memcpy(&td->bw_sample_time, &td->epoch, sizeof(td->epoch));
memcpy(&td->iops_sample_time, &td->epoch, sizeof(td->epoch));
Expand Down
6 changes: 4 additions & 2 deletions cconv.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ void convert_thread_options_to_cpu(struct thread_options *o,
o->log_gz_store = le32_to_cpu(top->log_gz_store);
o->log_unix_epoch = le32_to_cpu(top->log_unix_epoch);
o->log_alternate_epoch = le32_to_cpu(top->log_alternate_epoch);
o->log_alternate_epoch_clock_id = le32_to_cpu(top->log_alternate_epoch_clock_id);
o->record_alternate_epoch = le32_to_cpu(top->record_alternate_epoch);
o->alternate_epoch_clock_id = le32_to_cpu(top->alternate_epoch_clock_id);
o->norandommap = le32_to_cpu(top->norandommap);
o->softrandommap = le32_to_cpu(top->softrandommap);
o->bs_unaligned = le32_to_cpu(top->bs_unaligned);
Expand Down Expand Up @@ -428,7 +429,8 @@ void convert_thread_options_to_net(struct thread_options_pack *top,
top->log_gz_store = cpu_to_le32(o->log_gz_store);
top->log_unix_epoch = cpu_to_le32(o->log_unix_epoch);
top->log_alternate_epoch = cpu_to_le32(o->log_alternate_epoch);
top->log_alternate_epoch_clock_id = cpu_to_le32(o->log_alternate_epoch_clock_id);
top->record_alternate_epoch = cpu_to_le32(o->record_alternate_epoch);
top->alternate_epoch_clock_id = cpu_to_le32(o->alternate_epoch_clock_id);
top->norandommap = cpu_to_le32(o->norandommap);
top->softrandommap = cpu_to_le32(o->softrandommap);
top->bs_unaligned = cpu_to_le32(o->bs_unaligned);
Expand Down
24 changes: 15 additions & 9 deletions fio.1
Original file line number Diff line number Diff line change
Expand Up @@ -3395,18 +3395,24 @@ parameter. The files will be stored with a `.fz' suffix.
.BI log_unix_epoch \fR=\fPbool
If set, fio will log Unix timestamps to the log files produced by enabling
write_type_log for each log type, instead of the default zero-based
timestamps.
timestamps. alternate_epoch will also be set as a Unix timestamp.
.TP
.BI log_alternate_epoch \fR=\fPbool
If set, fio will log timestamps based on the epoch used by the clock specified
in the \fBlog_alternate_epoch_clock_id\fR option, to the log files produced by
enabling write_type_log for each log type, instead of the default zero-based
timestamps.
.TP
.BI log_alternate_epoch_clock_id \fR=\fPint
If set, fio will set alternate_epoch based on the clock specified in
\fBlog_alternate_epoch_clock_id\fR. Further, fio will add alternate_epoch to the
timestamps in the log files produced by enabling write_type_log for each log type.
Fio will also report the alternate_epoch in its json output.
.TP
.BI record_alternate_epoch \fR=\fPbool
If set, fio will set alternate_epoch based on the clock specified in
\fBlog_alternate_epoch_clock_id\fR, but timestamps in log files produced by
enabling write_type_log for each log type will not be affected. Fio will report
the alternate_epoch in its json output.
.TP
.BI alternate_epoch_clock_id \fR=\fPint
Specifies the clock_id to be used by clock_gettime to obtain the alternate epoch
if either \fBBlog_unix_epoch\fR or \fBlog_alternate_epoch\fR are true. Otherwise has no
effect. Default value is 0, or CLOCK_REALTIME.
if \fBBlog_unix_epoch\fR, \fBlog_alternate_epoch\fR, or \fBrecord_alternate_epoch\fR
are true. Otherwise has no effect. Default value is 0, or CLOCK_REALTIME.
.TP
.BI block_error_percentiles \fR=\fPbool
If set, record errors in trim block-sized units from writes and trims and
Expand Down
6 changes: 5 additions & 1 deletion libfio.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,11 @@ void reset_all_stats(struct thread_data *td)
td->ts.runtime[i] = 0;
}

set_epoch_time(td, td->o.log_unix_epoch | td->o.log_alternate_epoch, td->o.log_alternate_epoch_clock_id);
set_epoch_time(td,
td->o.log_unix_epoch |
td->o.log_alternate_epoch |
td->o.record_alternate_epoch,
td->o.alternate_epoch_clock_id);
memcpy(&td->start, &td->epoch, sizeof(td->epoch));
memcpy(&td->iops_sample_time, &td->epoch, sizeof(td->epoch));
memcpy(&td->bw_sample_time, &td->epoch, sizeof(td->epoch));
Expand Down
21 changes: 15 additions & 6 deletions options.c
Original file line number Diff line number Diff line change
Expand Up @@ -4510,7 +4510,7 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
.lname = "Log epoch unix",
.type = FIO_OPT_BOOL,
.off1 = offsetof(struct thread_options, log_unix_epoch),
.help = "Use Unix time in log files",
.help = "Use Unix time in log files. Equivalent to log_alternate_epoch with default value for alternate_epoch_clock_id",
.category = FIO_OPT_C_LOG,
.group = FIO_OPT_G_INVALID,
},
Expand All @@ -4519,16 +4519,25 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
.lname = "Log epoch alternate",
.type = FIO_OPT_BOOL,
.off1 = offsetof(struct thread_options, log_alternate_epoch),
.help = "Use alternate epoch time in log files. Uses the same epoch as that is used by clock_gettime with specified log_alternate_epoch_clock_id.",
.help = "Set a job's alternate_epoch using by calling clock_gettime(alternate_epoch_clock_id, &ts) when the job begins, and set alternate_epoch to ts converted to milliseconds. Further, add alternate_epoch to the timestamps in the log files. This means log file timestamps are also using the epoch specified with alternate_epoch_clock_id. Report the alternate_epoch in json output",
.category = FIO_OPT_C_LOG,
.group = FIO_OPT_G_INVALID,
},
{
.name = "log_alternate_epoch_clock_id",
.lname = "Log alternate epoch clock_id",
.name = "record_alternate_epoch",
.lname = "Record alternate epoch",
.type = FIO_OPT_BOOL,
.off1 = offsetof(struct thread_options, record_alternate_epoch),
.help = "Set a job's alternate_epoch using by calling clock_gettime(alternate_epoch_clock_id, &ts) when the job begins, and set alternate_epoch to ts converted to milliseconds. Unlike log_alternate_epoch/log_unix_epoch, does not add alternate_epoch to the timestamps in the log files, so the timestamps in logs remain zero-based. Report the alternate_epoch in json output. A true value for log_alternate_epoch/log_unix_epoch functionally overrides this option.",
.category = FIO_OPT_C_LOG,
.group = FIO_OPT_G_INVALID,
},
{
.name = "alternate_epoch_clock_id",
.lname = "alternate epoch clock_id",
.type = FIO_OPT_INT,
.off1 = offsetof(struct thread_options, log_alternate_epoch_clock_id),
.help = "If log_alternate_epoch or log_unix_epoch is true, this option specifies the clock_id from clock_gettime whose epoch should be used. If neither of those is true, this option has no effect. Default value is 0, or CLOCK_REALTIME",
.off1 = offsetof(struct thread_options, alternate_epoch_clock_id),
.help = "If log_alternate_epoch, log_unix_epoch, or record_alternate_epoch is true, this option specifies the clock_id to be used when calling clock_gettime to determine a job's alternate_epoch. If none of those is true, this option has no effect. Default value is 0, or CLOCK_REALTIME",
.category = FIO_OPT_C_LOG,
.group = FIO_OPT_G_INVALID,
},
Expand Down
6 changes: 5 additions & 1 deletion rate-submit.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,11 @@ static int io_workqueue_init_worker_fn(struct submit_worker *sw)
if (td->io_ops->post_init && td->io_ops->post_init(td))
goto err_io_init;

set_epoch_time(td, td->o.log_unix_epoch | td->o.log_alternate_epoch, td->o.log_alternate_epoch_clock_id);
set_epoch_time(td,
td->o.log_unix_epoch |
td->o.log_alternate_epoch |
td->o.record_alternate_epoch,
td->o.alternate_epoch_clock_id);
fio_getrusage(&td->ru_start);
clear_io_state(td, 1);

Expand Down
6 changes: 5 additions & 1 deletion stat.c
Original file line number Diff line number Diff line change
Expand Up @@ -1691,6 +1691,7 @@ static struct json_object *show_thread_status_json(struct thread_stat *ts,
root = json_create_object();
json_object_add_value_string(root, "jobname", ts->name);
json_object_add_value_int(root, "groupid", ts->groupid);
json_object_add_value_int(root, "alternate_epoch", ts->alternate_epoch);
json_object_add_value_int(root, "error", ts->error);

/* ETA Info */
Expand Down Expand Up @@ -2505,6 +2506,7 @@ void __show_run_stats(void)
*/
ts->thread_number = td->thread_number;
ts->groupid = td->groupid;
ts->alternate_epoch = td->alternate_epoch;

/*
* first pid in group, not very useful...
Expand Down Expand Up @@ -3016,11 +3018,13 @@ static void __add_log_sample(struct io_log *iolog, union io_sample_data data,
cur_log = get_cur_log(iolog);
if (cur_log) {
struct io_sample *s;
bool add_alternate_epoch;

add_alternate_epoch = iolog->td->o.log_alternate_epoch || iolog->td->o.log_unix_epoch;
s = get_sample(iolog, cur_log, cur_log->nr_samples);

s->data = data;
s->time = t + (iolog->td ? iolog->td->alternate_epoch : 0);
s->time = t + ((iolog->td && add_alternate_epoch) ? iolog->td->alternate_epoch : 0);
io_sample_set_ddir(iolog, s, ddir);
s->bs = bs;
s->priority = priority;
Expand Down
1 change: 1 addition & 0 deletions stat.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ struct thread_stat {
uint32_t error;
uint32_t thread_number;
uint32_t groupid;
unsigned long long alternate_epoch;
uint32_t pid;
char description[FIO_JOBDESC_SIZE];
uint32_t members;
Expand Down
7 changes: 5 additions & 2 deletions thread_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ struct thread_options {
unsigned int log_gz_store;
unsigned int log_unix_epoch;
unsigned int log_alternate_epoch;
unsigned int log_alternate_epoch_clock_id;
unsigned int record_alternate_epoch;
unsigned int alternate_epoch_clock_id;
unsigned int norandommap;
unsigned int softrandommap;
unsigned int bs_unaligned;
Expand Down Expand Up @@ -491,7 +492,8 @@ struct thread_options_pack {
uint32_t log_gz_store;
uint32_t log_unix_epoch;
uint32_t log_alternate_epoch;
uint32_t log_alternate_epoch_clock_id;
uint32_t record_alternate_epoch;
uint32_t alternate_epoch_clock_id;
uint32_t norandommap;
uint32_t softrandommap;
uint32_t bs_unaligned;
Expand All @@ -505,6 +507,7 @@ struct thread_options_pack {

struct zone_split zone_split[DDIR_RWDIR_CNT][ZONESPLIT_MAX];
uint32_t zone_split_nr[DDIR_RWDIR_CNT];
uint32_t pad5;

fio_fp64_t zipf_theta;
fio_fp64_t pareto_h;
Expand Down