my $PACKING_FACTOR = 0.4;
# assume 2 cores if GNU nproc(1) is not available
-sub nproc_parts () {
+sub nproc_parts ($) {
+ my ($creat_opt) = @_;
+ if (ref($creat_opt) eq 'HASH') {
+ if (defined(my $n = $creat_opt->{nproc})) {
+ return $n
+ }
+ }
+
my $n = int($ENV{NPROC} || `nproc 2>/dev/null` || 2);
# subtract for the main process and git-fast-import
$n -= 1;
}
sub new {
+ # $creat may be any true value, or 0/undef. A hashref is true,
+ # and $creat->{nproc} may be set to an integer
my ($class, $v2ibx, $creat) = @_;
my $dir = $v2ibx->{mainrepo} or die "no mainrepo in inbox\n";
unless (-d $dir) {
im => undef, # PublicInbox::Import
parallel => 1,
transact_bytes => 0,
+ current_info => '',
xpfx => $xpfx,
over => PublicInbox::OverIdx->new("$xpfx/over.sqlite3", 1),
lock_path => "$dir/inbox.lock",
rotate_bytes => int((1024 * 1024 * 1024) / $PACKING_FACTOR),
last_commit => [], # git repo -> commit
};
- $self->{partitions} = count_partitions($self) || nproc_parts();
+ $self->{partitions} = count_partitions($self) || nproc_parts($creat);
bless $self, $class;
}
my $all = "$self->{-inbox}->{mainrepo}/all.git";
my @cmd;
unless (-d $all) {
- @cmd = (qw(git init --bare -q), $all);
- PublicInbox::Import::run_die(\@cmd);
- @cmd = (qw/git config/, "--file=$all/config",
- 'repack.writeBitmaps', 'true');
- PublicInbox::Import::run_die(\@cmd);
+ PublicInbox::Import::init_bare($all);
}
@cmd = (qw/git config/, "--file=$pfx/$epoch.git/config",
'include.path', '../../all.git/config');
my $fh = $self->{reindex_pipe} = $git->popen(@cmd, $range);
my $cmt;
while (<$fh>) {
+ chomp;
+ $self->{current_info} = "$i.git $_";
if (/\A$x40$/o && !defined($cmt)) {
- chomp($cmt = $_);
+ $cmt = $_;
} elsif (/\A:\d{6} 100644 $x40 ($x40) [AM]\tm$/o) {
$self->reindex_oid($mm_tmp, $D, $git, $1,
$regen, $reindex);