mirror of
https://github.com/amadvance/snapraid.git
synced 2026-11-25 09:26:27 -05:00
Updates the CPU usage using the last 100 seconds data.
This commit is contained in:
parent
b8e25228f4
commit
0b372da80e
3 changed files with 16 additions and 5 deletions
2
HISTORY
2
HISTORY
|
|
@ -4,7 +4,7 @@ SnapRAID HISTORY
|
||||||
6.4 2014/9
|
6.4 2014/9
|
||||||
==========
|
==========
|
||||||
* Keeps and print the time spent waiting for each disk also in 'scrub'.
|
* Keeps and print the time spent waiting for each disk also in 'scrub'.
|
||||||
* The speed and ETA estimations are now based on the last 100
|
* The CPU usage, speed and ETA estimations are now based on the last 100
|
||||||
seconds rather than from the start.
|
seconds rather than from the start.
|
||||||
|
|
||||||
6.3 2014/7
|
6.3 2014/7
|
||||||
|
|
|
||||||
|
|
@ -4346,12 +4346,12 @@ int state_progress(struct snapraid_state* state, block_off_t blockpos, block_off
|
||||||
/* if the previous measure is different */
|
/* if the previous measure is different */
|
||||||
if (state->progress_tick == 0 || state->progress_time[pred] != now) {
|
if (state->progress_tick == 0 || state->progress_time[pred] != now) {
|
||||||
uint64_t tick_total;
|
uint64_t tick_total;
|
||||||
|
uint64_t tick_cpu;
|
||||||
printf("%u%%, %u MiB", countpos * 100 / countmax, (unsigned)(countsize / (1024*1024)));
|
|
||||||
|
|
||||||
tick_total = state->tick_cpu + state->tick_io;
|
tick_total = state->tick_cpu + state->tick_io;
|
||||||
if (tick_total != 0)
|
tick_cpu = state->tick_cpu;
|
||||||
printf(", CPU %"PRIu64"%%", state->tick_cpu * 100U / tick_total);
|
|
||||||
|
printf("%u%%, %u MiB", countpos * 100 / countmax, (unsigned)(countsize / (1024*1024)));
|
||||||
|
|
||||||
/* if we have at least 5 measures */
|
/* if we have at least 5 measures */
|
||||||
if (state->progress_tick >= 5) {
|
if (state->progress_tick >= 5) {
|
||||||
|
|
@ -4360,6 +4360,8 @@ int state_progress(struct snapraid_state* state, block_off_t blockpos, block_off
|
||||||
time_t delta_time;
|
time_t delta_time;
|
||||||
block_off_t delta_pos;
|
block_off_t delta_pos;
|
||||||
data_off_t delta_size;
|
data_off_t delta_size;
|
||||||
|
uint64_t delta_tick_total;
|
||||||
|
uint64_t delta_tick_cpu;
|
||||||
|
|
||||||
/* number of past measures */
|
/* number of past measures */
|
||||||
past = state->progress_tick;
|
past = state->progress_tick;
|
||||||
|
|
@ -4383,10 +4385,15 @@ int state_progress(struct snapraid_state* state, block_off_t blockpos, block_off
|
||||||
delta_time = now - state->progress_time[oldest];
|
delta_time = now - state->progress_time[oldest];
|
||||||
delta_pos = countpos - state->progress_pos[oldest];
|
delta_pos = countpos - state->progress_pos[oldest];
|
||||||
delta_size = countsize - state->progress_size[oldest];
|
delta_size = countsize - state->progress_size[oldest];
|
||||||
|
delta_tick_total = tick_total - state->progress_tick_total[oldest];
|
||||||
|
delta_tick_cpu = tick_cpu - state->progress_tick_cpu[oldest];
|
||||||
|
|
||||||
if (delta_time != 0)
|
if (delta_time != 0)
|
||||||
printf(", %u MiB/s", (unsigned)(delta_size / (1024*1024) / delta_time));
|
printf(", %u MiB/s", (unsigned)(delta_size / (1024*1024) / delta_time));
|
||||||
|
|
||||||
|
if (delta_tick_total != 0)
|
||||||
|
printf(", CPU %"PRIu64"%%", delta_tick_cpu * 100U / delta_tick_total);
|
||||||
|
|
||||||
/* estimate the remaining time */
|
/* estimate the remaining time */
|
||||||
if (delta_pos != 0) {
|
if (delta_pos != 0) {
|
||||||
unsigned m, h;
|
unsigned m, h;
|
||||||
|
|
@ -4407,6 +4414,8 @@ int state_progress(struct snapraid_state* state, block_off_t blockpos, block_off
|
||||||
state->progress_time[state->progress_ptr] = now;
|
state->progress_time[state->progress_ptr] = now;
|
||||||
state->progress_pos[state->progress_ptr] = countpos;
|
state->progress_pos[state->progress_ptr] = countpos;
|
||||||
state->progress_size[state->progress_ptr] = countsize;
|
state->progress_size[state->progress_ptr] = countsize;
|
||||||
|
state->progress_tick_cpu[state->progress_ptr] = tick_cpu;
|
||||||
|
state->progress_tick_total[state->progress_ptr] = tick_total;
|
||||||
|
|
||||||
/* next position */
|
/* next position */
|
||||||
++state->progress_ptr;
|
++state->progress_ptr;
|
||||||
|
|
|
||||||
|
|
@ -171,6 +171,8 @@ struct snapraid_state {
|
||||||
time_t progress_time[PROGRESS_MAX]; /**< Last times of progress. */
|
time_t progress_time[PROGRESS_MAX]; /**< Last times of progress. */
|
||||||
block_off_t progress_pos[PROGRESS_MAX]; /**< Last positions of progress. */
|
block_off_t progress_pos[PROGRESS_MAX]; /**< Last positions of progress. */
|
||||||
data_off_t progress_size[PROGRESS_MAX]; /**< Last sizes of progress. */
|
data_off_t progress_size[PROGRESS_MAX]; /**< Last sizes of progress. */
|
||||||
|
uint64_t progress_tick_cpu[PROGRESS_MAX]; /**< Last cpu ticks of progress. */
|
||||||
|
uint64_t progress_tick_total[PROGRESS_MAX]; /**< Last total ticks of progress. */
|
||||||
|
|
||||||
int progress_ptr; /**< Pointer to the next position to fill. Rolling over. */
|
int progress_ptr; /**< Pointer to the next position to fill. Rolling over. */
|
||||||
int progress_tick; /**< Number of measures done. */
|
int progress_tick; /**< Number of measures done. */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue