]> Sergey Matveev's repositories - public-inbox.git/commitdiff
t/search.t: use transactions to reduce I/O load
authorEric Wong <e@80x24.org>
Mon, 29 Feb 2016 02:48:45 +0000 (02:48 +0000)
committerEric Wong <e@80x24.org>
Mon, 29 Feb 2016 02:48:53 +0000 (02:48 +0000)
In case folks do not use eatmydata or tmpfs for testing,
use transactions to reduce the number of fsync calls
made and hopefully prevent drives from wearing out.

t/search.t

index 3ec3f304d99644f86315ba744b48920ae74f881d..df5a5d36bf8d772af946fd5fd62ebb3d41f6f9d0 100644 (file)
@@ -34,9 +34,12 @@ ok($@, "exception raised on non-existent DB");
 
 my $rw = PublicInbox::SearchIdx->new($git_dir, 1);
 my $ro = PublicInbox::Search->new($git_dir);
+$rw = undef;
 my $rw_commit = sub {
+       $rw->{xdb}->commit_transaction if $rw;
        $rw = undef;
        $rw = PublicInbox::SearchIdx->new($git_dir, 1);
+       $rw->{xdb}->begin_transaction;
 };
 
 {
@@ -86,6 +89,7 @@ my $rw_commit = sub {
                body => "goodbye forever :<\n");
 
        my $rv;
+       $rw_commit->();
        $root_id = $rw->add_message($root);
        is($root_id, int($root_id), "root_id is an integer: $root_id");
        $last_id = $rw->add_message($last);