Changeset: b1e51c236e7e for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b1e51c236e7e
Modified Files:
clients/mapiclient/tomograph.c
Branch: Feb2013
Log Message:
Re-establish fixed color map heuristics
A 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 user
defined 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 to leave colorpicking to
the code itself.
diffs (truncated from 498 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
@@ -133,7 +133,8 @@ static char *tracefile = 0;
static lng startrange = 0, endrange = 0;
static char *title = 0;
static int debug = 0;
-static int colormap = 1;
+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,113 +482,90 @@ 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, "*", "*", 0 },
- { 0, 0, "aggr", "count", 0 },
- { 0, 0, "aggr", "max", 0 },
- { 0, 0, "aggr", "subcount", 0 },
- { 0, 0, "aggr", "submin", 0 },
- { 0, 0, "aggr", "subsum", 0 },
- { 0, 0, "aggr", "sum", 0 },
- { 0, 0, "algebra", "fetch", 0 },
- { 0, 0, "algebra", "join", 0 },
- { 0, 0, "algebra", "leftfetchjoin", 0 },
- { 0, 0, "algebra", "leftfetchjoinPath", 0 },
- { 0, 0, "algebra", "leftjoin", 0 },
- { 0, 0, "algebra", "likesubselect", 0 },
- { 0, 0, "algebra", "project", 0 },
- { 0, 0, "algebra", "selectNotNil", 0 },
- { 0, 0, "algebra", "subselect", 0 },
- { 0, 0, "algebra", "subslice", 0 },
- { 0, 0, "algebra", "subsort", 0 },
- { 0, 0, "algebra", "tdiff", 0 },
- { 0, 0, "algebra", "thetajoin", 0 },
- { 0, 0, "algebra", "thetasubselect", 0 },
- { 0, 0, "algebra", "tinter", 0 },
- { 0, 0, "bat", "append", 0 },
- { 0, 0, "batcalc", "<", 0 },
- { 0, 0, "batcalc", "==", 0 },
- { 0, 0, "batcalc", ">", 0 },
- { 0, 0, "batcalc", "-", 0 },
- { 0, 0, "batcalc", "!=", 0 },
- { 0, 0, "batcalc", "/", 0 },
- { 0, 0, "batcalc", "*", 0 },
- { 0, 0, "batcalc", "+", 0 },
- { 0, 0, "batcalc", "and", 0 },
- { 0, 0, "batcalc", "dbl", 0 },
- { 0, 0, "batcalc", "hash", 0 },
- { 0, 0, "batcalc", "ifthenelse", 0 },
- { 0, 0, "batcalc", "isnil", 0 },
- { 0, 0, "batcalc", "lng", 0 },
- { 0, 0, "batcalc", "or", 0 },
- { 0, 0, "bat", "insert", 0 },
- { 0, 0, "bat", "mergecand", 0 },
- { 0, 0, "bat", "mirror", 0 },
- { 0, 0, "batmtime", "year", 0 },
- { 0, 0, "bat", "new", 0 },
- { 0, 0, "bat", "reverse", 0 },
- { 0, 0, "batstr", "like", 0 },
- { 0, 0, "batstr", "substring", 0 },
- { 0, 0, "calc", "==", 0 },
- { 0, 0, "calc", "-", 0 },
- { 0, 0, "calc", "!=", 0 },
- { 0, 0, "calc", "/", 0 },
- { 0, 0, "calc", "*", 0 },
- { 0, 0, "calc", "+", 0 },
- { 0, 0, "calc", "bit", 0 },
- { 0, 0, "calc", "date", 0 },
- { 0, 0, "calc", "dbl", 0 },
- { 0, 0, "calc", "ifthenelse", 0 },
- { 0, 0, "calc", "int", 0 },
- { 0, 0, "calc", "isnil", 0 },
- { 0, 0, "calc", "lng", 0 },
- { 0, 0, "calc", "max", 0 },
- { 0, 0, "calc", "min", 0 },
- { 0, 0, "calc", "ptr", 0 },
- { 0, 0, "calc", "str", 0 },
- { 0, 0, "calc", "wrd", 0 },
- { 0, 0, "group", "subgroup", 0 },
- { 0, 0, "group", "subgroupdone", 0 },
- { 0, 0, "io", "stdout", 0 },
- { 0, 0, "iterator", "new", 0 },
- { 0, 0, "iterator", "next", 0 },
- { 0, 0, "language", "dataflow", 0 },
- { 0, 0, "language", "pass", 0 },
- { 0, 0, "mat", "pack", 0 },
- { 0, 0, "mat", "packIncrement", 0 },
- { 0, 0, "mkey", "bulk_rotate_xor_hash", 0 },
- { 0, 0, "mtime", "addmonths", 0 },
- { 0, 0, "mtime", "date_sub_msec_interval", 0 },
- { 0, 0, "pqueue", "topn_max", 0 },
- { 0, 0, "pqueue", "topn_min", 0 },
- { 0, 0, "pqueue", "utopn_max", 0 },
- { 0, 0, "pqueue", "utopn_min", 0 },
- { 0, 0, "profiler", "ping", 0 },
- { 0, 0, "profiler", "wait", 0 },
- { 0, 0, "sql", "affectedRows", 0 },
- { 0, 0, "sql", "assert", 0 },
- { 0, 0, "sql", "bind", 0 },
- { 0, 0, "sql", "bind_idxbat", 0 },
- { 0, 0, "sql", "catalog", 0 },
- { 0, 0, "sql", "copy_from", 0 },
- { 0, 0, "sql", "dec_round", 0 },
- { 0, 0, "sql", "delta", 0 },
- { 0, 0, "sql", "exportOperation", 0 },
- { 0, 0, "sql", "exportResult", 0 },
- { 0, 0, "sql", "exportValue", 0 },
- { 0, 0, "sql", "mvc", 0 },
- { 0, 0, "sql", "projectdelta", 0 },
- { 0, 0, "sql", "resultSet", 0 },
- { 0, 0, "sql", "rsColumn", 0 },
- { 0, 0, "sql", "setVariable", 0 },
- { 0, 0, "sql", "subdelta", 0 },
- { 0, 0, "sql", "tid", 0 },
- { 0, 0, "sql", "update", 0 },
+ { 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 }
};
+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 +590,56 @@ 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;
+ 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 {
+ /* use fixed assignment of colors */
+ 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;
+ }
}
}
@@ -914,42 +928,76 @@ static void showcolormap(char *filename,
}
/* create copy of colormap and sort in ascending order of timeused;
* "*.*" stays first (colors[0]) */
- _clrs_ = (Color*) malloc (sizeof(colors));
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list