]> Sergey Matveev's repositories - public-inbox.git/blobdiff - script/public-inbox-index
index: max out XAPIAN_FLUSH_THRESHOLD if using --batch-size
[public-inbox.git] / script / public-inbox-index
index a52fb1bf399280218e8d01eff8a8e7bdb6d73d75..e2bca16e92510221a0f95998277be6351dcac6f8 100755 (executable)
@@ -14,9 +14,9 @@ PublicInbox::Admin::require_or_die('-index');
 use PublicInbox::Xapcmd;
 
 my $compact_opt;
-my $opt = { quiet => -1, compact => 0, maxsize => undef, sync => 1 };
-GetOptions($opt, qw(verbose|v+ reindex rethread compact|c+ jobs|j=i prune sync!
-               xapianonly|xapian-only
+my $opt = { quiet => -1, compact => 0, maxsize => undef, fsync => 1 };
+GetOptions($opt, qw(verbose|v+ reindex rethread compact|c+ jobs|j=i prune
+               fsync|sync! xapianonly|xapian-only
                indexlevel|L=s maxsize|max-size=s batchsize|batch-size=s
                sequentialshard|seq-shard|sequential-shard))
        or die "bad command-line args\n$usage";
@@ -42,11 +42,16 @@ if (defined $max_size) {
                die "`publicInbox.indexMaxSize=$max_size' not parsed\n";
 }
 
-if (my $bs = $opt->{batchsize} // $cfg->{lc('publicInbox.indexBatchSize')}) {
+my $bs = $opt->{batchsize} // $cfg->{lc('publicInbox.indexBatchSize')};
+if (defined $bs) {
        PublicInbox::Admin::parse_unsigned(\$bs) or
                die "`publicInbox.indexBatchSize=$bs' not parsed\n";
-       $PublicInbox::SearchIdx::BATCH_BYTES = $bs;
 }
+local $PublicInbox::SearchIdx::BATCH_BYTES = $bs if defined($bs);
+
+# out-of-the-box builds of Xapian 1.4.x are still limited to 32-bit
+# https://getting-started-with-xapian.readthedocs.io/en/latest/concepts/indexing/limitations.html
+local $ENV{XAPIAN_FLUSH_THRESHOLD} ||= '4294967295' if defined($bs);
 
 my $s = $opt->{sequentialshard} //
                        $cfg->{lc('publicInbox.indexSequentialShard')};
@@ -73,7 +78,7 @@ for my $ibx (@ibxs) {
        if ($opt->{compact} >= 2) {
                PublicInbox::Xapcmd::run($ibx, 'compact', $compact_opt);
        }
-       $ibx->{-no_sync} = 1 if !$opt->{sync};
+       $ibx->{-no_fsync} = 1 if !$opt->{fsync};
 
        my $ibx_opt = $opt;
        if (defined(my $s = $ibx->{indexsequentialshard})) {
@@ -83,5 +88,8 @@ EOL
                $ibx_opt = { %$opt, sequentialshard => $v };
        }
        PublicInbox::Admin::index_inbox($ibx, undef, $ibx_opt);
-       PublicInbox::Xapcmd::run($ibx, 'compact', $compact_opt) if $compact_opt;
+       if ($compact_opt) {
+               local $compact_opt->{jobs} = 0 if $ibx_opt->{sequentialshard};
+               PublicInbox::Xapcmd::run($ibx, 'compact', $compact_opt);
+       }
 }