Skip to content
Merged
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
2 changes: 1 addition & 1 deletion src/control/cmd/ddb/ddb_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ the path must include the extent, otherwise, it must not.`,
a.String("path", "Optional, VOS tree path of a container to aggregate.", grumble.Default(""))
},
Flags: func(f *grumble.Flags) {
f.Uint64("t", "cmt_time", math.MaxUint64, "Max aggregfation committed time in seconds")
f.Uint64("t", "cmt_time", math.MaxUint64, "Max aggregation committed time in seconds")
f.String("d", "cmt_date", "", "Max aggregation committed date (format '1970-01-01 00:00:00')")
},
Run: func(c *grumble.Context) error {
Expand Down
3 changes: 2 additions & 1 deletion src/include/daos_srv/vos.h
Original file line number Diff line number Diff line change
Expand Up @@ -1799,7 +1799,8 @@ bool
vos_oi_exist(daos_handle_t coh, daos_unit_oid_t oid);

/* Timing statistic of DTX entries */
#define DTX_TIME_STAT_COUNT 3
enum { DTX_TIME_STAT_MIN = 0, DTX_TIME_STAT_MAX, DTX_TIME_STAT_MEAN, DTX_TIME_STAT_COUNT };

struct dtx_time_stat {
daos_epoch_t dts_epoch[DTX_TIME_STAT_COUNT];
uint64_t dts_cmt_time[DTX_TIME_STAT_COUNT];
Expand Down
55 changes: 34 additions & 21 deletions src/utils/ddb/ddb_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -1506,35 +1506,48 @@ dtx_stat_cont_cb(daos_handle_t ih, vos_iter_entry_t *entry, vos_iter_type_t type
if (args->opt->details) {
if (args->aggr_epoch < args_tmp.aggr_epoch)
args->aggr_epoch = args_tmp.aggr_epoch;
if (args->time_stat.dts_cmt_time[0] > args_tmp.time_stat.dts_cmt_time[0])
args->time_stat.dts_cmt_time[0] = args_tmp.time_stat.dts_cmt_time[0];
if (args->time_stat.dts_cmt_time[1] < args_tmp.time_stat.dts_cmt_time[1])
args->time_stat.dts_cmt_time[1] = args_tmp.time_stat.dts_cmt_time[1];
if (args->time_stat.dts_cmt_time[2] == 0)
args->time_stat.dts_cmt_time[2] = args_tmp.time_stat.dts_cmt_time[2];
if (args->time_stat.dts_cmt_time[DTX_TIME_STAT_MIN] >
args_tmp.time_stat.dts_cmt_time[DTX_TIME_STAT_MIN])
args->time_stat.dts_cmt_time[DTX_TIME_STAT_MIN] =
args_tmp.time_stat.dts_cmt_time[DTX_TIME_STAT_MIN];
if (args->time_stat.dts_cmt_time[DTX_TIME_STAT_MAX] <
args_tmp.time_stat.dts_cmt_time[DTX_TIME_STAT_MAX])
args->time_stat.dts_cmt_time[DTX_TIME_STAT_MAX] =
args_tmp.time_stat.dts_cmt_time[DTX_TIME_STAT_MAX];
if (args->time_stat.dts_cmt_time[DTX_TIME_STAT_MEAN] == 0)
args->time_stat.dts_cmt_time[DTX_TIME_STAT_MEAN] =
args_tmp.time_stat.dts_cmt_time[DTX_TIME_STAT_MEAN];
else {
long double tmp_mean;

tmp_mean = args->time_stat.dts_cmt_time[2] * (long double)args->cmt_cnt;
tmp_mean += (long double)args_tmp.time_stat.dts_cmt_time[2] *
(long double)args_tmp.cmt_cnt;
tmp_mean = args->time_stat.dts_cmt_time[DTX_TIME_STAT_MEAN] *
(long double)args->cmt_cnt;
tmp_mean +=
(long double)args_tmp.time_stat.dts_cmt_time[DTX_TIME_STAT_MEAN] *
(long double)args_tmp.cmt_cnt;
tmp_mean /= (long double)(args->cmt_cnt + args_tmp.cmt_cnt);
args->time_stat.dts_cmt_time[2] = tmp_mean;
args->time_stat.dts_cmt_time[DTX_TIME_STAT_MEAN] = tmp_mean;
}
if (args->time_stat.dts_epoch[0] > args_tmp.time_stat.dts_epoch[0])
args->time_stat.dts_epoch[0] = args_tmp.time_stat.dts_epoch[0];
if (args->time_stat.dts_epoch[1] < args_tmp.time_stat.dts_epoch[1])
args->time_stat.dts_epoch[1] = args_tmp.time_stat.dts_epoch[1];
if (args->time_stat.dts_epoch[2] == 0)
args->time_stat.dts_epoch[2] = args_tmp.time_stat.dts_epoch[2];
if (args->time_stat.dts_epoch[DTX_TIME_STAT_MIN] >
args_tmp.time_stat.dts_epoch[DTX_TIME_STAT_MIN])
args->time_stat.dts_epoch[DTX_TIME_STAT_MIN] =
args_tmp.time_stat.dts_epoch[DTX_TIME_STAT_MIN];
if (args->time_stat.dts_epoch[DTX_TIME_STAT_MAX] <
args_tmp.time_stat.dts_epoch[DTX_TIME_STAT_MAX])
args->time_stat.dts_epoch[DTX_TIME_STAT_MAX] =
args_tmp.time_stat.dts_epoch[DTX_TIME_STAT_MAX];
if (args->time_stat.dts_epoch[DTX_TIME_STAT_MEAN] == 0)
args->time_stat.dts_epoch[DTX_TIME_STAT_MEAN] =
args_tmp.time_stat.dts_epoch[DTX_TIME_STAT_MEAN];
else {
long double tmp_mean;

tmp_mean = args->time_stat.dts_epoch[2] * (long double)args->cmt_cnt;
tmp_mean += (long double)args_tmp.time_stat.dts_epoch[2] *
tmp_mean = args->time_stat.dts_epoch[DTX_TIME_STAT_MEAN] *
(long double)args->cmt_cnt;
tmp_mean += (long double)args_tmp.time_stat.dts_epoch[DTX_TIME_STAT_MEAN] *
(long double)args_tmp.cmt_cnt;
tmp_mean /= (long double)(args->cmt_cnt + args_tmp.cmt_cnt);
args->time_stat.dts_epoch[2] = tmp_mean;
args->time_stat.dts_epoch[DTX_TIME_STAT_MEAN] = tmp_mean;
}
}

Expand Down Expand Up @@ -1592,8 +1605,8 @@ ddb_run_dtx_stat(struct ddb_ctx *ctx, struct dtx_stat_options *opt)
}

args.cmt_cnt = 0;
args.time_stat.dts_cmt_time[0] = UINT64_MAX;
args.time_stat.dts_epoch[0] = DAOS_EPOCH_MAX;
args.time_stat.dts_cmt_time[DTX_TIME_STAT_MIN] = UINT64_MAX;
args.time_stat.dts_epoch[DTX_TIME_STAT_MIN] = DAOS_EPOCH_MAX;
param.ip_hdl = ctx->dc_poh;
param.ip_epr.epr_hi = DAOS_EPOCH_MAX;
do {
Expand Down
48 changes: 30 additions & 18 deletions src/vos/vos_dtx.c
Original file line number Diff line number Diff line change
Expand Up @@ -4070,10 +4070,12 @@ vos_dtx_local_end(struct dtx_handle *dth, int result)
return result;
}

enum { DTS_EPOCH_ACC = 0, DTS_CMT_TIME_ACC, DTS_ACC_COUNT };

struct dtx_time_stat_priv {
struct dtx_time_stat dts_pub;
/* DAOS-17322: Use of floating point to avoid integer overflow issue */
long double dts_mean[2];
long double dts_mean[DTS_ACC_COUNT];
};

int
Expand All @@ -4099,8 +4101,8 @@ vos_dtx_get_cmt_stat(daos_handle_t coh, uint64_t *cmt_cnt, struct dtx_time_stat
cmt_cnt_tmp = 0;
umm = vos_cont2umm(cont);
dbd = umem_off2ptr(umm, cont->vc_cont_df->cd_dtx_committed_head);
dts_tmp.dts_pub.dts_epoch[0] = DAOS_EPOCH_MAX;
dts_tmp.dts_pub.dts_cmt_time[0] = UINT64_MAX;
dts_tmp.dts_pub.dts_epoch[DTX_TIME_STAT_MIN] = DAOS_EPOCH_MAX;
dts_tmp.dts_pub.dts_cmt_time[DTX_TIME_STAT_MIN] = UINT64_MAX;
while (dbd != NULL) {
if (dbd->dbd_magic != DTX_CMT_BLOB_MAGIC) {
D_ERROR("Committed DTX blob with bad magic: container=" DF_UUID
Expand All @@ -4119,17 +4121,25 @@ vos_dtx_get_cmt_stat(daos_handle_t coh, uint64_t *cmt_cnt, struct dtx_time_stat

dce_df = &dbd->dbd_committed_data[i];

if (dts_tmp.dts_pub.dts_epoch[0] > dce_df->dce_epoch)
dts_tmp.dts_pub.dts_epoch[0] = dce_df->dce_epoch;
if (dts_tmp.dts_pub.dts_epoch[1] < dce_df->dce_epoch)
dts_tmp.dts_pub.dts_epoch[1] = dce_df->dce_epoch;
dts_tmp.dts_mean[0] += dce_df->dce_epoch;

if (dts_tmp.dts_pub.dts_cmt_time[0] > dce_df->dce_cmt_time)
dts_tmp.dts_pub.dts_cmt_time[0] = dce_df->dce_cmt_time;
if (dts_tmp.dts_pub.dts_cmt_time[1] < dce_df->dce_cmt_time)
dts_tmp.dts_pub.dts_cmt_time[1] = dce_df->dce_cmt_time;
dts_tmp.dts_mean[1] += dce_df->dce_cmt_time;
if (dts_tmp.dts_pub.dts_epoch[DTX_TIME_STAT_MIN] >
dce_df->dce_epoch)
dts_tmp.dts_pub.dts_epoch[DTX_TIME_STAT_MIN] =
dce_df->dce_epoch;
if (dts_tmp.dts_pub.dts_epoch[DTX_TIME_STAT_MAX] <
dce_df->dce_epoch)
dts_tmp.dts_pub.dts_epoch[DTX_TIME_STAT_MAX] =
dce_df->dce_epoch;
dts_tmp.dts_mean[DTS_EPOCH_ACC] += dce_df->dce_epoch;

if (dts_tmp.dts_pub.dts_cmt_time[DTX_TIME_STAT_MIN] >
dce_df->dce_cmt_time)
dts_tmp.dts_pub.dts_cmt_time[DTX_TIME_STAT_MIN] =
dce_df->dce_cmt_time;
if (dts_tmp.dts_pub.dts_cmt_time[DTX_TIME_STAT_MAX] <
dce_df->dce_cmt_time)
dts_tmp.dts_pub.dts_cmt_time[DTX_TIME_STAT_MAX] =
dce_df->dce_cmt_time;
dts_tmp.dts_mean[DTS_CMT_TIME_ACC] += dce_df->dce_cmt_time;
}
}

Expand All @@ -4140,11 +4150,13 @@ vos_dtx_get_cmt_stat(daos_handle_t coh, uint64_t *cmt_cnt, struct dtx_time_stat

if (dts != NULL) {
if (cmt_cnt_tmp != 0) {
dts_tmp.dts_mean[0] /= (long double)cmt_cnt_tmp;
dts_tmp.dts_pub.dts_epoch[2] = (daos_epoch_t)dts_tmp.dts_mean[0];
dts_tmp.dts_mean[DTS_EPOCH_ACC] /= (long double)cmt_cnt_tmp;
dts_tmp.dts_pub.dts_epoch[DTX_TIME_STAT_MEAN] =
(daos_epoch_t)dts_tmp.dts_mean[DTS_EPOCH_ACC];

dts_tmp.dts_mean[1] /= (long double)cmt_cnt_tmp;
dts_tmp.dts_pub.dts_cmt_time[2] = (uint64_t)dts_tmp.dts_mean[1];
dts_tmp.dts_mean[DTS_CMT_TIME_ACC] /= (long double)cmt_cnt_tmp;
dts_tmp.dts_pub.dts_cmt_time[DTX_TIME_STAT_MEAN] =
(uint64_t)dts_tmp.dts_mean[DTS_CMT_TIME_ACC];
}

memcpy(dts, &dts_tmp, sizeof(struct dtx_time_stat));
Expand Down
Loading