]> eyrie.org Git - kerberos/krb5-strength.git/commitdiff
Performance tuning of krb5-strength-wordlist for SQLite
authorRuss Allbery <eagle@eyrie.org>
Tue, 25 Mar 2014 22:28:35 +0000 (15:28 -0700)
committerRuss Allbery <eagle@eyrie.org>
Tue, 25 Mar 2014 22:28:35 +0000 (15:28 -0700)
Apply some performance tuning from various threads at Perl Monks
to increase the speed of the bulk creation of the SQLite database.

tools/krb5-strength-wordlist

index fb9d13ce992e4c0586414d056f7ed2963923befa..49bac55251bf66d8c6630766350090402b77a071 100755 (executable)
@@ -131,11 +131,17 @@ sub write_sqlite {
     require DBD::SQLite;
 
     # Open and create the database.
-    my $options = { PrintError => 0, RaiseError => 1, AutoCommit => 0 };
+    my $options = { PrintError => 0, RaiseError => 1, AutoCommit => 1 };
     my $dbh = DBI->connect("dbi:SQLite:dbname=$output", q{}, q{}, $options);
     $dbh->do($SQLITE_CREATE);
 
-    # Prepare the insert statement for each word.
+    # Tune SQLite to improve the speed of bulk inserts.  Use unsafe insert
+    # processing and increase the index cache to 500MB.
+    $dbh->do('PRAGMA synchronous = 0');
+    $dbh->do('PRAGMA cache_size = 500000');
+
+    # Start a transaction and prepare the insert statement for each word.
+    $dbh->begin_work();
     my $sth = $dbh->prepare($SQLITE_INSERT);
 
     # Walk through the input word list and add each word that passes the