Keeps a cumulative tick for all disk operations.

This commit is contained in:
Andrea Mazzoleni 2014-09-09 22:22:46 +02:00
parent 6f8cfd22fa
commit b8e25228f4
2 changed files with 26 additions and 23 deletions

View file

@ -85,8 +85,9 @@ void state_init(struct snapraid_state* state)
for(l=0;l<LEV_MAX;++l) {
state->parity_path[l][0] = 0;
state->parity_device[l] = 0;
state->tick[l] = 0;
state->tick_parity[l] = 0;
}
state->tick_io = 0;
state->tick_cpu = 0;
state->tick_last = tick();
state->share[0] = 0;
@ -4333,8 +4334,6 @@ int state_progress(struct snapraid_state* state, block_off_t blockpos, block_off
fflush(stdlog);
} else {
time_t now;
tommy_node* i;
unsigned l;
int pred;
now = time(0);
@ -4350,13 +4349,7 @@ int state_progress(struct snapraid_state* state, block_off_t blockpos, block_off
printf("%u%%, %u MiB", countpos * 100 / countmax, (unsigned)(countsize / (1024*1024)));
tick_total = state->tick_cpu;
for(i=state->disklist;i!=0;i=i->next) {
struct snapraid_disk* disk = i->data;
tick_total += disk->tick;
}
for(l=0;l<state->level;++l)
tick_total += state->tick[l];
tick_total = state->tick_cpu + state->tick_io;
if (tick_total != 0)
printf(", CPU %"PRIu64"%%", state->tick_cpu * 100U / tick_total);
@ -4457,9 +4450,9 @@ void state_usage_print(struct snapraid_state* state)
tick_max = disk->tick;
}
for(l=0;l<state->level;++l) {
tick_total += state->tick[l];
if (state->tick[l] > tick_max)
tick_max = state->tick[l];
tick_total += state->tick_parity[l];
if (state->tick_parity[l] > tick_max)
tick_max = state->tick_parity[l];
}
if (!tick_total)
@ -4478,11 +4471,11 @@ void state_usage_print(struct snapraid_state* state)
printf("Time for parity:");
for(l=0;l<state->level;++l) {
if (state->tick[l] == tick_max)
if (state->tick_parity[l] == tick_max)
printf(" %s:", lev_config_name(l));
else
printf(" ");
printf("%"PRIu64"%%", state->tick[l] * 100U / tick_total);
printf("%"PRIu64"%%", state->tick_parity[l] * 100U / tick_total);
}
printf("\n");
}

View file

@ -128,16 +128,21 @@ struct snapraid_state {
tommy_hashdyn previmportset; /**< Hashtable by prevhash of all the import blocks. Valid only if we are in a rehash state. */
tommy_arrayblkof infoarr; /**< Block information array. */
/**
* Cumulative time used for parity disks.
*/
uint64_t tick[LEV_MAX];
/**
* Cumulative time used for computations.
*/
uint64_t tick_cpu;
/**
* Cumulative time used for all io operations of disks.
*/
uint64_t tick_io;
/**
* Cumulative time used for parity disks.
*/
uint64_t tick_parity[LEV_MAX];
/**
* Last time used for time measure.
*/
@ -301,9 +306,10 @@ static inline void state_usage_waste(struct snapraid_state* state)
static inline void state_usage_cpu(struct snapraid_state* state)
{
uint64_t now = tick();
uint64_t delta = now - state->tick_last;
/* increment the time spent in computations */
state->tick_cpu += now - state->tick_last;
state->tick_cpu += delta;
state->tick_last = now;
}
@ -314,9 +320,11 @@ static inline void state_usage_cpu(struct snapraid_state* state)
static inline void state_usage_disk(struct snapraid_state* state, struct snapraid_disk* disk)
{
uint64_t now = tick();
uint64_t delta = now - state->tick_last;
/* increment the time spent in the data disk */
disk->tick += now - state->tick_last;
disk->tick += delta;
state->tick_io += delta;
state->tick_last = now;
}
@ -327,11 +335,13 @@ static inline void state_usage_disk(struct snapraid_state* state, struct snaprai
static inline void state_usage_parity(struct snapraid_state* state, unsigned level)
{
uint64_t now = tick();
uint64_t delta = now - state->tick_last;
assert(level < LEV_MAX);
/* increment the time spent in the parity disk */
state->tick[level] += now - state->tick_last;
state->tick_parity[level] += delta;
state->tick_io += delta;
state->tick_last = now;
}