]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
repo: search index flushes for excessive active refs
authorEric Wong <e@80x24.org>
Fri, 10 Feb 2017 03:30:40 +0000 (03:30 +0000)
committerEric Wong <e@80x24.org>
Fri, 10 Feb 2017 03:32:30 +0000 (03:32 +0000)
For certain repos, having too many active refs will cause
memory usage problems.  Mitigate the Xapian problems, for
now, and consider a switch to GDBM_File or similar for
repos with more refs.

lib/PublicInbox/RepoGitSearchIdx.pm

index 67d7ec3fd6931460272711c2ba441c4880458e2c..d2b4597ed7a760ac90ba17bcab310f4a52a167ce 100644 (file)
@@ -345,10 +345,16 @@ sub index_top_ref ($$$) {
                print $progress "$refname => $tip\n" if $progress;
                replace_or_add($db, $doc_id, $ref_doc);
        }
+       $db->flush;
 
        # update all decorated refs which got snowballed into this one
        delete $active->{$refname};
+       my $n = 100;
        foreach my $ref (keys %$active) {
+               if (--$n <= 0) {
+                       $db->flush;
+                       $n = 100;
+               }
                $ref_doc = get_doc($self, \$doc_id, 'ref', $ref);
                $ref_doc->set_data($active->{$ref});
                if ($progress) {