コード例 #1
0
def prepare_paper(path='logs/nsdi19'):
    path = Path(path)
    with plt.style.context(['seaborn-paper', 'mypaper', 'line12']):
        # also use color

        # fifo = ju.load_trace(path/'card266'/'salus'/'trace.csv')
        fifo = load_data(path / 'card272' / 'case0' / 'fifo', 'case0.output')

        srtf = load_data(path / 'card266' / 'salus', 'card266.output')
        srtf_refine = ju.load_refine(path / 'card266' / 'salus')

        fair = load_data(path / 'card272' / 'case2' / 'salus', 'case2.output')
        pack = load_data(path / 'card272' / 'case1' / 'salus', 'case1.output')

        fig, ax = plt.subplots()
        fig.set_size_inches(3.25, 1.5, forward=True)

        jcts = pd.DataFrame({
            'FIFO': fifo.JCT,
            'SRTF': srtf.JCT,
            'PACK': pack.JCT,
            'FAIR': fair.JCT
        })
        plot_jcts(jcts, ax=ax, markevery=0.1, markersize=4, linewidth=1)

        fig.tight_layout()
        fig.savefig('/tmp/workspace/card272-jct.pdf', dpi=300)
        plt.close()

    return fifo, srtf, srtf_refine, fair, pack
コード例 #2
0
def do_srtf2(path):
    srtf = load_data(path / 'card266' / 'salus', 'card266.output')
    srtf_refine = ju.load_refine(path / 'card266' / 'salus')

    offset_local = srtf.Queued.min()

    #srtf = ju.update_start_time_using_refine(srtf, srtf_refine, offset=offset_local)

    jnos = [34, 80, 82, 86, 93, 94]
    new_jnos = {n: i for i, n in enumerate(jnos)}
    st_sec = 2651
    ed_sec = 2910

    srtf = srtf[srtf.No.isin(jnos)]

    #colors = ['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2']

    with plt.style.context(['seaborn-paper', 'mypaper', 'color3']):
        # first do a refine plot to update 'Started' in srtf
        ax = plt.gca()
        ju.plot_refine(ax,
                       srtf,
                       srtf_refine,
                       offset=offset_local,
                       new_jnos=new_jnos,
                       plot_offset=-st_sec)
        plt.close()

        fig, ax = plt.subplots()

        monochrome = cycler('color', ['0.0'])
        ax.set_prop_cycle(monochrome)

        ju.plot_timeline(srtf.drop(['LaneId'], axis=1),
                         ax=ax,
                         linewidth=2.5,
                         offset=offset_local,
                         new_jnos=new_jnos,
                         plot_offset=-st_sec)
        ju.plot_refine(ax,
                       srtf,
                       srtf_refine,
                       offset=offset_local,
                       new_jnos=new_jnos,
                       plot_offset=-st_sec)
        ax.set_xlim([0, ed_sec - st_sec])

        ax.set_ylabel('Job #')
        ax.yaxis.set_ticks([0, 1, 2, 3, 4, 5])

        fig.set_size_inches(4.875, 2, forward=True)
        fig.savefig('/tmp/workspace/card274-srtf-compute.pdf',
                    dpi=300,
                    bbox_inches='tight',
                    pad_inches=.015)
        plt.close()
コード例 #3
0
def do_timelines(path):
    path = Path(path)
    # fifo = ju.load_trace(path/'card266'/'salus'/'trace.csv')
    fifo = load_data(path / 'card272' / 'case0' / 'fifo', 'case0.output')

    srtf = load_data(path / 'card266' / 'salus', 'card266.output')
    srtf_refine = ju.load_refine(path / 'card266' / 'salus')

    fair = load_data(path / 'card272' / 'case2' / 'salus', 'case2.output')
    pack = load_data(path / 'card272' / 'case1' / 'salus', 'case1.output')

    with plt.style.context(['seaborn-paper', 'mypaper', 'color4']):
        fig, axs = plt.subplots(nrows=4, sharex=True)
        fig.set_size_inches(3.25, 5.35, forward=True)
        _, colors = ju.plot_timeline(fifo, ax=axs[0], linewidth=2.5)
        axs[0].set_ylabel('FIFO')
        axs[0].legend().remove()
        axs[0].set_xlabel('')

        ju.plot_timeline(srtf.drop(['LaneId'], axis=1),
                         ax=axs[1],
                         linewidth=2.5,
                         colors=colors)
        ju.plot_refine(axs[1], srtf, srtf_refine)
        axs[1].set_ylabel('SRTF')

        ju.plot_timeline(pack, ax=axs[2], linewidth=2.5, colors=colors)
        axs[2].set_ylabel('PACK')

        ju.plot_timeline(fair.drop(['LaneId'], axis=1),
                         ax=axs[3],
                         linewidth=2.5,
                         colors=colors)
        axs[3].set_ylabel('FAIR')

        #fig.subplots_adjust(bottom=0.35)
        #axs[-1].legend(loc="upper center", frameon=False,
        #              bbox_to_anchor=[0.5, -0.8],
        #              #bbox_transform=fig.transFigure,
        #              fontsize='x-small',
        #              ncol=3
        #              #mode='expand'
        #              )

        fig.tight_layout()
        fig.savefig('/tmp/workspace/card272.pdf', dpi=300)
