Ejemplo n.º 1
0
 def plot_workmem_cpuutil(self, output):
     nrow = self.conn.execute("select count(*) from cpu").fetchone()[0]
     if not nrow: return
     gp = self.init_gnuplot()
     query = "select max(usr + sys + iowait + idle) from cpu"
     maxper = int(round(self.conn.execute(query).fetchone()[0], -2))
     gp('set output "{0}"'.format(output))
     gp.ylabel("CPU util [%]")
     gp('set yrange [0:{0}]'.format(maxper))
     gp('set key outside top')
     gp('set style fill pattern 1 border')
     query = ("select workmem, avg(usr) as usr, avg(sys) as sys, avg(iowait) as iowait, "
              "avg(irq) as irq, avg(soft) as soft, avg(idle) as idle "
              "from measurement, cpu "
              "where measurement.id = cpu.id "
              "group by workmem order by workmem")
     datas = query2data(self.conn, query)
     keys = ("workmem", "usr", "sys", "iowait", "irq", "soft", "idle")
     xlist = datas[0]
     piledatas = [np.array(datas[1])]
     for d in datas[2:]: piledatas.append(np.array(d) + piledatas[-1])
     piledatas = [d.tolist() for d in piledatas]
     gds = []
     widthlist = [v / 4 for v in xlist] if xlogplot else [2 ** 20 / 2 for v in xlist]
     for k, dat in zip(keys[:0:-1], piledatas[::-1]):
         gds.append(Gnuplot.Data(xlist, dat, widthlist,
                                 title = k,
                                 with_ = 'boxes fs solid border lc rgb "black"'))
     gp.plot(*gds)
     sys.stdout.write("output {0}\n".format(output))
     gp.close()
Ejemplo n.º 2
0
 def plot_workmem_cputime(self, output):
     nrow = self.conn.execute("select count(*) from cpu").fetchone()[0]
     if not nrow: return
     gp = self.init_gnuplot()
     query = "select max(usr + sys + iowait + idle + irq + soft) from cpu"
     maxper = int(round(self.conn.execute(query).fetchone()[0], -2))
     gp('set output "{0}"'.format(output))
     gp('set ylabel "Time [s]" offset 2')
     gp('set yrange [0:*]')
     gp('set key inside top right')
     gp('set style fill pattern 1 border')
     query = ("select workmem, avg(exectime) as exectime, "
              "avg(usr) / {maxper} as usr, avg(sys) / {maxper} as sys, "
              "avg(iowait) / {maxper} as iowait, "
              "avg(irq) / {maxper} as irq, avg(soft) / {maxper} as soft, "
              "avg(idle) / {maxper} as idle "
              "from measurement, cpu "
              "where measurement.id = cpu.id "
              "group by workmem order by workmem"
              .format(maxper = maxper))
     datas = query2data(self.conn, query)
     keys = ("workmem", "exectime", "usr", "sys", "iowait", "irq", "soft", "idle")
     colors = ("red", "dark-magenta", "light-blue", "green", "blue", "orange")
     xlist = datas[0]
     exectimes = np.array(datas[1])
     piledatas = [np.array(datas[2])]
     for d in datas[3:]: piledatas.append(np.array(d) + piledatas[-1])
     for d in piledatas: d *= exectimes
     piledatas = [d.tolist() for d in piledatas]
     with open("{0}/cputime.dat".format(os.path.dirname(output)), "w") as fo:
         for vals in zip(xlist, *piledatas[::-1]):
             fo.write("{0}\n".format('\t'.join([str(v) for v in vals])))
     gds = []
     widthlist = [v / 4 for v in xlist] if xlogplot else [2 ** 20 / 2 for v in xlist]
     gp('set xrange [{0}:*]'.format(xlist[0] - widthlist[0] / 2))
     for k, dat, color in zip(keys[:0:-1], piledatas[::-1], colors):
         gds.append(Gnuplot.Data(xlist, dat, widthlist,
                                 title = k,
                                 with_ = 'boxes lc rgb "{0}" fs solid border lc rgb "black"'.format(color)))
     # cache size line
     gds.append(Gnuplot.Data([24 * 2 ** 20] * 2, [0, 1400], with_ = 'lines lw 2 lc 8'))
     gp.plot(*gds)
     sys.stdout.write("output {0}\n".format(output))
     gp.close()
Ejemplo n.º 3
0
def draw_bucket(dbpath, terminaltype = "png"):
    conn = sqlite3.connect(dbpath)
    gp = gpinit(terminaltype)
    dirname = os.path.dirname(os.path.abspath(dbpath))
    output = "{0}/bucketscan.{1}".format(dirname, terminaltype)
    gp('set output "{0}"'.format(output))
    gp('set key inside left top')
    gp.xlabel("work\_mem [byte]")
    gp('set ylabel "# of bucket scan"')
    gp('set y2label "# of partition * # of bucket"')
    gp('set format x "%.0b%B"')
    gp('set logscale x 2')
    gp('set ytics nomirror')
    gp('set grid xtics noytics noy2tics')
    gp('set yrange[0:*]')
    y2max = conn.execute("select max(nbatch * nbucket) from bucketinfo").fetchone()[0]
    y2max = ceiltop(y2max)
    gp('set y2range[0:{0}]'.format(y2max))
    gp('set y2tics {0}'.format(y2max / 10))
    if slide:
        if "eps" == terminaltype:
            gp('set termoption font "Times-Roman,28"')
            plotprefdict = {"with_" : "points lt 1 lw 6" }
        elif "png" == terminaltype:
            gp('set termoption font "Times-Roman,18"')
            plotprefdict = {"with_" : "points lw 2"}
    else:
        plotprefdict = {"with_" : "points" }
    query = "select workmem, {0} from bucketinfo order by workmem"
    gds = []
    datalist = query2data(conn, query.format("sum"))
    gds.append(Gnuplot.Data(datalist[0], datalist[1], [v / 4 for v in datalist[0]],
                            title = "nbucketscan", axes = "x1y1",
                            with_ = 'boxes lc rgb "blue" fs solid border lc rgb "black"'))
    gds.extend(query2gds(conn, query.format("nbatch * nbucket"),
                         title = "npartition * nbucket", axes = "x1y2", **plotprefdict))
    gp.plot(*gds)
    sys.stdout.write("output {0}\n".format(output))
    gp.close()
    conn.close()
