summaryrefslogtreecommitdiff
path: root/src/charts.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/charts.c')
-rw-r--r--src/charts.c58
1 files changed, 44 insertions, 14 deletions
diff --git a/src/charts.c b/src/charts.c
index 1040d45..aeacb18 100644
--- a/src/charts.c
+++ b/src/charts.c
@@ -67,7 +67,7 @@ typedef struct _vwm_charts_t {
float prev_sampling_interval_secs, sampling_interval_secs;
int sampling_paused, contiguous_drops, primed;
unsigned marker_distance;
- float inv_ticks_per_sec, inv_total_delta;
+ double inv_ticks_per_sec, inv_total_delta;
unsigned defer_maintenance:1;
unsigned no_threads:1;
} vwm_charts_t;
@@ -197,7 +197,7 @@ static void sample_callback(vmon_t *vmon, void *arg)
sys_stat->softirq + sys_stat->steal + sys_stat->guest;
charts->total_delta = charts->this_total - charts->last_total;
- charts->inv_total_delta = 1.f / (float)charts->total_delta;
+ charts->inv_total_delta = 1.0 / (double)charts->total_delta;
charts->idle_delta = sys_stat->idle - charts->last_idle;
charts->iowait_delta = sys_stat->iowait - charts->last_iowait;
charts->irq_delta = sys_stat->irq - charts->last_irq;
@@ -287,6 +287,7 @@ static void snowflake_row(vwm_charts_t *charts, vwm_chart_t *chart, int row)
/* stash the graph rows */
vcr_stash_row(chart->vcr, VCR_LAYER_GRAPHA, row);
vcr_stash_row(chart->vcr, VCR_LAYER_GRAPHB, row);
+ vcr_stash_row(chart->vcr, VCR_LAYER_META, row);
/* shift _all_ the layers up by 1 row */
vcr_shift_below_row_up_one(chart->vcr, row);
@@ -294,6 +295,7 @@ static void snowflake_row(vwm_charts_t *charts, vwm_chart_t *chart, int row)
/* unstash the graph rows @ hierarchy end so we have them in the snowflakes */
vcr_unstash_row(chart->vcr, VCR_LAYER_GRAPHA, chart->hierarchy_end);
vcr_unstash_row(chart->vcr, VCR_LAYER_GRAPHB, chart->hierarchy_end);
+ vcr_unstash_row(chart->vcr, VCR_LAYER_META, chart->hierarchy_end);
/* clear the others @ hierarchy end, new argv will get stamped over it */
vcr_clear_row(chart->vcr, VCR_LAYER_TEXT, chart->hierarchy_end, -1, -1);
@@ -319,6 +321,7 @@ static void allocate_row(vwm_charts_t *charts, vwm_chart_t *chart, int row)
vcr_clear_row(chart->vcr, VCR_LAYER_GRAPHB, row, -1, -1);
vcr_clear_row(chart->vcr, VCR_LAYER_TEXT, row, -1, -1);
vcr_clear_row(chart->vcr, VCR_LAYER_SHADOW, row, -1, -1);
+ vcr_clear_row(chart->vcr, VCR_LAYER_META, row, -1, -1);
}
@@ -411,18 +414,35 @@ static int proc_hierarchy_changed(vmon_proc_t *proc)
/* helper for drawing the vertical bars in the graph layers */
-static void draw_bars(vwm_charts_t *charts, vwm_chart_t *chart, int row, float mult, float a_fraction, float inv_a_total, vcr_layer_t a_layer, float b_fraction, float inv_b_total, vcr_layer_t b_layer)
+static void draw_bars(vwm_charts_t *charts, vwm_chart_t *chart, int row, float mult, float a_fraction, double inv_a_total, vcr_layer_t a_layer, float b_fraction, double inv_b_total, vcr_layer_t b_layer)
{
+ int a_height, b_height;
float a_t, b_t;
+//#error "the *ncpus scaling done in floating point seems to often result in enough rounding error to produce 1-pixel overlap of utime and stime bars where they really shouldn't exist"
/* compute the bar %ages for this sample */
a_t = a_fraction * inv_a_total * mult;
+ if (a_t > 1.f)
+ a_t = 1.f;
+
b_t = b_fraction * inv_b_total * mult;
+ if (b_t > 1.f)
+ b_t = 1.f;
+
+ a_height = a_t * (float)(VCR_ROW_HEIGHT - 1);
+ if (a_height == 0 && a_fraction != 0.f)
+ a_height = 1;
+ b_height = b_t * (float)(VCR_ROW_HEIGHT - 1);
+ if (b_height == 0 && b_fraction != 0.f)
+ b_height = 1;
+
+ //fprintf(stderr, "a_t=%f a_h=%i b_t=%f b_h=%i\n",
+ // a_t, a_height, b_t, b_height);
/* ensure at least 1 pixel when the scaled result is a fraction less than 1,
* I want to at least see 1 pixel blips for the slightest cpu utilization */
- vcr_draw_bar(chart->vcr, a_layer, row, a_t, a_fraction != 0 ? 1 : 0 /* min_height */);
- vcr_draw_bar(chart->vcr, b_layer, row, b_t, b_fraction != 0 ? 1 : 0 /* min_height */);
+ vcr_draw_bar(chart->vcr, a_layer, VCR_BAR_BASE_TOP, row, a_height);
+ vcr_draw_bar(chart->vcr, b_layer, VCR_BAR_BASE_BOTTOM, row, b_height);
}
@@ -1116,6 +1136,7 @@ static void draw_chart_rest(vwm_charts_t *charts, vwm_chart_t *chart, vmon_proc_
if (!proc->is_thread) { /* per-proc RSS row */
allocate_row(charts, chart, (*row) + 1);
+ vcr_set_row_palette(chart->vcr, (*row) + 1, VCR_ROW_PALETTE_1);
chart->hierarchy_end++;
}
@@ -1129,7 +1150,7 @@ static void draw_chart_rest(vwm_charts_t *charts, vwm_chart_t *chart, vmon_proc_
draw_bars(charts, chart, *row,
(proc->is_thread || !proc->is_threaded) ? charts->vmon.num_cpus : 1.f /* mult */,
- -stime_delta,
+ stime_delta,
charts->inv_total_delta,
VCR_LAYER_GRAPHA,
utime_delta,
@@ -1137,15 +1158,24 @@ static void draw_chart_rest(vwm_charts_t *charts, vwm_chart_t *chart, vmon_proc_
VCR_LAYER_GRAPHB);
if (!proc->is_thread) {
- if (proc_ctxt->rss != proc_ctxt->prev_rss) {
+ if (proc->is_new) {
+ draw_bars(charts, chart, *row + 1,
+ 1.f /* mult */,
+ 1.f,
+ 1.f,
+ VCR_LAYER_GRAPHB,
+ 1.f,
+ 1.f,
+ VCR_LAYER_GRAPHA);
+ } else if (proc_ctxt->rss != proc_ctxt->prev_rss) {
// fprintf(stderr, "row=%i rss_delta=%i rss=%llu\n", (*row) + 1, proc_ctxt->rss_log2_delta, proc_ctxt->rss);
draw_bars(charts, chart, *row + 1,
1.f /* mult */,
- proc_ctxt->rss_log2_delta < 0.f ? proc_ctxt->rss_log2_delta : 0.f,
- 1.f / (VCR_ROW_HEIGHT - 1),
+ proc_ctxt->rss_log2_delta < 0 ? -proc_ctxt->rss_log2_delta : 0.f,
+ 1.f / VCR_ROW_HEIGHT,
VCR_LAYER_GRAPHB,
- proc_ctxt->rss_log2_delta > 0.f ? proc_ctxt->rss_log2_delta : 0.f,
- 1.f / (VCR_ROW_HEIGHT - 1),
+ proc_ctxt->rss_log2_delta > 0 ? proc_ctxt->rss_log2_delta : 0.f,
+ 1.f / VCR_ROW_HEIGHT,
VCR_LAYER_GRAPHA);
}
}
@@ -1187,7 +1217,7 @@ static void draw_chart(vwm_charts_t *charts, vwm_chart_t *chart, vmon_proc_t *pr
/* IOWait and Idle % @ row 0 */
draw_bars(charts, chart, row,
1.f /* mult */,
- -charts->iowait_delta,
+ charts->iowait_delta,
charts->inv_total_delta,
VCR_LAYER_GRAPHA,
charts->idle_delta,
@@ -1197,7 +1227,7 @@ static void draw_chart(vwm_charts_t *charts, vwm_chart_t *chart, vmon_proc_t *pr
/* IRQ and SoftIRQ % @ row 1 */
draw_bars(charts, chart, row + 1,
1.f /* mult */,
- -charts->irq_delta,
+ charts->irq_delta,
charts->inv_total_delta,
VCR_LAYER_GRAPHA,
charts->softirq_delta,
@@ -1207,7 +1237,7 @@ static void draw_chart(vwm_charts_t *charts, vwm_chart_t *chart, vmon_proc_t *pr
/* "Adherence" @ row 2 */
draw_bars(charts, chart, row + 2,
1.f /* mult */,
- charts->this_sample_adherence > 0.f ? -charts->this_sample_adherence : 0.f /* a_fraction */,
+ charts->this_sample_adherence > 0.f ? charts->this_sample_adherence : 0.f /* a_fraction */,
1.f /* inv_a_total */,
VCR_LAYER_GRAPHA,
charts->this_sample_adherence < 0.f ? -charts->this_sample_adherence : 0.f /* b_fraction */,
© All Rights Reserved