unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
* [PATCH] cindex: dump cidx shards before inboxes
@ 2023-08-24 22:07 Eric Wong
  2023-08-24 22:14 ` [FAIL?] cindex: maximize SMP when dumping inboxes for --associate Eric Wong
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Wong @ 2023-08-24 22:07 UTC (permalink / raw)
  To: meta

Since cidx shards used for associations are typically bigger
than individual inboxes, we'll dump them first to get better
work scheduling for xap_helper processes.

This gives roughly a 5% performance improvement with doing
a full associate on (git+lore).kernel.org
---
 lib/PublicInbox/CodeSearchIdx.pm | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/lib/PublicInbox/CodeSearchIdx.pm b/lib/PublicInbox/CodeSearchIdx.pm
index 404d6826..a9a7d313 100644
--- a/lib/PublicInbox/CodeSearchIdx.pm
+++ b/lib/PublicInbox/CodeSearchIdx.pm
@@ -511,8 +511,10 @@ sub assoc_max_init ($) {
 	$max < 0 ? ((2 ** 31) - 1) : $max;
 }
 
-sub dump_roots_once {
+sub dump_roots_start {
 	my ($self, $associate) = @_;
+	($XHC, $XH_PID) = PublicInbox::XapClient::start_helper("-j$NPROC");
+	awaitpid($XH_PID, \&cmd_done, ['xap_helper', "-j$NPROC"]);
 	$associate // die 'BUG: no $associate';
 	$TODO{associating} = 1; # keep shards_active() happy
 	progress($self, 'dumping IDs from coderepos');
@@ -571,7 +573,6 @@ sub dump_ibx_start {
 	my $fold_pid = spawn(\@UNIQ_FOLD, $CMD_ENV, { 0 => $fold_r, 1 => $fh });
 	awaitpid($sort_pid, \&cmd_done, \@sort, $associate);
 	awaitpid($fold_pid, \&cmd_done, [@UNIQ_FOLD, '(ibx)'], $associate);
-	($XHC, $XH_PID) = PublicInbox::XapClient::start_helper("-j$NPROC");
 }
 
 sub index_next ($) {
@@ -586,11 +587,11 @@ sub index_next ($) {
 		fp_start($self, $git, $prep_repo);
 		ct_start($self, $git, $prep_repo);
 	} elsif ($TMPDIR) {
+		return if delete($TODO{dump_roots_start});
 		delete $TODO{dump_ibx_start}; # runs OnDestroy once
 		return dump_ibx($self, shift @IBXQ) if @IBXQ;
-		progress($self, 'done dumping inboxes') if $DUMP_IBX_WPIPE;
 		undef $DUMP_IBX_WPIPE; # done dumping inboxes, dump roots
-		dump_roots_once($self, delete($TODO{associate}) // return);
+		delete $TODO{associate};
 	}
 	# else: wait for shards_active (post_loop_do) callback
 }
@@ -934,6 +935,8 @@ EOM
 	$TODO{associate} = PublicInbox::OnDestroy->new($$, \&associate, $self);
 	$TODO{dump_ibx_start} = PublicInbox::OnDestroy->new($$,
 				\&dump_ibx_start, $self, $TODO{associate});
+	$TODO{dump_roots_start} = PublicInbox::OnDestroy->new($$,
+				\&dump_roots_start, $self, $TODO{associate});
 	my $id = -1;
 	@IBXQ = map { ++$id } @IBX;
 }

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-08-24 22:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-24 22:07 [PATCH] cindex: dump cidx shards before inboxes Eric Wong
2023-08-24 22:14 ` [FAIL?] cindex: maximize SMP when dumping inboxes for --associate Eric Wong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).