コード例 #4
0
def do_srtf(path):
    srtf = load_data(path / 'card272' / 'case5' / 'salus', 'case5.output')
    srtf_refine = ju.load_refine(path / 'card272' / 'case5' / 'salus')
    df = cm.load_mem(path / 'card274/srtf/alloc.output')

    offset_local = srtf.Queued.min()
    # timeline logs in US/Eastern, but server logs in UTC
    # convert offset from US/Eastern to UTC
    offset_server = offset_local.tz_localize('US/Eastern').tz_convert(
        'UTC').tz_localize(None)

    # select sess name after calc the offset
    # use jno = [13, 14, 15]
    jnos = [13, 14, 15]
    srtf = srtf[srtf.No.isin(jnos)]
    #srtf_refine = srtf_refine[srtf_refine.No.isin(jnos)]

    # select data in range
    st_sec = 400
    ed_sec = 515
    st = offset_server + pd.to_timedelta(st_sec, 's')
    ed = offset_server + pd.to_timedelta(ed_sec, 's')
    df = df[(df.timestamp >= st) & (df.timestamp <= ed)]
    df = df[df.Sess.isin(srtf.Sess.unique())]

    sess2Model = srtf.set_index('Sess').Model.str.split('.', expand=True)
    sess2Model['Label'] = sess2Model.apply(
        lambda x: '#{}: {}'.format(x[3], x[0]), axis=1)
    df['Sess'] = df.Sess.map(sess2Model.Label)

    #colors = ['#1f77b4', '#ff7f0e', '#2ca02c']

    with plt.style.context(['seaborn-paper', 'mypaper', 'color3']):
        fig, axs = plt.subplots(nrows=2,
                                sharex=True,
                                gridspec_kw={'height_ratios': [1, 4]})

        _, _, sessProps = ju.plot_timeline(srtf.drop(['LaneId'], axis=1),
                                           ax=axs[0],
                                           linewidth=2.5,
                                           returnSessProps=True,
                                           offset=offset_local)
        ju.plot_refine(axs[0], srtf, srtf_refine, offset=offset_local)
        #axs[0].set_ylabel('Job No.')
        # srtf is selected by simply set axis limit, because they are not easy to cut in data
        axs[0].set_xlim([st_sec, ed_sec])
        axs[0].set_ylim([12.45, 15.5])
        #axs[0].set_ylabel('Job', rotation=0, labelpad=20)

        sessProps = {
            row.Label: sessProps[sess]
            for sess, row in sess2Model.iterrows()
        }

        cm.plot_all(df, offset=offset_server, ax=axs[1], sessProps=sessProps)
        axs[1].set_ylim(bottom=0)

        #axs[1].legend().remove()
        # Use axs[0]'s legend, but put it at axs[1]'s legend's place
        fig.subplots_adjust(bottom=0.15, hspace=0.05)
        axs[1].legend(
            #*axs[0].get_legend_handles_labels(),
            loc="lower center",
            frameon=False,
            bbox_to_anchor=[0.5, 1],
            #bbox_transform=fig.transFigure,
            fontsize='x-small',
            ncol=4
            #mode='expand'
        )

        axs[1].xaxis.set_major_locator(pu.MaxNLocator(nbins=5))
        axs[1].minorticks_off()
        pu.cleanup_axis_bytes(axs[1].yaxis, maxN=5)
        axs[1].set_ylabel('Memory Usage')
        axs[1].set_xlabel('Time (s)')

        #fig.tight_layout()
        fig.set_size_inches(6.5, 2, forward=True)
        fig.savefig('/tmp/workspace/card274-srtf.pdf',
                    dpi=300,
                    bbox_inches='tight',
                    pad_inches=.015)