[Rt-commit] rt branch, 4.2/init-once-in-db-insert-action, created. rt-4.2.10-17-g6c888db
Alex Vandiver
alexmv at bestpractical.com
Thu Mar 5 15:20:50 EST 2015
The branch, 4.2/init-once-in-db-insert-action has been created
at 6c888db72ae4c1f62210168157091d507b3aa248 (commit)
- Log -----------------------------------------------------------------
commit 6c888db72ae4c1f62210168157091d507b3aa248
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Wed Feb 25 16:22:35 2015 -0500
Reduce the number of Init() calls per upgrade
Init() is a relatively heavy-weight operation, loading the configuration
and all lib/ files, as well as performing post-load consistency checks.
Running it once per insert operation occupies significant time, for no
benefit.
Only run RT::Init() during the first insert; no other action calls
RT::Init(), so they are not eligible for the same change. This drops
the time to upgrade an empty 3.8.17 database to 4.2.10 from 6.5 minutes
to 17s.
diff --git a/sbin/rt-setup-database.in b/sbin/rt-setup-database.in
index 46b0c42..339912f 100644
--- a/sbin/rt-setup-database.in
+++ b/sbin/rt-setup-database.in
@@ -48,6 +48,7 @@
# END BPS TAGGED BLOCK }}}
use strict;
use warnings;
+use 5.010;
use vars qw($Nobody $SystemUser $item);
@@ -348,9 +349,13 @@ sub action_coredata {
}
sub action_insert {
+ state $RAN_INIT;
my %args = @_;
- $RT::Handle = RT::Handle->new;
- RT::Init();
+ unless ($RAN_INIT) {
+ $RT::Handle = RT::Handle->new;
+ RT::Init();
+ $RAN_INIT++;
+ }
$log_actions = 1;
my ($status, $msg) = RT::Handle->CheckCompatibility( $RT::Handle->dbh, 'insert' );
-----------------------------------------------------------------------
More information about the rt-commit
mailing list