Changeset: 935b134dccbf for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=935b134dccbf
Modified Files:
clients/mapiclient/tomograph.c
monetdb5/modules/kernel/algebra.mx
Branch: default
Log Message:
Merge with Feb2013 branch.
diffs (truncated from 466 to 300 lines):
diff --git a/clients/mapiclient/tomograph.c b/clients/mapiclient/tomograph.c
--- a/clients/mapiclient/tomograph.c
+++ b/clients/mapiclient/tomograph.c
@@ -134,6 +134,7 @@ static lng startrange = 0, endrange = 0;
static char *title = 0;
static int debug = 0;
static int colormap = 0;
+static int fixedmap=1;
static int beat = 50;
static char *sqlstatement = NULL;
static int batch = 1; /* number of queries to combine in one run */
@@ -158,7 +159,8 @@ usage(void)
fprintf(stderr, " -o | --output=<file prefix > (default
'tomograph'\n");
fprintf(stderr, " -b | --beat=<delay> in milliseconds (default 50)\n");
fprintf(stderr, " -B | --batch=<number> of combined queries\n");
- fprintf(stderr, " -m | --colormap produces colormap \n");
+ fprintf(stderr, " -a | --adaptive colormap \n");
+ fprintf(stderr, " -m | --colormap=<userdefined colormap>\n");
fprintf(stderr, " -D | --debug\n");
fprintf(stderr, " -? | --help\n");
}
@@ -467,6 +469,7 @@ dictionary[] = {
#define NUM_COLORS ((int) (sizeof(dictionary) / sizeof(RGB)))
#define MAX_LEGEND 30 /* max. size of colormap / legend */
+#define PERCENTAGE 0.01 /* threshold for time filter */
/* The initial dictionary is geared towars TPCH-use */
@@ -479,9 +482,84 @@ typedef struct COLOR {
Color
colors[NUM_COLORS] = {{0,0,0,0,0}};
+/*
+ * The fixed color scheme is designed to keep the legend
+ * consistent over multiple tomograms. Furthermore, groups
+ * of instructions are kept within the same color group.
+ * For less frequent or important operations, we re-use the color.
+ *
+ * The map design is initially based on the relative frequency
+ * of MAL instructions encountered in TPCH and those that
+ * take significant time.
+ *
+ * The built-in fixed color map can be over-ruled using a color
+ * map file, which consists of mod\tfcn\tcol lines using
+ * the color dictionary as a frame of reference.
+ *
+ * Use the adaptive scheme if you want distinct colors
+ * targeted for a single tomogram.
+ */
Color
fixed_colors[] = {
- /* reserve (fixed_)colors[0] for generic "*.*" */
+ { 0, 0, "aggr", "count", "darkgreen" },
+ { 0, 0, "aggr", "max", "lawngreen" },
+ { 0, 0, "aggr", "min", "lawngreen" },
+ { 0, 0, "aggr", "subcount", "darkgreen" },
+ { 0, 0, "aggr", "submin", "lawngreen" },
+ { 0, 0, "aggr", "submax", "lawngreen" },
+ { 0, 0, "aggr", "subsum", "lawngreen" },
+ { 0, 0, "aggr", "*", "green" },
+ { 0, 0, "algebra", "join", "navy" },
+ { 0, 0, "algebra", "leftfetchjoin", "lightblue" },
+ { 0, 0, "algebra", "leftfetchjoinPath", "lightcyan" },
+ { 0, 0, "algebra", "leftjoin", "blue" },
+ { 0, 0, "algebra", "likesubselect", "greenyellow" },
+ { 0, 0, "algebra", "selectNotNil", "lime" },
+ { 0, 0, "algebra", "subselect", "forestgreen" },
+ { 0, 0, "algebra", "subslice", "lightgreen" },
+ { 0, 0, "algebra", "subsort", "springgreen" },
+ { 0, 0, "algebra", "tdiff", "cyan" },
+ { 0, 0, "algebra", "thetajoin", "darkblue" },
+ { 0, 0, "algebra", "thetasubselect", "lightgreen" },
+ { 0, 0, "algebra", "tinter", "seagreen" },
+ { 0, 0, "algebra", "*", "lightgreen" },
+ { 0, 0, "batcalc", "dbl", "deeppink" },
+ { 0, 0, "batcalc", "lng", "deeppink" },
+ { 0, 0, "batcalc", "hash", "coral" },
+ { 0, 0, "batcalc", "ifthenelse", "plum" },
+ { 0, 0, "batcalc", "*", "lightyellow" },
+ { 0, 0, "bat", "append", "salmon" },
+ { 0, 0, "bat", "insert", "salmon" },
+ { 0, 0, "bat", "mergecand", "orange" },
+ { 0, 0, "bat", "mirror", "lightsalmon" },
+ { 0, 0, "bat", "*", "sandybrown" },
+ { 0, 0, "batmtime", "*", "lightpink" },
+ { 0, 0, "batstr", "*", "yellowgreen" },
+ { 0, 0, "group", "subgroup", "linen" },
+ { 0, 0, "group", "subgroupdone", "violet" },
+ { 0, 0, "group", "*", "orchid" },
+ { 0, 0, "io", "stdout", "gray" },
+ { 0, 0, "language", "dataflow", "lightgrey" },
+ { 0, 0, "language", "*", "lightslategray" },
+ { 0, 0, "mat", "pack", "darkred" },
+ { 0, 0, "mat", "packIncrement", "red" },
+ { 0, 0, "mat", "*", "indianred" },
+ { 0, 0, "mkey", "bulk_rotate_xor_hash", "sienna" },
+ { 0, 0, "pqueue", "*", "khaki" },
+ { 0, 0, "sql", "bind", "lavender" },
+ { 0, 0, "sql", "bind_idxbat", "lavenderblush" },
+ { 0, 0, "sql", "delta", "tan" },
+ { 0, 0, "sql", "projectdelta", "gold" },
+ { 0, 0, "sql", "subdelta", "goldenrod" },
+ { 0, 0, "sql", "tid", "thistle" },
+ { 0, 0, "sql", "*", "mistyrose" },
+ { 0, 0, "*", "*", "peachpuff" },
+ { 0, 0, 0, 0, 0 }
+};
+/* initial mod.fcn list for adaptive colormap */
+Color
+base_colors[] = {
+ /* reserve (base_)colors[0] for generic "*.*" */
{ 0, 0, "*", "*", 0 },
{ 0, 0, "aggr", "count", 0 },
{ 0, 0, "aggr", "max", 0 },
@@ -586,6 +664,15 @@ fixed_colors[] = {
{ 0, 0, 0, 0, 0 }
};
+static char *getRGB(char *name)
+{
+ int i;
+ for (i = 0; dictionary[i].name; i++)
+ if (strcmp(dictionary[i].name, name) == 0)
+ return dictionary[i].hsv;
+ return 0;
+}
+
static int cmp_clr ( const void * _one , const void * _two )
{
Color *one = (Color*) _one, *two = (Color*) _two;
@@ -610,22 +697,55 @@ static int cmp_clr ( const void * _one ,
int object = 1;
-static void initcolors(void)
+static void initcolors(FILE *map)
{
- int i;
- for (i = 0; i < NUM_COLORS && fixed_colors[i].mod; i++) {
- colors[i].mod = fixed_colors[i].mod;
- colors[i].fcn = fixed_colors[i].fcn;
- colors[i].freq = 0;
- colors[i].timeused = 0;
- colors[i].col = dictionary[i].hsv;
- }
- for (; i < NUM_COLORS; i++) {
- colors[i].mod = 0;
- colors[i].fcn = 0;
- colors[i].freq = 0;
- colors[i].timeused = 0;
- colors[i].col = dictionary[i].hsv;
+ int i = 0;
+ char *c;
+ char buf[3][128];
+
+ if ( map){
+ /* read the color map */
+ while ( fscanf(map,"%s\t%s\t%s\n", buf[0],buf[1],buf[2])== 3 &&
i< NUM_COLORS){
+ colors[i].mod = strdup(buf[0]);
+ colors[i].fcn = strdup(buf[1]);
+ colors[i].freq = 0;
+ colors[i].timeused = 0;
+ c = getRGB(buf[2]);
+ if (c)
+ colors[i].col = c;
+ else
+ fprintf(stderr, " %s.%s color '%s' not
found\n", buf[0],buf[1],buf[2]);
+ i++;
+ }
+
+ } else
+ if (fixedmap) {
+ for ( i = 0; fixed_colors[i].mod; i++){
+ colors[i].mod = fixed_colors[i].mod;
+ colors[i].fcn = fixed_colors[i].fcn;
+ colors[i].freq = 0;
+ colors[i].timeused = 0;
+ c = getRGB(fixed_colors[i].col);
+ if (c)
+ colors[i].col = c;
+ else
+ fprintf(stderr, "color '%s' not found\n",
fixed_colors[i].col);
+ }
+ } else {
+ for (i = 0; i < NUM_COLORS && base_colors[i].mod; i++) {
+ colors[i].mod = base_colors[i].mod;
+ colors[i].fcn = base_colors[i].fcn;
+ colors[i].freq = 0;
+ colors[i].timeused = 0;
+ colors[i].col = dictionary[i].hsv;
+ }
+ for (; i < NUM_COLORS; i++) {
+ colors[i].mod = 0;
+ colors[i].fcn = 0;
+ colors[i].freq = 0;
+ colors[i].timeused = 0;
+ colors[i].col = dictionary[i].hsv;
+ }
}
}
@@ -912,44 +1032,78 @@ static void showcolormap(char *filename,
fprintf(f, "unset title\n");
fprintf(f, "unset ylabel\n");
}
- /* create copy of colormap and sort in ascending order of timeused;
- * "*.*" stays first (colors[0]) */
- _clrs_ = (Color*) malloc (sizeof(colors));
- if (_clrs_) {
- memcpy (_clrs_, colors, sizeof(colors));
- qsort (_clrs_, NUM_COLORS, sizeof(Color), cmp_clr);
- clrs = _clrs_;
- }
- /* show colormap / legend in descending order of timeused;
- * show max. the MAX_LEGEND-1 most expensive function calls;
- * show all remaining aggregated as "*.*" */
- for (i = NUM_COLORS - 1; i >= 0; i--)
- if (clrs[i].mod && (clrs[i].freq > 0 || all)) {
- if (all || k < MAX_LEGEND - 1 || i == 0) {
- tottime += clrs[i].timeused;
- totfreq += clrs[i].freq;
+ if ( !fixedmap ){
+ /* create copy of colormap and sort in ascending order of
timeused;
+ * "*.*" stays first (colors[0]) */
+ _clrs_ = (Color*) malloc (sizeof(colors));
+ if (_clrs_) {
+ memcpy (_clrs_, colors, sizeof(colors));
+ qsort (_clrs_, NUM_COLORS, sizeof(Color), cmp_clr);
+ clrs = _clrs_;
+ }
+ /* show colormap / legend in descending order of timeused;
+ * show max. the MAX_LEGEND-1 most expensive function calls;
+ * show all remaining aggregated as "*.*" */
+ for (i = NUM_COLORS - 1; i >= 0; i--)
+ if (clrs[i].mod && (clrs[i].freq > 0 || all)) {
+ if (all || k < MAX_LEGEND - 1 || i == 0) {
+ tottime += clrs[i].timeused;
+ totfreq += clrs[i].freq;
+ if (k % 3 == 0)
+ h -= 45;
+ fprintf(f, "set object %d rectangle
from %f, %f to %f, %f fillcolor rgb \"%s\" fillstyle solid 0.6\n",
+ object++, (double) (k %
3) * w, (double) h - 40, (double) ((k % 3) * w + 0.15 * w), (double) h - 5,
clrs[i].col);
+ fprintf(f, "set label %d \"%s.%s \" at
%d,%d\n",
+ object++, clrs[i].mod,
clrs[i].fcn, (int) ((k % 3) * w + 0.2 * w), h - 15);
+ fprintf(f, "set label %d \"%d calls: ",
+ object++, clrs[i].freq);
+ fprintf_time(f, clrs[i].timeused);
+ fprintf(f, "\" at %f,%f\n",
+ (double) ((k % 3) * w +
0.2 * w), (double) h - 35);
+ k++;
+ } else {
+ clrs[0].timeused += clrs[i].timeused;
+ clrs[0].freq += clrs[i].freq;
+ }
+ }
+ if (_clrs_) {
+ clrs = colors;
+ free(_clrs_);
+ _clrs_ = NULL;
+ }
+ } else {
+ /* use a heuristic fixed map to highlight the important
operations */
+ /* limit the legend to the most important ones <MAX_LEGEND and
> 1% */
+ int map[MAX_LEGEND], n, j ;
+ for (j =0; j < MAX_LEGEND; j++)
+ map[j] = 0;
+ for (i = 0; i < NUM_COLORS - 1; i++) {
+ tottime += clrs[i].timeused;
+ totfreq += clrs[i].freq;
+ for ( j = 0; j < MAX_LEGEND && clrs[map[j]].timeused >
clrs[i].timeused; j++)
+ ;
+ if ( j < MAX_LEGEND){
+ for( n = MAX_LEGEND-1; n > j; n--)
+ map[n] = map[n-1];
+ map[j] = i;
+ }
+ }
+ for (i = 0; i < MAX_LEGEND; i++)
+ if (clrs[map[i]].mod && ((clrs[map[i]].freq > 0 &&
(clrs[map[i]].timeused > PERCENTAGE * tottime || clrs[map[i]].freq > PERCENTAGE
* totfreq)) || all) ){
if (k % 3 == 0)
h -= 45;
fprintf(f, "set object %d rectangle from %f, %f
to %f, %f fillcolor rgb \"%s\" fillstyle solid 0.6\n",
- object++, (double) (k % 3) * w,
(double) h - 40, (double) ((k % 3) * w + 0.15 * w), (double) h - 5,
clrs[i].col);
+ object++, (double) (k % 3) * w,
(double) h - 40, (double) ((k % 3) * w + 0.15 * w), (double) h - 5,
clrs[map[i]].col);
fprintf(f, "set label %d \"%s.%s \" at %d,%d\n",
- object++, clrs[i].mod,
clrs[i].fcn, (int) ((k % 3) * w + 0.2 * w), h - 15);
+ object++, clrs[map[i]].mod,
clrs[map[i]].fcn, (int) ((k % 3) * w + 0.2 * w), h - 15);
fprintf(f, "set label %d \"%d calls: ",
- object++, clrs[i].freq);
- fprintf_time(f, clrs[i].timeused);
+ object++, clrs[map[i]].freq);
+ fprintf_time(f, clrs[map[i]].timeused);
fprintf(f, "\" at %f,%f\n",
(double) ((k % 3) * w + 0.2 *
w), (double) h - 35);
k++;
- } else {
- clrs[0].timeused += clrs[i].timeused;
- clrs[0].freq += clrs[i].freq;
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list