diff mbox

[i-g-t,02/11] trace.pl: Improve readability of graphical timeline representation

Message ID 2977b001-a780-e19e-60e6-53c3c4744f54@Intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

John Harrison July 11, 2018, 10:07 p.m. UTC
On 7/9/2018 6:19 AM, Tvrtko Ursulin wrote:
> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>
> We add stripes for different stages of request execution so it is easier
> to follow one context in the multi-colour mode.
>
> Vertical stripe pattern indicates pipeline "blockages" - requests waiting
> for dependencies before they are runnable.
>
> Diagonal stripes indicate runnable requests waiting for GPU time.
>
> Horizontal strips are requests executing on the GPU.
>
> Also use this new multi-coloured mode from media-bench.pl.
>
> v2:
>   John Harrison:
>   * Mention media-bench.pl in the commit.
>   * Fix HTML for single colour mode.
>
> v3:
>   * Rebase.
>   * Apply stripes to legacy colouring as well.
>
> v4:
>   John Harrison:
>   * Use per context colours for ctxsave and incomplete boxes.
>   * Clearer timeline legend.
>
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Cc: John Harrison <John.C.Harrison@Intel.com>
> ---
>   scripts/media-bench.pl |   2 +-
>   scripts/trace.pl       | 112 ++++++++++++++++++++++++++++++++---------
>   2 files changed, 90 insertions(+), 24 deletions(-)
>
> diff --git a/scripts/media-bench.pl b/scripts/media-bench.pl
> index c5628c7f2836..375844d9cdf6 100755
> --- a/scripts/media-bench.pl
> +++ b/scripts/media-bench.pl
> @@ -207,7 +207,7 @@ sub trace_workload
>   	show_cmd($cmd);
>   	system($cmd);
>   
> -	$cmd = "perf script | $tracepl --html -x ctxsave -s ";
> +	$cmd = "perf script | $tracepl --html -x ctxsave -s -c ";
>   	$cmd .= join ' ', map("-i $_", @skip_engine);
>   	$cmd .= " > ${file}.html";
>   	show_cmd($cmd);
> diff --git a/scripts/trace.pl b/scripts/trace.pl
> index fd414f5a4b1e..1ec8b297d15e 100755
> --- a/scripts/trace.pl
> +++ b/scripts/trace.pl
> @@ -727,9 +727,14 @@ foreach my $key (keys %reqwait) {
>   say sprintf('GPU: %.2f%% idle, %.2f%% busy',
>   	     $flat_busy{'gpu-idle'}, $flat_busy{'gpu-busy'}) unless $html;
>   
> -my $queued_colour = $colour_contexts ? 'multi-colour light' : 'blue';
> -my $runnable_colour = $colour_contexts ? 'multi-colour dark' : 'grey';
> -my $execute_colour = $colour_contexts ? 'multi-colour' : 'pink';
> +my $timeline_text = $colour_contexts ?
> +		    'Per context coloured shading like:' : 'Box shading like:';
> +
> +my $queued_style = box_style($min_ctx, 'queue');
> +my $ready_style = box_style($min_ctx, 'ready');
> +my $execute_style = box_style($min_ctx, 'execute');
> +my $ctxsave_style = box_style($min_ctx, 'ctxsave');
> +my $incomplete_style = box_style($min_ctx, 'incomplete');

In context colouring mode, the legend is not especially useful as it is 
only coloured for one particular context (which at least for all of my 
traces, is the system context that only appears at the very end as a 
flush) and has no indication that other contexts will be significantly 
different. Also, I find the black text is really hard to read against 
the dark colour backgrounds. Plus the boxes are too small to actually 
work out what the shading is (for 'ready' and 'incomplete' if not all of 
them).

See attached patch for some tweaks. Basically, add all contexts to the 
key in colour mode, make the boxes bigger and use white text for most of 
it. Although the thought occurs that it might be worth limiting the 
legend to only four or five contexts and just putting an 'etc' at the 
end if there are more. Otherwise a trace with hundreds of contexts could 
be a problem! I'm guessing in that case, the difference in colour from 
one context to the next will be pretty minimal anyway.

>   
>   print <<ENDHTML if $html;
>   <!DOCTYPE HTML>
> @@ -751,9 +756,28 @@ print <<ENDHTML if $html;
>   <button onclick="toggleStackSubgroups()">Toggle stacking</button>
>   
>   <p>
> -$execute_colour = requests executing on the GPU<br>
> -$runnable_colour = runnable requests waiting for a slot on GPU<br>
> -$queued_colour = requests waiting on fences and dependencies before they are runnable<br>
> +<b>Timeline request view:</b>
> +<table>
> +<tr><td colspan='4'>$timeline_text</td></tr>
> +<tr>
> +<td align='center'><div style='$queued_style'>QUEUED</div></td>
> +<td align='center'><div style='$ready_style'>READY</div></td>
> +<td align='center'><div style='$execute_style'>EXECUTE</div></td>
> +<td align='center'><div style='$ctxsave_style'>CTXSAVE</div></td>
> +</tr><tr>
> +<td></td>
> +<td></td>
> +<td align='center'><div style='$incomplete_style'>(INCOMPLETE)</div></td>
> +<td></td>
> +</tr/></table>
> +</p>
> +<p>
> +<small>
> +QUEUED = requests executing on the GPU<br>
> +READY = runnable requests waiting for a slot on GPU<br>
> +EXECUTE = requests waiting on fences and dependencies before they are runnable<br>
> +CTXSAVE = GPU saving the context image<br>
> +</small>
>   </p>
>   <p>
>   Boxes are in format 'ctx-id/seqno'.
> @@ -873,17 +897,31 @@ sub sortQueue {
>   
>   sub ctx_colour
>   {
> -	my ($ctx, $stage) = (@_);
> +	my ($ctx, $stage, $lfac) = (@_);
>   	my ($s, $l);
>   	my $val;
>   
>   	unless ($colour_contexts) {
>   		if ($stage eq 'queue') {
> -			return 'lightblue;';
> +			$val = 210;
> +			$s = 65;
> +			$l = 52;
>   		} elsif ($stage eq 'ready') {
> -			return 'lightgrey;';
> +			$val = 0;
> +			$s = 0;
> +			$l = 47;
>   		} elsif ($stage eq 'execute') {
> -			return 'pink;';
> +			$val = 346;
> +			$s = 68;
> +			$l = 65;
> +		} elsif ($stage eq 'ctxsave') {
> +			$val = 26;
> +			$s = 90;
> +			$l = 52;
> +		} elsif ($stage eq 'incomplete') {
> +			$val = 0;
> +			$s = 85;
> +			$l = 50;
>   		}
>   	} else {
>   		if ($stage eq 'queue') {
> @@ -895,12 +933,45 @@ sub ctx_colour
>   		} elsif ($stage eq 'execute') {
>   			$s = 80;
>   			$l = 65;
> +		} elsif ($stage eq 'ctxsave') {
> +			$s = 75;
> +			$l = 70;
> +		} elsif ($stage eq 'incomplete') {
> +			$s = 80;
> +			$l = 25;
>   		}
> +
> +		$val = int(360 / ($max_ctx - $min_ctx + 1)) * ($ctx - $min_ctx);
>   	}
>   
> -	$val = int(360 / ($max_ctx - $min_ctx + 1)) * ($ctx - $min_ctx);
> +	$l = int($l * $lfac);
>   
> -	return "hsl($val, $s%, $l%);";
> +	return "hsl($val, $s%, $l%)";
> +}
> +
> +sub box_style
> +{
> +	my ($ctx, $stage) = @_;
> +	my $deg;
> +
> +	if ($stage eq 'queue') {
> +		$deg = 90;
> +	} elsif ($stage eq 'ready') {
> +		$deg = 45;
> +	} elsif ($stage eq 'execute') {
> +		$deg = 0;
> +	} elsif ($stage eq 'ctxsave') {
> +		$deg = 105;
> +	} elsif ($stage eq 'incomplete') {
> +		$deg = 0;
> +	}
> +
> +	return 'color: black; background: repeating-linear-gradient(' .
> +		$deg . 'deg, ' .
> +		ctx_colour($ctx, $stage, 1.0) . ', ' .
> +		ctx_colour($ctx, $stage, 1.0) . ' 10px, ' .
> +		ctx_colour($ctx, $stage, 0.90) . ' 10px, ' .
> +		ctx_colour($ctx, $stage, 0.90) . ' 20px);';
>   }
>   
>   my $i = 0;
> @@ -917,8 +988,7 @@ foreach my $key (sort sortQueue keys %db) {
>   	# submit to execute
>   	unless (exists $skip_box{'queue'}) {
>   		$skey = 2 * $max_seqno * $ctx + 2 * $seqno;
> -		$style = 'color: black; background-color: ' .
> -			 ctx_colour($ctx, 'queue');
> +		$style = box_style($ctx, 'queue');
>   		$content = "$name<br>$db{$key}->{'submit-delay'}us <small>($db{$key}->{'execute-delay'}us)</small>";
>   		$startend = 'start: \'' . ts($queue) . '\', end: \'' . ts($submit) . '\'';
>   		print "\t{id: $i, key: $skey, $type group: $group, subgroup: 1, subgroupOrder: 1, content: '$content', $startend, style: \'$style\'},\n";
> @@ -928,8 +998,7 @@ foreach my $key (sort sortQueue keys %db) {
>   	# execute to start
>   	unless (exists $skip_box{'ready'}) {
>   		$skey = 2 * $max_seqno * $ctx + 2 * $seqno + 1;
> -		$style = 'color: black; background-color: ' .
> -			 ctx_colour($ctx, 'ready');
> +		$style = box_style($ctx, 'ready');
>   		$content = "<small>$name<br>$db{$key}->{'execute-delay'}us</small>";
>   		$startend = 'start: \'' . ts($submit) . '\', end: \'' . ts($start) . '\'';
>   		print "\t{id: $i, key: $skey, $type group: $group, subgroup: 1, subgroupOrder: 2, content: '$content', $startend, style: \'$style\'},\n";
> @@ -939,12 +1008,9 @@ foreach my $key (sort sortQueue keys %db) {
>   	# start to user interrupt
>   	unless (exists $skip_box{'execute'}) {
>   		$skey = -2 * $max_seqno * $ctx - 2 * $seqno - 1;
> -		if (exists $db{$key}->{'incomplete'}) {
> -			$style = 'color: white; background-color: red;';
> -		} else {
> -			$style = 'color: black; background-color: ' .
> -				  ctx_colour($ctx, 'execute');
> -		}
> +		$style = box_style($ctx,
> +				   exists $db{$key}->{'incomplete'} ?
> +				   'incomplete' : 'execute');
>   		$content = "$name <small>$db{$key}->{'port'}</small>";
>   		$content .= ' <small><i>???</i></small> ' if exists $db{$key}->{'incomplete'};
>   		$content .= ' <small><i>++</i></small> ' if exists $db{$key}->{'no-end'};
> @@ -958,7 +1024,7 @@ foreach my $key (sort sortQueue keys %db) {
>   	# user interrupt to context complete
>   	unless (exists $skip_box{'ctxsave'}) {
>   		$skey = -2 * $max_seqno * $ctx - 2 * $seqno;
> -		$style = 'color: black; background-color: orange;';
> +		$style = box_style($ctx, 'ctxsave');
>   		my $ctxsave = $db{$key}->{'end'} - $db{$key}->{'notify'};
>   		$content = "<small>$name<br>${ctxsave}us</small>";
>   		$content .= ' <small><i>???</i></small> ' if exists $db{$key}->{'incomplete'};
From df66e1353cc9550fb0a8a79b98dc8f8dc85ed993 Mon Sep 17 00:00:00 2001
From: John Harrison <John.C.Harrison@Intel.com>
Date: Tue, 10 Jul 2018 14:53:16 -0700
Subject: [PATCH 01/21] trace.pl: Improved key/colours

---
 scripts/trace.pl | 50 +++++++++++++++++++++++++++++++-------------------
 1 file changed, 31 insertions(+), 19 deletions(-)
diff mbox

Patch

diff --git a/scripts/trace.pl b/scripts/trace.pl
index 60a8e441..38379737 100755
--- a/scripts/trace.pl
+++ b/scripts/trace.pl
@@ -740,6 +740,29 @@  my $timeline_text = $colour_contexts ?
 		    'Per context coloured shading like:' : 'Box shading like:';
 
 my %ctx_colours;
+my $ctx_table;
+
+sub generate_ctx_table
+{
+	my @states = ("queue", "ready", "execute", "ctxsave", "incomplete");
+	my @ctxts;
+
+	if( $colour_contexts ) {
+		@ctxts = sort keys %ctxdb;
+	} else {
+		@ctxts = ($min_ctx);
+	}
+
+	$ctx_table = "";
+	foreach my $ctx (@ctxts) {
+		$ctx_table .= "<tr>\n";
+		$ctx_table .= "  <td>Context: $ctx</td>\n" if $colour_contexts;
+		foreach my $state (@states) {
+			$ctx_table .= "  <td align='center'><div style='" . box_style($ctx, $state) . "'>&nbsp;&nbsp;&nbsp;" . uc($state) . "&nbsp;&nbsp;&nbsp;<p>&nbsp;</div></td>\n";
+		}
+		$ctx_table .= "</tr>";
+	}
+}
 
 sub generate_ctx_colours
 {
@@ -753,12 +776,7 @@  sub generate_ctx_colours
 
 
 generate_ctx_colours() if $html and $colour_contexts;
-
-my $queued_style = box_style($min_ctx, 'queue');
-my $ready_style = box_style($min_ctx, 'ready');
-my $execute_style = box_style($min_ctx, 'execute');
-my $ctxsave_style = box_style($min_ctx, 'ctxsave');
-my $incomplete_style = box_style($min_ctx, 'incomplete');
+generate_ctx_table() if $html;
 
 print <<ENDHTML if $html;
 <!DOCTYPE HTML>
@@ -780,24 +798,16 @@  print <<ENDHTML if $html;
 <b>Timeline request view:</b>
 <table>
 <tr><td colspan='4'>$timeline_text</td></tr>
-<tr>
-<td align='center'><div style='$queued_style'>QUEUED</div></td>
-<td align='center'><div style='$ready_style'>READY</div></td>
-<td align='center'><div style='$execute_style'>EXECUTE</div></td>
-<td align='center'><div style='$ctxsave_style'>CTXSAVE</div></td>
-</tr><tr>
-<td></td>
-<td></td>
-<td align='center'><div style='$incomplete_style'>(INCOMPLETE)</div></td>
-<td></td>
-</tr/></table>
+$ctx_table
+</table>
 </p>
 <p>
 <small>
-QUEUED = requests executing on the GPU<br>
+QUEUE = requests executing on the GPU<br>
 READY = runnable requests waiting for a slot on GPU<br>
 EXECUTE = requests waiting on fences and dependencies before they are runnable<br>
 CTXSAVE = GPU saving the context image<br>
+INCOMPLETE = request has stopped executing but is not yet complete (e.g. it was pre-empted)
 </small>
 </p>
 <p>
@@ -974,9 +984,11 @@  sub box_style
 {
 	my ($ctx, $stage) = @_;
 	my $deg;
+	my $text_col = 'white';
 
 	if ($stage eq 'queue') {
 		$deg = 90;
+		$text_col = 'black' if $colour_contexts;
 	} elsif ($stage eq 'ready') {
 		$deg = 45;
 	} elsif ($stage eq 'execute') {
@@ -987,7 +999,7 @@  sub box_style
 		$deg = 0;
 	}
 
-	return 'color: black; background: repeating-linear-gradient(' .
+	return "color: $text_col; background: repeating-linear-gradient(" .
 		$deg . 'deg, ' .
 		ctx_colour($ctx, $stage, 1.0) . ', ' .
 		ctx_colour($ctx, $stage, 1.0) . ' 10px, ' .