From 06cd576bb9b73eb177728fead06de8c3fac8d7a3 Mon Sep 17 00:00:00 2001 From: "Eric Wong (Contractor, The Linux Foundation)" Date: Sat, 7 Apr 2018 03:41:49 +0000 Subject: over: remove forked subprocess Since the overview stuff is a synchronization point anyways, move it into the main V2Writable process and allow us to drop a bunch of code. This is another step towards making Xapian optional for v2. In other words, the fan-out point is moved and the Xapian partitions no longer need to synchronize against each other: Before: /-------->\ /---------->\ v2writable -->+----parts----> over \---------->/ \-------->/ After: /----------> /-----------> v2writable --> over-->+----parts---> \-----------> \----------> Since the overview/threading logic needs to run on the same core that feeds git-fast-import, it's slower for small repos but is not noticeable in large imports where I/O wait in the partitions dominates. --- lib/PublicInbox/SearchIdxPart.pm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'lib/PublicInbox/SearchIdxPart.pm') diff --git a/lib/PublicInbox/SearchIdxPart.pm b/lib/PublicInbox/SearchIdxPart.pm index e5766a82..078d2df1 100644 --- a/lib/PublicInbox/SearchIdxPart.pm +++ b/lib/PublicInbox/SearchIdxPart.pm @@ -11,7 +11,6 @@ sub new { # create the DB before forking: $self->_xdb_acquire; $self->_xdb_release; - $self->{over} = $v2writable->{over}; $self->spawn_worker($v2writable, $part) if $v2writable->{parallel}; $self; } @@ -25,7 +24,7 @@ sub spawn_worker { my $pid = fork; defined $pid or die "fork failed: $!\n"; if ($pid == 0) { - $v2writable->atfork_child; + my $bnote = $v2writable->atfork_child; $v2writable = undef; close $w or die "failed to close: $!"; @@ -33,7 +32,7 @@ sub spawn_worker { # speeds V2Writable batch imports across 8 cores by nearly 20% fcntl($r, 1031, 1048576) if $^O eq 'linux'; - eval { partition_worker_loop($self, $r, $part) }; + eval { partition_worker_loop($self, $r, $part, $bnote) }; die "worker $part died: $@\n" if $@; die "unexpected MM $self->{mm}" if $self->{mm}; exit; @@ -43,8 +42,8 @@ sub spawn_worker { close $r or die "failed to close: $!"; } -sub partition_worker_loop ($$$) { - my ($self, $r, $part) = @_; +sub partition_worker_loop ($$$$) { + my ($self, $r, $part, $bnote) = @_; $0 = "pi-v2-partition[$part]"; $self->begin_txn_lazy; while (my $line = $r->getline) { @@ -54,8 +53,9 @@ sub partition_worker_loop ($$$) { $self->_xdb_release; } elsif ($line eq "barrier\n") { $self->commit_txn_lazy; - print { $self->{over}->{w} } "barrier $part\n" or - die "write failed to overview $!\n"; + # no need to lock < 512 bytes is atomic under POSIX + print $bnote "barrier $part\n" or + die "write failed for barrier $!\n"; } elsif ($line =~ /\AD ([a-f0-9]{40,}) (.+)\n\z/s) { my ($oid, $mid) = ($1, $2); $self->begin_txn_lazy; -- cgit v1.2.3-24-ge0c7