Skip to content

Commit

Permalink
wp: Add fps instrument analysis
Browse files Browse the repository at this point in the history
Add new 'fps' metric to the processor for the fps instrument.
Add new 'frame_rendering_line' plotting function to the notebook
plotter.

Signed-off-by: Kajetan Puchalski <[email protected]>
  • Loading branch information
mrkajetanp committed Aug 17, 2023
1 parent 190941c commit dbaae4c
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 4 deletions.
9 changes: 8 additions & 1 deletion ipynb/drarm_full.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@
"drarm.plot.drarm_adpf_fps_bar(width=1500)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# FPS"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -126,7 +133,7 @@
},
"outputs": [],
"source": [
"# TODO"
"drarm.plot.frame_rendering_line()"
]
},
{
Expand Down
45 changes: 44 additions & 1 deletion ipynb/fortnite_full.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
"metadata": {},
"outputs": [],
"source": [
"# TODO"
"ft.plot.frame_rendering_line()"
]
},
{
Expand Down Expand Up @@ -224,6 +224,49 @@
"ft.plot.thermal_bar()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Frequency"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Line plot"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"ft.plot.frequency_line()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Bar plot"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"ft.plot.frequency_bar()"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
4 changes: 2 additions & 2 deletions wp/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

FULL_METRICS = [
'power', 'idle', 'idle-miss', 'freq', 'overutil', 'pelt', 'capacity',
'uclamp', 'adpf', 'thermal', 'perf-trace-event', 'wakeup-latency',
'tasks-residency', 'tasks-activations',
'uclamp', 'adpf', 'thermal', 'fps', 'wakeup-latency',
'tasks-residency', 'tasks-activations', 'perf-trace-event',
'cgroup-attach', 'wakeup-latency-cgroup', 'tasks-residency-cgroup',
'energy-estimate',
]
Expand Down
39 changes: 39 additions & 0 deletions wp/notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ def analysis_to_loader(self, analysis: str) -> Callable:
'task_activations_stats_cluster': self._load_task_activations_stats,
'task_activations_stats_cluster_melt': self._load_task_activations_stats,
'uclamp_updates': self._load_uclamp_updates,
'fps': self._load_fps,
}
return mapping[analysis]

Expand Down Expand Up @@ -1592,6 +1593,44 @@ def uclamp_per_task_line(self, height=600, width=1600, include_label=True,
self.ana.hv_figures[self.ana._title_to_filename(title, '__line')] = layout
return layout

# --- FPS instrument ---

def _load_fps(self):
self.ana.load_combined_analysis('fps.pqt', allow_missing=True)
log.info('Loaded fps into analysis')

@requires_analysis(['fps'])
def frame_rendering_line(self, height: int = 600, width: int = 1600, include_label: bool = True,
target_fps: int = 30, title: str = 'Frame rendering times over time'):
"""
Plot the frame rendering times over time overlaid between different runs, with a toggle to select the iteration.
:param target_fps: Target fps to draw the target rendering line from
.. note:: This plot uses HoloViews. The resulting figure will be saved to `WorkloadNotebookAnalysis.hv_figures`.
"""
if include_label:
title = f"{self.ana.label} - {title}"

df = self.ana.analysis['fps'].copy()
df['target_render_time'] = 1000.0 / target_fps

ds = hv.Dataset(
df,
['ts_iter', hv.Dimension('tag', values=self.ana.tags), 'iteration'],
['render_time']
)

layout = ds.to(hv.Curve, 'ts_iter', 'render_time').overlay('tag').opts(
legend_position='bottom', title=title, framewise=True
)
layout *= hv.Curve(df, 'ts_iter', 'target_render_time').opts(color='orange')
layout.opts(
opts.Curve(height=height, width=width, interpolation='steps-pre', framewise=True),
)

return layout

# -------- helper functions --------

def gmean_bars(self, df: pd.DataFrame, x: str = 'stat', y: str = 'value', color: str = 'tag',
Expand Down
28 changes: 28 additions & 0 deletions wp/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,3 +385,31 @@ def capacity_analysis(self):

df.write_parquet(os.path.join(self.analysis_path, 'capacity.pqt'))
print(df)

def fps_analysis(self):
log.info('Collecting fps data')

def process_fps_df(df, iteration):
return df.filter(
pl.col('actual_present_time_us') != 0x7fffffffffffffff
).with_columns(
pl.col('*') / 1000000.0
).select(
pl.col('actual_present_time_us').alias('ts') / 1000.0,
(pl.col('actual_present_time_us') - pl.col('actual_present_time_us').first()).alias('ts_iter') / 1000.0,
pl.col('desired_present_time_us').alias('desired_ts') / 1000.0,
pl.col('frame_ready_time_us').alias('ready_ts') / 1000.0,
pl.col('actual_present_time_us').diff().alias('render_time'),
pl.col('frame_ready_time_us').diff().alias('render_ready_time'),
pl.lit(iteration).alias('iteration'),
)[1:]

fps = df_add_wa_output_tags(pl.concat([
process_fps_df(
pl.read_csv(job.get_artifact_path('frames')), job.iteration
)
for job in self.wa_output.jobs
]), self.wa_output).sort('iteration')

fps.write_parquet(os.path.join(self.analysis_path, 'fps.pqt'))
print(fps)

0 comments on commit dbaae4c

Please sign in to comment.