diff options
author | Byron Jones <bjones@mozilla.com> | 2013-06-27 06:27:42 +0200 |
---|---|---|
committer | Byron Jones <bjones@mozilla.com> | 2013-06-27 06:27:42 +0200 |
commit | dfb9acfb6b76c7db463454df452c1941bf728766 (patch) | |
tree | 90f748bf242978731071336cb9ce27e1650198c4 /process_bug.cgi | |
parent | 225311b679a8bd2114b65a609d525179728b1ac6 (diff) | |
download | bugzilla-dfb9acfb6b76c7db463454df452c1941bf728766.tar.gz bugzilla-dfb9acfb6b76c7db463454df452c1941bf728766.tar.xz |
Bug 887180: show_bug and process_bug timings generating duplicates under mod_perl
Diffstat (limited to 'process_bug.cgi')
-rwxr-xr-x | process_bug.cgi | 48 |
1 files changed, 15 insertions, 33 deletions
diff --git a/process_bug.cgi b/process_bug.cgi index 6731a8395..523523281 100755 --- a/process_bug.cgi +++ b/process_bug.cgi @@ -58,12 +58,10 @@ use Bugzilla::Keyword; use Bugzilla::Flag; use Bugzilla::Status; use Bugzilla::Token; +use Bugzilla::Instrument; use List::MoreUtils qw(firstidx); use Storable qw(dclone); -use Time::HiRes qw(clock_gettime CLOCK_MONOTONIC); -use Encode qw(encode_utf8); -use Sys::Syslog qw(:DEFAULT); my $user = Bugzilla->login(LOGIN_REQUIRED); @@ -72,7 +70,7 @@ my $dbh = Bugzilla->dbh; my $template = Bugzilla->template; my $vars = {}; -my $timings = { start_time => clock_gettime(CLOCK_MONOTONIC) }; +my $timings = Bugzilla::Instrument->new('process_bug'); ###################################################################### # Subroutines @@ -147,7 +145,7 @@ Bugzilla::User::match_field({ print $cgi->header() unless Bugzilla->usage_mode == USAGE_MODE_EMAIL; -$timings->{load_bug} = clock_gettime(CLOCK_MONOTONIC); +$timings->time('load_bug'); # Check for a mid-air collision. Currently this only works when updating # an individual bug. @@ -212,7 +210,7 @@ else { check_token_data($token, 'buglist_mass_change', 'query.cgi'); } -$timings->{mid_air} = clock_gettime(CLOCK_MONOTONIC); +$timings->time('mid_air'); ###################################################################### # End Data/Security Validation @@ -401,14 +399,14 @@ if (defined $cgi->param('id')) { $first_bug->set_flags($flags, $new_flags); } -$timings->{update_time} = clock_gettime(CLOCK_MONOTONIC); +$timings->time('update_time'); ############################## # Do Actual Database Updates # ############################## foreach my $bug (@bug_objects) { my $changes = $bug->update(); - $timings->{db_time} = clock_gettime(CLOCK_MONOTONIC); + $timings->time('db_time'); if ($changes->{'bug_status'}) { my $new_status = $changes->{'bug_status'}->[1]; @@ -420,8 +418,11 @@ foreach my $bug (@bug_objects) { } } - $timings->{recipients} = $bug->send_changes($changes, $vars); - $timings->{bugmail_time} = clock_gettime(CLOCK_MONOTONIC); + my $recipient_count = $bug->send_changes($changes, $vars); + $timings->time('bugmail_time'); + $timings->label('bug-' . $bug->id); + $timings->label('user-' . $user->id); + $timings->value('recipient_count', $recipient_count); } # Delete the session token used for the mass-change. @@ -447,8 +448,8 @@ elsif ($action eq 'next_bug' or $action eq 'same_bug') { } $template->process("bug/show.html.tmpl", $vars) || ThrowTemplateError($template->error()); - $timings->{template_time} = clock_gettime(CLOCK_MONOTONIC); - _log_timings(); + $timings->time('template_time'); + $timings->log() if scalar(@bug_objects) == 1; exit; } } elsif ($action ne 'nothing') { @@ -461,27 +462,8 @@ unless (Bugzilla->usage_mode == USAGE_MODE_EMAIL) { || ThrowTemplateError($template->error()); $template->process("global/footer.html.tmpl", $vars) || ThrowTemplateError($template->error()); - $timings->{template_time} = clock_gettime(CLOCK_MONOTONIC); - _log_timings(); -} - -sub _log_timings { - return unless scalar(@bug_objects) == 1; - return unless scalar(keys %$timings) == 8; - my $entry = sprintf "process_bug bug-%s user-%s %.6f %.6f %.6f %.6f %.6f %.6f %.6f %s\n", - $bug_objects[0]->id, - $user->id, - $timings->{template_time} - $timings->{start_time}, - $timings->{load_bug} - $timings->{start_time}, - $timings->{mid_air} - $timings->{load_bug}, - $timings->{update_time} - $timings->{mid_air}, - $timings->{db_time} - $timings->{update_time}, - $timings->{bugmail_time} - $timings->{db_time}, - $timings->{template_time} - $timings->{bugmail_time}, - $timings->{recipients}; - openlog('apache', 'cons,pid', 'local4'); - syslog('notice', encode_utf8("[timing] $entry")); - closelog(); + $timings->time('template_time'); + $timings->log() if scalar(@bug_objects) == 1; } 1; |