pqd: Removed show-all, shorten, select & print-iterations

This commit is contained in:
Brian Fraser
2013-02-25 13:10:03 -03:00
parent 78cae8b91b
commit 1d9b013bab
14 changed files with 39 additions and 189 deletions

View File

@@ -6511,8 +6511,7 @@ sub BUILDARGS {
my $self = { my $self = {
%$args, %$args,
options => { options => {
show_all => $o->get('show-all'), shorten => 1024,
shorten => $o->get('shorten'),
report_all => $o->get('report-all'), report_all => $o->get('report-all'),
report_histogram => $o->get('report-histogram'), report_histogram => $o->get('report-histogram'),
}, },
@@ -6642,10 +6641,7 @@ sub header {
push @result, $self->make_global_header(); push @result, $self->make_global_header();
my $attribs = $self->sort_attribs( my $attribs = $self->sort_attribs( $ea );
($args{select} ? $args{select} : $ea->get_attributes()),
$ea,
);
foreach my $type ( qw(num innodb) ) { foreach my $type ( qw(num innodb) ) {
if ( $type eq 'innodb' && @{$attribs->{$type}} ) { if ( $type eq 'innodb' && @{$attribs->{$type}} ) {
@@ -6767,10 +6763,7 @@ sub query_report {
. '# ' . ( '#' x 72 ) . "\n\n"; . '# ' . ( '#' x 72 ) . "\n\n";
} }
my $attribs = $self->sort_attribs( my $attribs = $self->sort_attribs( $ea );
($args{select} ? $args{select} : $ea->get_attributes()),
$ea,
);
ITEM: ITEM:
foreach my $vals ( @$report_values ) { foreach my $vals ( @$report_values ) {
@@ -6902,10 +6895,7 @@ sub event_report_values {
my $attribs = $args{attribs}; my $attribs = $args{attribs};
if ( !$attribs ) { if ( !$attribs ) {
$attribs = $self->sort_attribs( $attribs = $self->sort_attribs( $ea );
($args{select} ? $args{select} : $ea->get_attributes()),
$ea
);
} }
$vals{attributes} = { map { $_ => [] } qw(num innodb bool string) }; $vals{attributes} = { map { $_ => [] } qw(num innodb bool string) };
@@ -7372,7 +7362,6 @@ sub bool_percents {
sub format_string_list { sub format_string_list {
my ( $self, $attrib, $vals, $class_cnt ) = @_; my ( $self, $attrib, $vals, $class_cnt ) = @_;
my $show_all = $self->{options}->{show_all};
if ( !exists $vals->{unq} ) { if ( !exists $vals->{unq} ) {
return ($vals->{cnt}); return ($vals->{cnt});
@@ -7402,9 +7391,6 @@ sub format_string_list {
} }
my $p = percentage_of($cnt_for->{$str}, $class_cnt); my $p = percentage_of($cnt_for->{$str}, $class_cnt);
$print_str .= " ($cnt_for->{$str}/$p%)"; $print_str .= " ($cnt_for->{$str}/$p%)";
if ( !$show_all->{$attrib} ) {
last if (length $line) + (length $print_str) > LINE_LENGTH - 27;
}
$line .= "$print_str, "; $line .= "$print_str, ";
$i++; $i++;
} }
@@ -7419,7 +7405,8 @@ sub format_string_list {
} }
sub sort_attribs { sub sort_attribs {
my ( $self, $attribs, $ea ) = @_; my ( $self, $ea ) = @_;
my $attribs = $ea->get_attributes();
return unless $attribs && @$attribs; return unless $attribs && @$attribs;
PTDEBUG && _d("Sorting attribs:", @$attribs); PTDEBUG && _d("Sorting attribs:", @$attribs);
@@ -12560,23 +12547,6 @@ sub main {
my $pat = $o->read_para_after(__FILE__, qr/MAGIC_history_cols/); my $pat = $o->read_para_after(__FILE__, qr/MAGIC_history_cols/);
$pat =~ s/\s+//g; $pat =~ s/\s+//g;
$pat = qr/^(.*?)_($pat)$/; $pat = qr/^(.*?)_($pat)$/;
# Get original --select values.
my %select = map { $_ => 1 } @{$o->get('select')};
foreach my $col ( @{$tbl->{cols}} ) {
my ( $attr, $metric ) = $col =~ $pat;
next unless $attr && $metric;
$attr = ucfirst $attr if $attr =~ m/_/; # TableParser lowercases
# Add history table values to original select values.
$select{$attr}++;
}
if ( $o->got('select') ) {
# Re-set --select with its original values plus the history
# table values.
$o->set('select', [sort keys %select]);
PTDEBUG && _d("--select after parsing the history table:",
@{$o->get('select')});
}
# And tell the QueryReview that it has more work to do. # And tell the QueryReview that it has more work to do.
$qv->set_history_options( $qv->set_history_options(
@@ -13053,9 +13023,9 @@ sub main {
PTDEBUG && _d('Iteration', $args->{iter}, PTDEBUG && _d('Iteration', $args->{iter},
'started at', ts($iter_start)); 'started at', ts($iter_start));
if ( $o->get('print-iterations') ) { if ( PTDEBUG ) {
print "\n# Iteration $args->{iter} started at ", _d("\n# Iteration $args->{iter} started at ",
ts($iter_start), "\n"; ts($iter_start), "\n");
} }
} }
@@ -13428,13 +13398,6 @@ sub main {
my ( $orderby_attrib, $orderby_func ) = split(/:/, $orderby[$i]); my ( $orderby_attrib, $orderby_func ) = split(/:/, $orderby[$i]);
my %attributes = map {
my ($name, @alt) = split(/:/, $_);
$name => [$name, @alt];
}
grep { $_ !~ m/^$groupby\b/ }
@{$o->get('select')};
# Create an EventAggregator for this groupby attrib and # Create an EventAggregator for this groupby attrib and
# add it to callbacks. # add it to callbacks.
my $type_for = { my $type_for = {
@@ -13451,7 +13414,7 @@ sub main {
my $ea = new EventAggregator( my $ea = new EventAggregator(
groupby => $groupby, groupby => $groupby,
attributes => { %attributes }, attributes => { },
worst => $orderby_attrib, worst => $orderby_attrib,
attrib_limit => $o->get('attribute-value-limit'), attrib_limit => $o->get('attribute-value-limit'),
ignore_attributes => $o->get('ignore-attributes'), ignore_attributes => $o->get('ignore-attributes'),

View File

@@ -108,7 +108,7 @@ sub new {
keys %$attributes keys %$attributes
}, },
worst => $args{worst}, worst => $args{worst},
unroll_limit => $args{unroll_limit} || 1000, unroll_limit => $ENV{PT_QUERY_DIGEST_CHECK_ATTRIB_LIMIT} || 1000,
attrib_limit => $args{attrib_limit}, attrib_limit => $args{attrib_limit},
result_classes => {}, result_classes => {},
result_globals => {}, result_globals => {},

View File

@@ -113,8 +113,7 @@ sub BUILDARGS {
my $self = { my $self = {
%$args, %$args,
options => { options => {
show_all => $o->get('show-all'), shorten => 1024,
shorten => $o->get('shorten'),
report_all => $o->get('report-all'), report_all => $o->get('report-all'),
report_histogram => $o->get('report-histogram'), report_histogram => $o->get('report-histogram'),
}, },
@@ -271,10 +270,7 @@ sub header {
push @result, $self->make_global_header(); push @result, $self->make_global_header();
# Sort the attributes, removing any hidden attributes. # Sort the attributes, removing any hidden attributes.
my $attribs = $self->sort_attribs( my $attribs = $self->sort_attribs( $ea );
($args{select} ? $args{select} : $ea->get_attributes()),
$ea,
);
foreach my $type ( qw(num innodb) ) { foreach my $type ( qw(num innodb) ) {
# Add "InnoDB:" sub-header before grouped InnoDB_* attributes. # Add "InnoDB:" sub-header before grouped InnoDB_* attributes.
@@ -414,10 +410,7 @@ sub query_report {
} }
# Sort the attributes, removing any hidden attributes. # Sort the attributes, removing any hidden attributes.
my $attribs = $self->sort_attribs( my $attribs = $self->sort_attribs( $ea );
($args{select} ? $args{select} : $ea->get_attributes()),
$ea,
);
# Print each worst item: its stats/metrics (sum/min/max/95%/etc.), # Print each worst item: its stats/metrics (sum/min/max/95%/etc.),
# Query_time distro chart, tables, EXPLAIN, fingerprint, etc. # Query_time distro chart, tables, EXPLAIN, fingerprint, etc.
@@ -584,10 +577,7 @@ sub event_report_values {
# will sort and pass the attribs so they're not for every event. # will sort and pass the attribs so they're not for every event.
my $attribs = $args{attribs}; my $attribs = $args{attribs};
if ( !$attribs ) { if ( !$attribs ) {
$attribs = $self->sort_attribs( $attribs = $self->sort_attribs( $ea );
($args{select} ? $args{select} : $ea->get_attributes()),
$ea
);
} }
$vals{attributes} = { map { $_ => [] } qw(num innodb bool string) }; $vals{attributes} = { map { $_ => [] } qw(num innodb bool string) };
@@ -1124,7 +1114,6 @@ sub bool_percents {
# Does pretty-printing for lists of strings like users, hosts, db. # Does pretty-printing for lists of strings like users, hosts, db.
sub format_string_list { sub format_string_list {
my ( $self, $attrib, $vals, $class_cnt ) = @_; my ( $self, $attrib, $vals, $class_cnt ) = @_;
my $show_all = $self->{options}->{show_all};
# Only class result values have unq. So if unq doesn't exist, # Only class result values have unq. So if unq doesn't exist,
# then we've been given global values. # then we've been given global values.
@@ -1157,9 +1146,6 @@ sub format_string_list {
} }
my $p = percentage_of($cnt_for->{$str}, $class_cnt); my $p = percentage_of($cnt_for->{$str}, $class_cnt);
$print_str .= " ($cnt_for->{$str}/$p%)"; $print_str .= " ($cnt_for->{$str}/$p%)";
if ( !$show_all->{$attrib} ) {
last if (length $line) + (length $print_str) > LINE_LENGTH - 27;
}
$line .= "$print_str, "; $line .= "$print_str, ";
$i++; $i++;
} }
@@ -1174,7 +1160,8 @@ sub format_string_list {
} }
sub sort_attribs { sub sort_attribs {
my ( $self, $attribs, $ea ) = @_; my ( $self, $ea ) = @_;
my $attribs = $ea->get_attributes();
return unless $attribs && @$attribs; return unless $attribs && @$attribs;
PTDEBUG && _d("Sorting attribs:", @$attribs); PTDEBUG && _d("Sorting attribs:", @$attribs);

View File

@@ -1526,11 +1526,14 @@ ok(
'New event class has new attrib; default unroll_limit(issue 514)' 'New event class has new attrib; default unroll_limit(issue 514)'
); );
$ea = new EventAggregator( $ea = do {
local $ENV{PT_QUERY_DIGEST_CHECK_ATTRIB_LIMIT} = 50;
new EventAggregator(
groupby => 'arg', groupby => 'arg',
worst => 'Query_time', worst => 'Query_time'
unroll_limit => 50,
); );
};
parse_file('t/lib/samples/slowlogs/slow030.txt', $p, $ea); parse_file('t/lib/samples/slowlogs/slow030.txt', $p, $ea);
ok( ok(
!exists $ea->{unrolled_for}->{InnoDB_rec_lock_wait}, !exists $ea->{unrolled_for}->{InnoDB_rec_lock_wait},

View File

@@ -464,7 +464,7 @@ ok(
# ############################################################################# # #############################################################################
# This test uses the $ea from the Bool pretty printer test above. # This test uses the $ea from the Bool pretty printer test above.
my $sorted = $qrf->sort_attribs($ea->get_attributes(), $ea); my $sorted = $qrf->sort_attribs($ea);
is_deeply( is_deeply(
$sorted, $sorted,
{ {
@@ -511,7 +511,7 @@ foreach my $event (@$events) {
} }
$ea->calculate_statistical_metrics(); $ea->calculate_statistical_metrics();
$sorted = $qrf->sort_attribs($ea->get_attributes(), $ea); $sorted = $qrf->sort_attribs($ea);
is_deeply( is_deeply(
$sorted, $sorted,
{ {
@@ -689,7 +689,7 @@ ok(
"t/lib/samples/QueryReportFormatter/report010.txt", "t/lib/samples/QueryReportFormatter/report010.txt",
cmd_output => 1, cmd_output => 1,
), ),
'Truncate one long string' "Don't truncate one long string"
); );
$ea->reset_aggregated_data(); $ea->reset_aggregated_data();
@@ -721,7 +721,7 @@ ok(
"t/lib/samples/QueryReportFormatter/report011.txt", "t/lib/samples/QueryReportFormatter/report011.txt",
cmd_output => 1, cmd_output => 1,
), ),
'Truncate multiple long strings' "Don't truncate multiple long strings"
); );
$ea->reset_aggregated_data(); $ea->reset_aggregated_data();
@@ -753,7 +753,7 @@ ok(
"t/lib/samples/QueryReportFormatter/report012.txt", "t/lib/samples/QueryReportFormatter/report012.txt",
cmd_output => 1, cmd_output => 1,
), ),
'Truncate multiple strings longer than whole line' "Don't truncate multiple strings longer than whole line"
); );
# ############################################################################# # #############################################################################
@@ -881,16 +881,6 @@ ok(
"IPs not shortened with more" "IPs not shortened with more"
); );
# Test show_all.
@ARGV = qw(--show-all host);
$o->get_opts();
$qrf = new QueryReportFormatter(
OptionParser => $o,
QueryRewriter => $qr,
QueryParser => $qp,
Quoter => $q,
ExplainAnalyzer => $ex,
);
$result = $qrf->event_report( $result = $qrf->event_report(
ea => $ea, ea => $ea,
select => [ qw(Query_time host) ], select => [ qw(Query_time host) ],

View File

@@ -7,4 +7,4 @@
# Count 100 3 # Count 100 3
# Exec time 100 6s 1s 3s 2s 3s 780ms 2s # Exec time 100 6s 1s 3s 2s 3s 780ms 2s
# String: # String:
# foo Hi. I'm a... (1/33%), Me too! I'... (1/33%)... 1 more # foo Hi. I'm a... (1/33%), Me too! I'... (1/33%), Number 3 l... (1/33%)

View File

@@ -5,4 +5,4 @@
# Count 100 2 # Count 100 2
# Exec time 100 16s 8s 8s 8s 8s 0 8s # Exec time 100 16s 8s 8s 8s 8s 0 8s
# String: # String:
# Hosts 123.123.123.456 (1/50%)... 1 more # Hosts 123.123.123.456 (1/50%), 123.123.123.789 (1/50%)

View File

@@ -5,4 +5,4 @@
# Count 100 3 # Count 100 3
# Exec time 100 24s 8s 8s 8s 8s 0 8s # Exec time 100 24s 8s 8s 8s 8s 0 8s
# String: # String:
# Hosts 123.123.123.456 (1/33%)... 2 more # Hosts 123.123.123.456 (1/33%), 123.123.123.789 (1/33%), 123.123.123.999 (1/33%)

View File

@@ -1,44 +0,0 @@
# Query 1: 0 QPS, 0x concurrency, ID 0x7F7D57ACDD8A346E at byte 0 ________
# This item is included in the report because it matches --limit.
# Scores: V/M = 0.00
# Attribute pct total min max avg 95% stddev median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count 50 1
# Exec time 50 2s 2s 2s 2s 2s 0 2s
# Query_time distribution
# 1us
# 10us
# 100us
# 1ms
# 10ms
# 100ms
# 1s ################################################################
# 10s+
# Tables
# SHOW TABLE STATUS FROM `test` LIKE 'n'\G
# SHOW CREATE TABLE `test`.`n`\G
# EXPLAIN /*!50100 PARTITIONS*/
select sleep(2) from n\G
# Query 2: 0 QPS, 0x concurrency, ID 0x3A99CC42AEDCCFCD at byte 359 ______
# This item is included in the report because it matches --limit.
# Scores: V/M = 0.00
# Attribute pct total min max avg 95% stddev median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count 50 1
# Exec time 50 2s 2s 2s 2s 2s 0 2s
# Query_time distribution
# 1us
# 10us
# 100us
# 1ms
# 10ms
# 100ms
# 1s ################################################################
# 10s+
# Tables
# SHOW TABLE STATUS FROM `test` LIKE 'n'\G
# SHOW CREATE TABLE `test`.`n`\G
# EXPLAIN /*!50100 PARTITIONS*/
select sleep(2) from test.n\G

View File

@@ -1,30 +0,0 @@
# Query 1: 0 QPS, 0x concurrency, ID 0x7CE9953EA3A36141 at byte 417 ______
# This item is included in the report because it matches --limit.
# Scores: V/M = 0.00
# Time range: all events occurred at 2009-12-05 19:55:11
# Attribute pct total min max avg 95% stddev median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count 100 3
# Exec time 100 2ms 613us 613us 613us 613us 0 613us
# Lock time 99 321us 107us 107us 107us 107us 0 107us
# Rows sent 100 690 230 230 230 230 0 230
# Rows examine 100 690 230 230 230 230 0 230
# Rows affecte 0 0 0 0 0 0 0 0
# Rows read 100 690 230 230 230 230 0 230
# Query size 100 31 10 11 10.33 10.84 0.47 9.83
# String:
# Hosts 123.123.123.121 (1/33%)... 2 more
# Users chessguest
# Query_time distribution
# 1us
# 10us
# 100us ################################################################
# 1ms
# 10ms
# 100ms
# 1s
# 10s+
# EXPLAIN /*!50100 PARTITIONS*/
select foo
\G

View File

@@ -72,7 +72,7 @@ SELECT * FROM bar WHERE id=12\G
# Rows examine 0 0 0 0 0 0 0 0 # Rows examine 0 0 0 0 0 0 0 0
# Query size 45 140 28 28 28 28 0 28 # Query size 45 140 28 28 28 28 0 28
# String: # String:
# arg crc 108 (1/20%), 306 (1/20%), 353 (1/20%)... 2 more # arg crc 108 (1/20%), 306 (1/20%), 353 (1/20%), 558 (1/20%), 887 (1/20%)
# Query_time distribution # Query_time distribution
# 1us # 1us
# 10us ################################################################ # 10us ################################################################

View File

@@ -12,7 +12,7 @@
# Rows examine 0 0 0 0 0 0 0 0 # Rows examine 0 0 0 0 0 0 0 0
# Query size 100 224 28 28 28 28 0 28 # Query size 100 224 28 28 28 28 0 28
# String: # String:
# InnoDB trxID 101 (1/12%), 102 (1/12%), 103 (1/12%)... 5 more # InnoDB trxID 101 (1/12%), 102 (1/12%), 103 (1/12%), 104 (1/12%), 105 (1/12%), 106 (1/12%), A07 (1/12%), A08 (1/12%)
# Query_time distribution # Query_time distribution
# 1us # 1us
# 10us ################################################################ # 10us ################################################################

View File

@@ -56,7 +56,7 @@ select * from d.t where name="adam"\G
# Warning coun 0 0 0 0 0 0 0 0 # Warning coun 0 0 0 0 0 0 0 0
# String: # String:
# Hosts 127.0.0.1 # Hosts 127.0.0.1
# Statement id 2 (1/20%), 3 (1/20%), 4 (1/20%), 5 (1/20%)... 1 more # Statement id 2 (1/20%), 3 (1/20%), 4 (1/20%), 5 (1/20%), 6 (1/20%)
# Query_time distribution # Query_time distribution
# 1us # 1us
# 10us # 10us

View File

@@ -63,14 +63,6 @@ ok(
'Timeline for slow002 with distill' 'Timeline for slow002 with distill'
); );
ok(
no_diff(
sub { pt_query_digest::main(@args, $sample.'slow001.txt', qw(--select Query_time)) },
"t/pt-query-digest/samples/slow001_select_report.txt"
),
'Analysis for slow001 --select'
);
ok( ok(
no_diff( no_diff(
sub { pt_query_digest::main(@args, $sample.'slow002.txt') }, sub { pt_query_digest::main(@args, $sample.'slow002.txt') },
@@ -307,23 +299,13 @@ is(
); );
diag(`rm -rf /tmp/mqd-warnings.txt`); diag(`rm -rf /tmp/mqd-warnings.txt`);
# Issue 940
ok( ok(
no_diff( no_diff(
sub { pt_query_digest::main(@args, $sample.'slow042.txt', sub { pt_query_digest::main(@args, $sample.'slow042.txt',
qw(--report-format query_report)) }, qw(--report-format query_report)) },
"t/pt-query-digest/samples/slow042.txt",
),
'Analysis for slow042'
);
ok(
no_diff(
sub { pt_query_digest::main(@args, $sample.'slow042.txt',
qw(--report-format query_report --show-all host)) },
"t/pt-query-digest/samples/slow042-show-all-host.txt", "t/pt-query-digest/samples/slow042-show-all-host.txt",
), ),
'Analysis for slow042 with --show-all hosts' 'Analysis for slow042 (previously the --show-all test)'
); );
# ############################################################################# # #############################################################################
@@ -389,8 +371,7 @@ ok(
no_diff( no_diff(
sub { sub {
local $ENV{PT_QUERY_DIGEST_CHECK_ATTRIB_LIMIT} = 5; local $ENV{PT_QUERY_DIGEST_CHECK_ATTRIB_LIMIT} = 5;
pt_query_digest::main(@args, $sample.'slow054.txt', pt_query_digest::main(@args, $sample.'slow054.txt')
qw(--check-attributes-limit 5))
}, },
"t/pt-query-digest/samples/slow054.txt", "t/pt-query-digest/samples/slow054.txt",
), ),