Ejemplo n.º 4
0
def plot_multicores_cputime(dbpaths, output, terminaltype = "png"):
    gp = Gnuplot.Gnuplot()
    if terminaltype == "png":
        settermcmd = 'set terminal png font "Times-Roman, 20" size 2880,810'
    elif terminaltype == "eps":
        settermcmd = 'set terminal postscript eps color "Times-Roman, 30"'
        gp('set size 2,1')
    else:
        sys.stdout.write("wrong terminal type\n")
        sys.exit(1)
    gp(settermcmd)
    gp('set output "{0}"'.format(output))
    gp('set style fill solid border lc rgb "black"')
    #gp('set boxwidth 0.1 relative')
    gp('set logscale x 2')
    #gp('set key inside top left')
    gp('set key outside width -3')
    gp('set xrange [{min}:{max}]'.format(min = 3 * (1 << 14), max = 3 * (1 << 28)))
    gp('set yrange [0:*]')
    gp('set xlabel "work\_mem [byte]" offset 0,0.3')
    gp('set ylabel "Time [s]" offset 2')
    if terminaltype == "png":
        gp('set label 1 "1    8   64" at 51000,-8')
    elif terminaltype == "eps":
        gp('set label 1 "1      8     64" at 50000,-10 font "Times-Roman,28"')
    gp('set label 1 font "Times-Roman, 14"')
    gp('set format x "%.0b%B"')
    gp('set grid')
    keys = ("workmem", "exectime", "usr", "sys", "iowait", "irq", "soft", "idle")
    colors = ("red", "dark-magenta", "light-blue", "green", "blue", "orange")
    gds = []
    numres = len(dbpaths)
    step = 0.12
    margin = numres / 2 - 0.5 if numres % 2 == 0 else numres / 2
    for i, dbpath in enumerate(dbpaths):
        conn = sqlite3.connect(dbpath)
        maxperquery = "select max(usr + sys + iowait + idle + irq + soft) from cpu"
        maxper = int(round(conn.execute(maxperquery).fetchone()[0], -2))
        query = ("select workmem, avg(exectime) as exectime, "
                 "avg(usr) / {maxper} as usr, avg(sys) / {maxper} as sys, "
                 "avg(iowait) / {maxper} as iowait, "
                 "avg(irq) / {maxper} as irq, avg(soft) / {maxper} as soft, "
                 "avg(idle) / {maxper} as idle "
                 "from measurement, cpu "
                 "where measurement.id = cpu.id "
                 "group by workmem order by workmem"
                 .format(maxper = maxper))
        datas = query2data(conn, query)
        conn.close()
        xlist = np.array(datas[0])
        xlist *= np.exp2(step * (i - margin))
        widthlist = [v / 20 for v in xlist]
        exectimes = np.array(datas[1])
        piledatas = [np.array(datas[2])]
        for d in datas[3:]: piledatas.append(np.array(d) + piledatas[-1])
        for d in piledatas: d *= exectimes
        piledatas = [d.tolist() for d in piledatas]
        if i == 0:
            for k, dat, color in zip(keys[:0:-1], piledatas[::-1], colors):
                gds.append(Gnuplot.Data(xlist, dat, widthlist,
                                        title = k,
                                        with_ = 'boxes lc rgb "{0}" lw 1'.format(color)))
        else:
            for k, dat, color in zip(keys[:0:-1], piledatas[::-1], colors):
                gds.append(Gnuplot.Data(xlist, dat, widthlist,
                                        with_ = 'boxes lc rgb "{0}" lw 1'.format(color)))
    gp.plot(*gds)
    sys.stdout.write("output {0}\n".format(output))
Ejemplo n.º 5
0
    else:
        sys.stdout.write("Usage : {0} dbpath [eps|png]\n".format(sys.argv[0]))
        sys.exit(1)

    if terminaltype != "png" and terminaltype != "eps":
        sys.stdout.write("wrong terminal type\n")
        sys.exit(1)

    conn = sqlite3.connect(dbpath)
    cols = ["elapsedtime", "mbps", "iops"]
    units = {"elapsed" : "(us)",
             "mbps" : "(MB/s)",
             "iops" : ""}
    tables = ["sequential_read", "random_read", "sequential_write", "random_write"]

    for i, col in enumerate(cols):
        gp = plotutil.gpinit(terminaltype)
        gp.xlabel("io size (B)")
        gp.ylabel("{0} {1}".format(col, units[col]))
        fpath = os.path.dirname(dbpath) + "/" + os.path.splitext(dbpath)[0].rsplit('_', 1)[1]
        figpath = "{0}_{1}.{2}".format(fpath, col, terminaltype)
        gp('set title "{0}"'.format(col))
        gp('set output "{0}"'.format(figpath))
        gp('set logscale x')
        if col == "mbps":
            gp('set key left top')
        query = "select iosize, {0} from {{table}}".format(col)
        gd = plotutil.query2data(conn, query, table = tables, with_ = "linespoints")
        gp.plot(*gd)
        gp.close()