From 383e5e538cbab5f20cf6742ec1ea5d2c2f81c5ea Mon Sep 17 00:00:00 2001 From: Hubert depesz Lubaczewski Date: Fri, 19 Feb 2021 14:52:03 +0100 Subject: [PATCH] Display JIT info for plans --- cpanfile | 2 +- public/css/common.css | 19 ++++++++++++++ templates/controller/show.html.ep | 42 ++++++++++++++++++++++++++++++- 3 files changed, 61 insertions(+), 2 deletions(-) diff --git a/cpanfile b/cpanfile index 58facc9..54af80c 100644 --- a/cpanfile +++ b/cpanfile @@ -18,6 +18,6 @@ requires 'Encode'; requires 'English'; requires 'File::Spec'; requires 'Mojolicious'; -requires 'Pg::Explain', '>= 0.90'; +requires 'Pg::Explain', '>= 1.05'; # vim: set ft=perl: diff --git a/public/css/common.css b/public/css/common.css index 41534d5..f6314e9 100755 --- a/public/css/common.css +++ b/public/css/common.css @@ -256,3 +256,22 @@ section p a:hover {background:#234;color:#fff;border:1px solid #123} #trigger-times tr.c-2 {background-color:#fe8 !important} #trigger-times tr.c-3 {background-color:#e80 !important;color:#fff} #trigger-times tr.c-4 {background-color:#800 !important;color:#fff} + +#jit-info {margin: 1em 0px;background: #eee;} +#jit-info thead a { border: 1px solid black; font-size: 0.5em; float: right; padding: 0.3em; } +#jit-info, +#jit-info th, +#jit-info td {border-collapse: collapse; border:1px solid #ccc;} +#jit-info .jit-timing th, +#jit-info .jit-option th {padding-left: 1.5em; padding-right: 1em;} +#jit-info .jit-option td {text-align: center;} +#jit-info .jit-option td span {font-size: 1.2em; font-weight: bold;} +#jit-info th { font-size: 1.2em; font-weight: bold; padding: 0.2em 0.5em;} +#jit-info thead th {text-align: center} +#jit-info th.top {font-size: 1.5em;} +#jit-info td {text-align: right; padding: 0.2em 0.5em;} +#jit-info .jit-fun td {text-align: center;} +#jit-info span.value { font-size: 1.2em; } +#jit-info tr.c-2 {background-color:#fe8 !important} +#jit-info tr.c-3 {background-color:#e80 !important;color:#fff} +#jit-info tr.c-4 {background-color:#800 !important;color:#fff} diff --git a/templates/controller/show.html.ep b/templates/controller/show.html.ep index e9fc291..d27babf 100755 --- a/templates/controller/show.html.ep +++ b/templates/controller/show.html.ep @@ -572,6 +572,46 @@ % } +% if (defined $explain->jit) { +% my $full_execution_time = $explain->runtime || 0; + + + + + + + + + % my $opts = $explain->jit->options; + % for my $name ( sort keys %{ $opts } ) { + + + + + % } + + + % my $ts = $explain->jit->timings; + % for my $name ( sort keys %{ $ts } ) { + % my $row_color = 1; + % if ( $full_execution_time ) { + % my $t_point = $ts->{$name} / $full_execution_time; + % if ( $t_point > 0.9 ) { $row_color = 4; } + % elsif ( $t_point > 0.5 ) { $row_color = 3; } + % elsif ( $t_point > 0.1 ) { $row_color = 2; } + % } + + % } + +
JIT:?
Functions:<%= $explain->jit->functions %>
Options:
<%= $name %> + % if ( $opts->{$name} ) { + (true) + % } else { + (false) + % } +
Timing:
<%= $name %><%= commify_number( $ts->{$name} ) %> ms
+% } + % if ( defined $explain->trigger_times ) { % my $full_execution_time = $explain->runtime || 0; @@ -591,7 +631,7 @@ - + % }
<%= $trg->{'name'} %> <%= commify_number( sprintf '%.03f', $trg->{'time'} ) %> ms<%= $trg->{'calls'} %><%= commify_number( $trg->{'calls'} ) %> <%= commify_number( sprintf '%.03f', $trg->{'time'} / $trg->{'calls'} ) %> ms