[rt-users] some performance improvements when caching transactions in ShowHistory

Ralf Hack ralf.hack at pipex.net
Tue Apr 20 15:08:24 EDT 2004


Hi,
    there was some discussions about benchmarking and performance of 
RT3. I am running RT on an old piece of kit lying around, so performance 
was rather poor compared in general. However, tickets with many 
transactions are real drag.

    A bit of empirical evaluation got me to cache the generation of the 
transaction html code in ShowHistory with dramatic effects -- no 
official performance numbers though, sorry.

    This diff is against RT 3.0.9 (debian) .. but I did the equivalent 
thing for RT 3.0.10 and have similar results. Please consider this as an 
example and do not use it on production machines since it does indeed 
need some serious cleaning up still.

    Hope you can make some use of it. I am sure some database wizzard 
knows a way to put the html into a table with placeholders for the 
customisations.

xxx at tickets:/usr/local/share/request-tracker3/html/Ticket/Elements$ diff 
-Nau ShowHistory.orig ShowHistory
--- ShowHistory.orig    2004-04-20 17:02:25.000000000 +0100
+++ ShowHistory 2004-04-20 19:41:21.000000000 +0100
@@ -54,15 +54,38 @@
 % }
 
 <TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=2 BORDER=0>
-% while (my $Transaction = $Transactions->Next) {
-% my $skip = 0;
-% $m->comp('/Elements/Callback', _CallbackName => 'SkipTransaction', 
Transaction => $Transaction, skip => \$skip, %ARGS);
-% next if $skip;
-% $i++;
-%      if ($Transactions->IsLast) {
-       <a name="lasttrans"></a>
-%      }
-           <& ShowTransaction, Ticket => $Ticket, Transaction => 
$Transaction, ShowHeaders => $ShowHeaders, Collapsed => $Collapsed, 
RowNum => $i, ShowTitleBarCommands => $ShowTitleBarCommands, %ARGS &>
+
+<%perl>
+while (my $Transaction = $Transactions->Next) {
+       my $skip = 0;
+       $m->comp('/Elements/Callback', _CallbackName => 
'SkipTransaction', Transaction => $Transaction, skip => \$skip, %ARGS);
+       next if $skip;
+       $i++;
+       if ($Transactions->IsLast) {
+               $m->out('<a name="lasttrans"></a>');
+       }
+my $tx;
+my $parm = ($Collapsed?"C":".");
+$parm .= ($ShowHeaders?"S":".");
+$parm .= ($i%2?"O":"E");
+if ( open(TX, "/var/tmp/TxCacheSH/$parm".$Transaction->Id) ) {
+       $/=undef;
+       $tx=<TX>;
+       $/="\n";
+       close(TX);
+}
+else {
+       $tx=$m->scomp('ShowTransaction', Ticket => $Ticket, Transaction 
=> $Transaction, ShowHeaders => $ShowHeaders, Collapsed => $Collapsed, 
RowNum => $i, ShowTitleBarCommands => $ShowTitleBarCommands, %ARGS);
+       if ( ! -d "/var/tmp/TxCacheSH" ) {
+               mkdir "/var/tmp/TxCacheSH";
+       };
+       if (open (TX, ">/var/tmp/TxCacheSH/$parm".$Transaction->Id)) {
+               print TX $tx;
+               close(TX);
+       }
+}
+$m->out($tx);
+</%perl>
 % }
 </TABLE>
 % if ($ShowDisplayModes or $ShowTitle) {




More information about the rt-users mailing list