Add time stats also for thread scheduling

This commit is contained in:
Andrea Mazzoleni 2016-01-31 16:38:29 +01:00
parent c1993e0abb
commit 4a418e158a
5 changed files with 34 additions and 0 deletions

View file

@ -217,6 +217,9 @@ static int state_dry_process(struct snapraid_state* state, struct snapraid_parit
if (blockcur >= blockmax)
break;
/* until now is scheduling */
state_usage_sched(state);
/* for each disk, process the block */
for (j = 0; j < diskmax; ++j) {
struct snapraid_task* task;

View file

@ -329,6 +329,9 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par
if (blockcur >= blockmax)
break;
/* until now is scheduling */
state_usage_sched(state);
/* one more block processed for autosave */
++autosavedone;
--autosavemissing;

View file

@ -162,6 +162,7 @@ void state_init(struct snapraid_state* state)
}
state->tick_io = 0;
state->tick_misc = 0;
state->tick_sched = 0;
state->tick_raid = 0;
state->tick_hash = 0;
state->tick_last = tick();
@ -3917,6 +3918,7 @@ static void state_progress_latest(struct snapraid_state* state)
unsigned l;
state->progress_tick_misc[state->progress_ptr] = state->tick_misc;
state->progress_tick_sched[state->progress_ptr] = state->tick_sched;
state->progress_tick_raid[state->progress_ptr] = state->tick_raid;
state->progress_tick_hash[state->progress_ptr] = state->tick_hash;
state->progress_tick_io[state->progress_ptr] = state->tick_io;
@ -3950,6 +3952,7 @@ static void state_progress_graph(struct snapraid_state* state, struct snapraid_i
tick_total = 0;
tick_total += state->progress_tick_misc[current] - ref(state->progress_tick_misc, oldest);
tick_total += state->progress_tick_sched[current] - ref(state->progress_tick_sched, oldest);
tick_total += state->progress_tick_raid[current] - ref(state->progress_tick_raid, oldest);
tick_total += state->progress_tick_hash[current] - ref(state->progress_tick_hash, oldest);
tick_total += state->progress_tick_io[current] - ref(state->progress_tick_io, oldest);
@ -4043,6 +4046,12 @@ static void state_progress_graph(struct snapraid_state* state, struct snapraid_i
printc('*', v * bar / tick_total);
printf("\n");
v = state->progress_tick_sched[current] - ref(state->progress_tick_sched, oldest);
printr("sched", pad);
printf("%3" PRIu64 "%% | ", v * 100 / tick_total);
printc('*', v * bar / tick_total);
printf("\n");
v = state->progress_tick_misc[current] - ref(state->progress_tick_misc, oldest);
printr("misc", pad);
printf("%3" PRIu64 "%% | ", v * 100 / tick_total);
@ -4140,11 +4149,13 @@ int state_progress(struct snapraid_state* state, struct snapraid_io* io, block_o
oldest -= PROGRESS_MAX;
tick_cpu = state->progress_tick_misc[state->progress_ptr]
+ state->progress_tick_sched[state->progress_ptr]
+ state->progress_tick_raid[state->progress_ptr]
+ state->progress_tick_hash[state->progress_ptr];
tick_total = tick_cpu + state->progress_tick_io[state->progress_ptr];
oldest_tick_cpu = state->progress_tick_misc[oldest]
+ state->progress_tick_sched[oldest]
+ state->progress_tick_raid[oldest]
+ state->progress_tick_hash[oldest];
oldest_tick_total = oldest_tick_cpu + state->progress_tick_io[oldest];
@ -4230,6 +4241,17 @@ void state_usage_misc(struct snapraid_state* state)
state->tick_last = now;
}
void state_usage_sched(struct snapraid_state* state)
{
uint64_t now = tick();
uint64_t delta = now - state->tick_last;
/* increment the time spent in computations */
state->tick_sched += delta;
state->tick_last = now;
}
void state_usage_raid(struct snapraid_state* state)
{
uint64_t now = tick();

View file

@ -156,6 +156,7 @@ struct snapraid_state {
* Cumulative time used for computations.
*/
uint64_t tick_misc;
uint64_t tick_sched;
uint64_t tick_raid;
uint64_t tick_hash;
@ -179,6 +180,7 @@ struct snapraid_state {
block_off_t progress_pos[PROGRESS_MAX]; /**< Last positions of progress. */
data_off_t progress_size[PROGRESS_MAX]; /**< Last sizes of progress. */
uint64_t progress_tick_misc[PROGRESS_MAX]; /**< Last cpu ticks of progress. */
uint64_t progress_tick_sched[PROGRESS_MAX]; /**< Last scheduling ticks of progress. */
uint64_t progress_tick_raid[PROGRESS_MAX]; /**< Last raid ticks of progress. */
uint64_t progress_tick_hash[PROGRESS_MAX]; /**< Last hash ticks of progress. */
uint64_t progress_tick_io[PROGRESS_MAX]; /**< Last io ticks of progress. */
@ -342,6 +344,7 @@ void state_usage_waste(struct snapraid_state* state);
* Set the usage time for CPU.
*/
void state_usage_misc(struct snapraid_state* state);
void state_usage_sched(struct snapraid_state* state);
void state_usage_raid(struct snapraid_state* state);
void state_usage_hash(struct snapraid_state* state);

View file

@ -772,6 +772,9 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
if (blockcur >= blockmax)
break;
/* until now is scheduling */
state_usage_sched(state);
/* one more block processed for autosave */
++autosavedone;
--autosavemissing;